Exemplo n.º 1
0
        public void  CompoundNounTest()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("a cat is a kind of person",
                            "a persian is a kind of cat",
                            "a tabby is a kind of cat",
                            "a siamese is a kind of cat",
                            "a cat can be haughty",
                            "a cat can be cuddly",
                            "a cat can be crazy",
                            "a persian can be matted",
                            "thaumaturge and necromancer are kinds of magic user");
            var cat       = (CommonNoun)Noun.Find("cat");
            var magicUser = (CommonNoun)Noun.Find("magic", "user");
            var g         = new Generator(cat, magicUser);

            for (var n = 0; n < 100; n++)
            {
                var i = g.Solve();
                Assert.IsTrue(i.IsA(i.Individuals[0], cat));
                Assert.IsTrue(i.IsA(i.Individuals[0], "persian") ||
                              i.IsA(i.Individuals[0], "tabby") ||
                              i.IsA(i.Individuals[0], "siamese"));
                Console.WriteLine(i.Model.Model);
                Console.WriteLine(i.Description(i.Individuals[0]));
            }
        }
Exemplo n.º 2
0
        public void PartTest()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("a cat is a kind of person",
                            "a persian is a kind of cat",
                            "a tabby is a kind of cat",
                            "a siamese is a kind of cat",
                            "a cat can be haughty",
                            "a cat can be cuddly",
                            "a cat can be crazy",
                            "a persian can be matted",
                            "red, blue, and green are kinds of color",
                            "a cat has a color called its favorite color");
            var cat   = (CommonNoun)Noun.Find("cat");
            var color = (CommonNoun)Noun.Find("color");
            var g     = new Generator(cat);

            for (var n = 0; n < 100; n++)
            {
                var i = g.Solve();
                Assert.IsTrue(i.IsA(i.Individuals[0], cat));
                Assert.IsTrue(i.IsA(i.Individuals[0], "persian") ||
                              i.IsA(i.Individuals[0], "tabby") ||
                              i.IsA(i.Individuals[0], "siamese"));
                Assert.AreEqual(i.Individuals[0], i.Individuals[1].Container);
                Assert.IsTrue(i.IsA(i.Individuals[1], color));
                Console.WriteLine(i.Model.Model);
                Console.WriteLine(i.Description(i.Individuals[0]));
            }
        }
Exemplo n.º 3
0
        public void ProperNameTest()
        {
            Ontology.EraseConcepts();
            ParseAndExecute("a cat is a kind of person",
                            "a persian is a kind of cat",
                            "a tabby is a kind of cat",
                            "a siamese is a kind of cat",
                            "a cat can be haughty",
                            "a cat can be cuddly",
                            "a cat can be crazy",
                            "a persian can be matted",
                            "thaumaturgy is a form of magic",
                            "necromancy is a form of magic",
                            "a magic user must practice one form of magic");
            var cat         = (CommonNoun)Noun.Find("cat");
            var magicUser   = (CommonNoun)Noun.Find("magic", "user");
            var thaumaturgy = Individual.AllPermanentIndividuals["thaumaturgy"];
            var necromancy  = Individual.AllPermanentIndividuals["necromancy"];
            var g           = new Generator(cat, magicUser);

            for (var n = 0; n < 100; n++)
            {
                var i = g.Solve();
                Assert.IsTrue(i.Holds("practices", i.Individuals[0], thaumaturgy) ||
                              i.Holds("practices", i.Individuals[0], necromancy));
                Console.WriteLine(i.Model.Model);
                Console.WriteLine(i.Description(i.Individuals[0]));
            }
        }
Exemplo n.º 4
0
 public void InterningNounTest()
 {
     Ontology.EraseConcepts();
     ParseAndExecute("Tabby, Persian, and Maine Coon are kinds of cat");
     Assert.IsNotNull(Noun.Find("Persian"));
     Assert.IsNotNull(Noun.Find("Persians"));
 }
Exemplo n.º 5
0
 /// <summary>
 /// True if the concept with the specified name applies to the individual in the current Model.
 /// </summary>
 /// <param name="i">Individual to test</param>
 /// <param name="name">Name of concept to test</param>
 /// <returns>True if Individual is an instance of the named concept.</returns>
 public bool IsA(Individual i, params string[] name) => IsA(i, (CommonNoun)Noun.Find(name));
Exemplo n.º 6
0
 public void PluralDeclarationTest()
 {
     Ontology.EraseConcepts();
     ParseAndExecute("the plural of person is people");
     Assert.AreEqual("people", ((CommonNoun)Noun.Find("person")).PluralForm[0]);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Returns the common noun identified by the specified sequence of tokens, or null, if there is no such noun.
 /// </summary>
 /// <param name="name">Tokens identifying the noun</param>
 /// <returns>Identified noun, or null if none found.</returns>
 public new static CommonNoun Find(params string[] name)
 {
     return((CommonNoun)Noun.Find(name));
 }