public void AddKnowledgeGetSuperConcept()
        {
            var cnlSentences = new List <string>()
            {
                "Every man is a human-being."
            };
            var feClient = new CogniPySvr();

            feClient.LoadCnlFromString(string.Join("\r\n", cnlSentences), true, true);
            feClient.KnowledgeInsert("John is a man.", true, true);

            var res1 = feClient.GetSuperConceptsOf("John", false);

            Assert.Contains("human-being", res1);

            var res2    = feClient.SparqlQueryInternal(feClient.SelectSuperconceptsSPARQL("John", false));
            var cnlRes2 = feClient.TranslateQueryResultsIntoCnlInPlace(res2);

            Assert.Contains("human-being", cnlRes2.Item2.SelectMany(x => x).ToList());
        }
Exemple #2
0
        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());
        }