Пример #1
0
        public void GetAnnotationsTest(string ax, string lan, string[] signature)
        {
            var cnlSentences = new List <string>()
            {
                "Every data-location-form is a form.",
                @"Annotations:
bela Concept: ""comment"":rdfs 'kaka maka'
bela Concept: ""comment"":rdfs 'biba'@en
_Ala Instance: ""backwardCompatibleWith"":owl 'sdsgd'@ar
."
            };

            var feClient = new CogniPySvr();

            feClient.LoadCnlFromString(string.Join("\r\n", cnlSentences), true, true);
            var result = feClient.GetAnnotationsForSignature(signature);

            //TODO: add also test for adding annotation on a role.
            Assert.Contains(ax, result.Select(x => x.Value.ToString()).ToList());
            Assert.True(rgxForCnlFormat.IsMatch(result.Select(ann => ann.Property).First()));
            Assert.Contains(lan, result.Select(x => x.Language).ToList());
        }
Пример #2
0
        public void KnowledgeInsertAnnotationsTest(bool includeImplicit, bool removeTrivials)
        {
            var cnlSentences = new List <string>()
            {
                "Data-Location-Form is a data-location-form.",
                "Annotations: _Data-Location-Form Instance: description 'A data location form.'@en.",
                "Comment: This comment should not be returned as CNL statement."
            };

            var feClient = new CogniPySvr();

            feClient.LoadCnlFromString(string.Join("\r\n", cnlSentences), true, true);


            var toInsert = new List <string>()
            {
                "Operational-Risk is a thing.",
                "Annotations: _Operational-Risk Instance: network-description 'Network of operational risk.'@en."
            };

            feClient.KnowledgeInsert(string.Join("\r\n", toInsert), true, true);
            var annots = feClient.GetAnnotationsForSignature(new List <string>()
            {
                "Operational-Risk"
            });

            Assert.IsTrue(annots.Where(a => a.Property == "network-description").Count() > 0);

            //Check for number of Annotations: blocks, should be exactly 1
            var toCnl = feClient.ToCNL(includeImplicit, true);

            Assert.AreEqual(1, toCnl.Split(' ').Where(tok => tok.Contains("Annotations:")).Count());

            var toCnlList = feClient.ToCNLList(includeImplicit, removeTrivials, true);

            Assert.AreEqual(1, toCnlList.Count(s => s.Contains("Annotations:")));
        }