Beispiel #1
0
 public void NPListTest()
 {
     ParseAndExecute("tabby, persian, and siamese are kinds of cat");
     Assert.IsTrue(CommonNoun.Find("tabby").IsImmediateSubKindOf(CommonNoun.Find("cat")));
     Assert.IsTrue(CommonNoun.Find("persian").IsImmediateSubKindOf(CommonNoun.Find("cat")));
     Assert.IsTrue(CommonNoun.Find("siamese").IsImmediateSubKindOf(CommonNoun.Find("cat")));
 }
Beispiel #2
0
        public void OptionalAlternativeSetTest()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("cats can be big or small");
            var cat = CommonNoun.Find("cat");

            Assert.AreEqual(1, cat.AlternativeSets.Count);
        }
Beispiel #3
0
        public void RequiredAlternativeSetTest()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("cats are long haired or short haired");
            var cat = CommonNoun.Find("cat");

            Assert.AreEqual(1, cat.AlternativeSets.Count);
        }
Beispiel #4
0
        public void ImpliedAdjectiveTest()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("cats are fuzzy");
            var cat   = CommonNoun.Find("cat");
            var fuzzy = Adjective.Find("fuzzy");
            var g     = new Generator(cat);

            for (var n = 0; n < 100; n++)
            {
                var i = g.Solve();
                Assert.IsTrue(i.IsA(i.Individuals[0], fuzzy));
            }
        }
Beispiel #5
0
        public void Symmetric()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("people can love each other");
            var v = Verb.Find("loves");
            var g = new Generator(CommonNoun.Find("person"), new MonadicConceptLiteral[0], 10);

            foreach (var i1 in g.Individuals)
            {
                foreach (var i2 in g.Individuals)
                {
                    Assert.IsTrue(ReferenceEquals(g.Holds(v, i1, i2), g.Holds(v, i2, i1)));
                }
            }
        }
Beispiel #6
0
        public void NumericPropertyTest()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("cats have an age between 1 and 20");
            var cat = CommonNoun.Find("cat");
            var age = cat.Properties[0];
            var g   = new Generator(cat);

            for (var n = 0; n < 100; n++)
            {
                var i        = g.Solve();
                var ageVar   = i.Individuals[0].Properties[age];
                var ageValue = (float)i.Model[ageVar];
                Assert.IsTrue(ageValue >= 1 && ageValue <= 20);
            }
        }
Beispiel #7
0
        public void Reflexive()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("people must love themselves");
            var v = Verb.Find("loves");
            var g = new Generator(CommonNoun.Find("person"), new MonadicConceptLiteral[0], 10);

            for (int n = 0; n < 100; n++)
            {
                var s = g.Solve();
                foreach (var i in s.Individuals)
                {
                    Assert.IsTrue(s.Holds(v, i, i));
                }
            }
        }
Beispiel #8
0
        public void TotalFunction()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("people must love one person");
            var v = Verb.Find("loves");
            var g = new Generator(CommonNoun.Find("person"), new MonadicConceptLiteral[0], 10);

            for (var n = 0; n < 100; n++)
            {
                var s = g.Solve();
                foreach (var i in s.Individuals)
                {
                    var count = s.Individuals.Count(i2 => s.Holds(v, i, i2));
                    Assert.IsTrue(count == 1);
                }
            }
        }
Beispiel #9
0
        public void PartialFunction()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("people can love one person");
            var  v           = Verb.Find("loves");
            var  g           = new Generator(CommonNoun.Find("person"), new MonadicConceptLiteral[0], 3);
            bool sawNonTotal = false;

            for (var n = 0; n < 300; n++)
            {
                var s = g.Solve();
                foreach (var i in s.Individuals)
                {
                    var count = s.Individuals.Count(i2 => s.Holds(v, i, i2));
                    Assert.IsFalse(count > 1);
                    sawNonTotal |= count == 0;
                }
            }
            Assert.IsTrue(sawNonTotal);
        }