Skip to content

Commit

Permalink
Speedup TIME validator by caching instant and interval individuals be…
Browse files Browse the repository at this point in the history
…fore starting
  • Loading branch information
Marco De Salvo committed Jan 10, 2025
1 parent c98b194 commit 7bacd30
Show file tree
Hide file tree
Showing 10 changed files with 261 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public async Task ShouldAnalyzeInstantAfterAndViolateRule1()
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
]);
List<OWLIssue> issues = await TIMEInstantAfterAnalysisRule.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<OWLIssue> issues = await TIMEInstantAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(issues);
Assert.IsTrue(issues.Count == 2);
Expand Down Expand Up @@ -101,7 +106,12 @@ public async Task ShouldAnalyzeInstantAfterAndViolateRule2()
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
]);
List<OWLIssue> issues = await TIMEInstantAfterAnalysisRule.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<OWLIssue> issues = await TIMEInstantAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(issues);
Assert.IsTrue(issues.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public async Task ShouldAnalyzeInstantBeforeAndViolateRule1()
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
]);
List<OWLIssue> issues = await TIMEInstantBeforeAnalysisRule.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<OWLIssue> issues = await TIMEInstantBeforeAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(issues);
Assert.IsTrue(issues.Count == 2);
Expand Down Expand Up @@ -101,7 +106,12 @@ public async Task ShouldAnalyzeInstantBeforeAndViolateRule2()
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
]);
List<OWLIssue> issues = await TIMEInstantBeforeAnalysisRule.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<OWLIssue> issues = await TIMEInstantBeforeAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);

Assert.IsNotNull(issues);
Assert.IsTrue(issues.Count == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule1()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalAfter";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -104,7 +109,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule2()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalBefore";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -147,7 +157,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule3()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalContains";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -190,7 +205,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule4()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalDuring";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -233,7 +253,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule5()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalEquals";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -276,7 +301,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule6()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalFinishedBy";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -319,7 +349,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule7()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalFinishes";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -362,7 +397,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule8()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:hasInside";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -405,7 +445,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule9()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalIn";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -448,7 +493,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule10()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalMeets";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -491,7 +541,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule11()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalMetBy";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -534,7 +589,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule12()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:notDisjoint";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -577,7 +637,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule13()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalOverlappedBy";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -620,7 +685,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule14()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalOverlaps";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -663,7 +733,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule15()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalStartedBy";

Assert.IsNotNull(issues);
Expand Down Expand Up @@ -706,7 +781,12 @@ public async Task ShouldAnalyzeIntervalAfterAndViolateRule16()
new OWLNamedIndividual(new RDFResource("ex:IntervalA")),
new OWLNamedIndividual(new RDFResource("ex:IntervalC"))),
]);
List<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.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<OWLIssue> issues = await TIMEIntervalAfterAnalysisRule.ExecuteRuleAsync(ontology, cacheRegistry);
string clashingRelation = "time:intervalStarts";

Assert.IsNotNull(issues);
Expand Down
Loading

0 comments on commit 7bacd30

Please sign in to comment.