public void GetConstraintsTest(string subjectToCheck, Modality constraint, IEnumerable <string> relationsToCheck, IEnumerable <string> objectsToCheck) { var cnlSentences = new List <string>() { "Every data-location-form is a form.", "Every data-location-form can concern a data-location-section-1.", "Every data-location-form must concern a data-location-section-2.", "Data-Location-Form is a data-location-form.", "If a data-location-form is a bubu then the data-location-form is a bibi.", "Every bubu must have-value (some string value).", "Every bubu must have-value (some datetime value).", "Every bubu must have-value (some integer value).", "Every bubu must have-value (some real value).", "Every bubu must have-value (some boolean value).", "Every bubu must have-value (some duration value).", "Every bubu must have-this[sfo] a smth[sfo].", "Bubu is a bubu.", "Bubu[sfo] is a bubu.", "Every some-concept[sfo] must concern an other-concept.", "Element-1-Form-D-14-08-2018-T-14-50-7[<http://www.sfo.cognitum.eu/Survey/a536f37b-00f5-492d-80ff-c84948d862ec#>] is a some-concept[sfo].", "References: [sfo] 'http://sfo.com' ('http://sfo.com') ." }; var feClient = new CogniPySvr(); feClient.LoadCnlFromString(string.Join("\r\n", cnlSentences), true, true); var sw = new Stopwatch(); sw.Start(); var constraints = feClient.GetConstraints(new List <string>() { subjectToCheck }); //, "a data-location-form", "Baba[sfo]", "baba[sfo]" sw.Stop(); var elap = sw.ElapsedMilliseconds; CollectionAssert.Contains(constraints.Keys, subjectToCheck); CollectionAssert.IsSubsetOf(relationsToCheck, constraints[subjectToCheck].Relations[constraint]); CollectionAssert.IsSubsetOf(objectsToCheck, constraints[subjectToCheck].ThirdElement[constraint]); }
public void GetConstraintsBig() { var feClient = new CogniPySvr(); feClient.LoadCnl(Path.Combine(AssemblyDirectory, "TestFiles", "CSHC.encnl"), true, true); Stopwatch sw = new Stopwatch(); sw.Start(); feClient.KnowledgeInsert("Element-1-Form-D-14-08-2018-T-14-55-26[<http://www.sfo.cognitum.eu/Survey/5d09ffea-d461-4335-a3c9-03e74aec92eb#>] is a form[sfo].", true, true); sw.Stop(); var elapUpdate = sw.ElapsedMilliseconds; sw.Restart(); var constraints = feClient.GetConstraints(new List <string>() { "form[sfo]", "element-1-form", "Element-1-Form-D-14-08-2018-T-14-55-26[<http://www.sfo.cognitum.eu/Survey/5d09ffea-d461-4335-a3c9-03e74aec92eb#>]" }); sw.Stop(); var elap = sw.ElapsedMilliseconds; Assert.Contains("form[sfo]", constraints.Keys); Assert.Contains("element-1-form", constraints.Keys); Assert.Contains("Element-1-Form-D-14-08-2018-T-14-55-26[<http://www.sfo.cognitum.eu/Survey/5d09ffea-d461-4335-a3c9-03e74aec92eb#>]", constraints.Keys); Assert.IsTrue(elap < 1000); sw.Restart(); var res1 = feClient.GetSuperConceptsOf("Element-1-Form-D-14-08-2018-T-14-55-26[<http://www.sfo.cognitum.eu/Survey/5d09ffea-d461-4335-a3c9-03e74aec92eb#>]", false); Assert.Contains("form[sfo]", res1); sw.Stop(); var elapReasoner = sw.ElapsedMilliseconds; sw.Restart(); var res2 = feClient.SparqlQueryInternal(feClient.SelectSuperconceptsSPARQL("Element-1-Form-D-14-08-2018-T-14-55-26[<http://www.sfo.cognitum.eu/Survey/5d09ffea-d461-4335-a3c9-03e74aec92eb#>]", false)); var cnlRes2 = feClient.TranslateQueryResultsIntoCnlInPlace(res2); var elapSparql = sw.ElapsedMilliseconds; Assert.Contains("form[sfo]", cnlRes2.Item2.SelectMany(x => x).ToList()); }