Skip to content

Commit

Permalink
Speedup TIME reasoner by caching instant and interval individuals bef…
Browse files Browse the repository at this point in the history
…ore starting
  • Loading branch information
Marco De Salvo committed Jan 10, 2025
1 parent 3080ac5 commit 7a90e5a
Show file tree
Hide file tree
Showing 49 changed files with 282 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteAfterEqualsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEAfterEqualsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEAfterEqualsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteAfterFinishesEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHES),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEAfterFinishesEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEAfterFinishesEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteAfterMetByEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_MET_BY),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEAfterMetByEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEAfterMetByEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteAfterTransitiveEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_AFTER),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEAfterTransitiveEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEAfterTransitiveEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand All @@ -64,7 +69,12 @@ public async Task ShouldExecuteAfterTransitiveEntailmentForInstants()
new OWLObjectProperty(RDFVocabulary.TIME.AFTER),
new OWLNamedIndividual(new RDFResource("ex:Instant2")),
new OWLNamedIndividual(new RDFResource("ex:Instant3"))));
List<OWLInference> inferences = await TIMEAfterTransitiveEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEAfterTransitiveEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteBeforeEqualsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEBeforeEqualsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEBeforeEqualsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteBeforeMeetsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_MEETS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEBeforeMeetsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEBeforeMeetsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteBeforeStartsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_STARTS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEBeforeStartsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEBeforeStartsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteBeforeTransitiveEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_BEFORE),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEBeforeTransitiveEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEBeforeTransitiveEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand All @@ -64,7 +69,12 @@ public async Task ShouldExecuteBeforeTransitiveEntailmentForInstants()
new OWLObjectProperty(RDFVocabulary.TIME.BEFORE),
new OWLNamedIndividual(new RDFResource("ex:Instant2")),
new OWLNamedIndividual(new RDFResource("ex:Instant3"))));
List<OWLInference> inferences = await TIMEBeforeTransitiveEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEBeforeTransitiveEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteContainsEqualsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEContainsEqualsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEContainsEqualsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteContainsTransitiveEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_CONTAINS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEContainsTransitiveEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEContainsTransitiveEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteDuringEqualsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEDuringEqualsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEDuringEqualsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteDuringTransitiveEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_DURING),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEDuringTransitiveEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEDuringTransitiveEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ public async Task ShouldExecuteEqualsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHES),
new OWLNamedIndividual(new RDFResource("ex:Interval1")),
new OWLNamedIndividual(new RDFResource("ex:Interval2"))));
List<OWLInference> inferences = await TIMEEqualsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEEqualsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ public async Task ShouldExecuteEqualsInverseEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_FINISHED_BY),
new OWLNamedIndividual(new RDFResource("ex:Interval1")),
new OWLNamedIndividual(new RDFResource("ex:Interval2"))));
List<OWLInference> inferences = await TIMEEqualsInverseEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEEqualsInverseEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteEqualsTransitiveEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEEqualsTransitiveEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEEqualsTransitiveEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteFinishedByEqualsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEFinishedByEqualsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEFinishedByEqualsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteFinishesEqualsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEFinishesEqualsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEFinishesEqualsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public async Task ShouldExecuteMeetsEqualsEntailment()
new OWLObjectProperty(RDFVocabulary.TIME.INTERVAL_EQUALS),
new OWLNamedIndividual(new RDFResource("ex:Interval2")),
new OWLNamedIndividual(new RDFResource("ex:Interval3"))));
List<OWLInference> inferences = await TIMEMeetsEqualsEntailmentRule.ExecuteRuleAsync(ontology);
Dictionary<string, List<OWLIndividualExpression>> cacheRegistry = new Dictionary<string, List<OWLIndividualExpression>>()
{
{ "INSTANTS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INSTANT)) },
{ "INTERVALS", ontology.GetIndividualsOf(new OWLClass(RDFVocabulary.TIME.INTERVAL)) },
};
List<OWLInference> inferences = await TIMEMeetsEqualsEntailmentRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(inferences);
Assert.IsTrue(inferences.Count == 1);
Expand Down
Loading

0 comments on commit 7a90e5a

Please sign in to comment.