public void CloneReasonerBigOntologyTest() { var feClient = new CogniPySvr(); feClient.LoadCnl(Path.Combine(AssemblyDirectory, "TestFiles", "RODO.encnl"), true, true); var clone1 = feClient.CloneForAboxChangesOnly(); var toAdd = new List <string>() { "Element-1-Form-D-24-01-2019-T-15-42-57[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>] is a element-1-form.", "Survey[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>] is a subject[sfo].", "Element-1-Form-D-24-01-2019-T-15-42-57[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>] concern[sfo] Survey[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>].", "Survey[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>] is-concerned-by[sfo] Element-1-Form-D-24-01-2019-T-15-42-57[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>].", "Element-1-1-Section-D-24-01-2019-T-15-42-57[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>] is a element-1-1-section.", "Element-1-Form-D-24-01-2019-T-15-42-57[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>] concern[sfo] Element-1-1-Section-D-24-01-2019-T-15-42-57[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>]." }; clone1.KnowledgeInsert(string.Join("\r\n", toAdd), false, true); clone1.KnowledgeDelete(string.Join("\r\n", toAdd), true); var instances = clone1.GetInstancesOf("element-1-form", false); CollectionAssert.DoesNotContain(instances, "Element-1-Form-D-24-01-2019-T-15-42-57[<http://www.sfo.cognitum.eu/Survey/2d3ce1df-a509-4c00-9a25-ac20e54efdf8#>]"); }
public void SR15BUG() { var reasoner = new CogniPySvr(); var ontologyPath = Path.Combine(AssemblyDirectory, "TestFiles", "TestOntology.encnl"); reasoner.LoadCnl(ontologyPath, true, true); const string concept = "reputational-risk-network-component"; var instances = reasoner.GetInstancesOf(concept, false); var descriptionsBeforeDeletion = reasoner.DescribeInstancesByName(instances); var toDel = new List <string> { "Deal-Criteria-14 is a deal-criteria.", "Deal-Criteria-11 is a deal-criteria.", "Deal-Criteria-26 is a deal-criteria.", "Deal-Criteria-8 is a deal-criteria.", "Deal-Criteria-2 is a deal-criteria.", "Deal-Criteria-20 is a deal-criteria.", "Deal-Criteria-23 is a deal-criteria.", "Deal-Criteria-5 is a deal-criteria.", "Deal-Criteria-17 is a deal-criteria." }; reasoner.KnowledgeDelete(string.Join("\r\n", toDel), true); var descriptionsAfterDeletion = reasoner.DescribeInstancesByName(instances); }
public void SR11BUG() { var toinstert = new string[] { "Deal-Criteria-2 is a reputational-risk-network-deal-criteria.", "Deal-Criteria-2 is a reputational-risk-network-component.", "Deal-Criteria-2 has-sql-name equal-to ''.", "Deal-Criteria-2 has-availability equal-to 'Data-Available'.", "Deal-Criteria-2 has-unit equal-to ''.", "Deal-Criteria-2 has-aggregation equal-to 'None'.", "Annotations:\r\n_Deal-Criteria-2 Instance: node-label 'Importance'@en\r\n_Deal-Criteria-2 Instance: node-description 'Importance'@en\r\n." }; var reasoner = new CogniPySvr(); reasoner.LoadCnl(Path.Combine(AssemblyDirectory, "TestFiles", "ont2.encnl"), true, true); foreach (var l in toinstert) { reasoner.KnowledgeInsert(l, true, true); } var sups = reasoner.GetSuperConceptsOf("Deal-Criteria-2", false); Assert.AreEqual(sups.Count(), 4); var descr = reasoner.DescribeInstances("Deal-Criteria-2"); Assert.AreEqual(descr.Count(), 1); }
public void SR14BUG() { var reasoner = new CogniPySvr(); reasoner.LoadCnl(Path.Combine(AssemblyDirectory, "TestFiles", "TestTBox.encnl"), true, false); var desc = reasoner.DescribeInstances("Nikolai"); Assert.IsEmpty(desc); }
public void LoadFileWithReference() { var feClient = new CogniPySvr(); feClient.LoadCnl(Path.Combine(AssemblyDirectory, "TestFiles", "CSHC.encnl"), true, true); var instances = new string[] { "Dynamic[sfo]", "Answer-2-1-10-1" }; var result = feClient.DescribeInstancesByName(instances); CollectionAssert.AreEquivalent(instances, result.Select(x => x.Instance).ToArray()); }
private CogniPySvr InitializeClient(string ontologyFile, bool materialize = true) { var ontologyDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; var ontologyPath = Path.Combine(ontologyDirectory, "TestFiles", ontologyFile); var client = new CogniPySvr(); client.LoadCnl(ontologyPath, true, materialize); return(client); }
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()); }
public void GetInstancesOfTest() { var cnlSentencesToInsert = new List <string>() { "Survey[<http://www.sfo.cognitum.eu/Survey/29ed4b1d-fa55-479b-93aa-7773b30bda6b#>] is a subject[sfo].", }; var feClient = new CogniPySvr(); feClient.LoadCnl(Path.Combine(AssemblyDirectory, "TestFiles", "CSHC.encnl"), true, true); feClient.KnowledgeInsert(cnlSentencesToInsert.First(), true, true); feClient.KnowledgeInsert(cnlSentencesToInsert.Last(), true, true); var instances = feClient.GetInstancesOf("a subject[sfo]", false); Assert.Contains("Survey[<http://www.sfo.cognitum.eu/Survey/29ed4b1d-fa55-479b-93aa-7773b30bda6b#>]", instances); var instances2 = feClient.GetInstancesOf("Survey[<http://www.sfo.cognitum.eu/Survey/29ed4b1d-fa55-479b-93aa-7773b30bda6b#>]", false); Assert.Contains("Survey[<http://www.sfo.cognitum.eu/Survey/29ed4b1d-fa55-479b-93aa-7773b30bda6b#>]", instances2); }