public void LockedOntologyTest()
        {
            var o = new Ontology("LockedOntologyTest");

            o.ParseAndExecute("a cat is a kind of person");
            o.IsLocked = true;
            o.ParseAndExecute("an alligator is a kind of cat");
        }
Example #2
0
        public void VerbQuantificationTest()
        {
            var o = new Ontology(nameof(VerbQuantificationTest));

            o.ParseAndExecute(
                "employee and employer are kinds of person",
                "an employee must work for one employer",
                "an employer must be worked for by at least two employees");
            var g        = o.CommonNoun("person").MakeGenerator(10);
            var employee = o.CommonNoun("employee");
            var employer = o.CommonNoun("employer");
            var workFor  = o.Verb("work", "for");

            for (var count = 0; count < 100; count++)
            {
                var invention = g.Generate();
                foreach (var person in invention.PossibleIndividuals)
                {
                    if (person.IsA(employee))
                    {
                        Assert.AreEqual(1, invention.PossibleIndividuals.Count(p => person.RelatesTo(p, workFor)));
                    }
                    else if (person.IsA(employer))
                    {
                        Assert.IsTrue(2 <= invention.PossibleIndividuals.Count(p => p.RelatesTo(person, workFor)));
                    }
                    else
                    {
                        throw new Exception("Object in model that is neither an employee or employer");
                    }
                }
            }
        }
        public void DeclarationOrderTest()
        {
            var o = new Ontology("test");

            o.ParseAndExecute("Persian, tabby, Siamese, manx, Chartreux, and Maine coon are kinds of cat.",
                              "cat, dog, bunny, dragon, toad, basilisk, owl, flumph, boar, phoenix, unicorn, and homunculus are kinds of pet.");
        }
        public void RiTest2()
        {
            // Due to Ri Boksenbaum
            var o = new Ontology("test");

            o.ParseAndExecute("Persian, tabby, Siamese, manx, Chartreux, and Maine coon are kinds of cat.",
                              "   The plural of Chartreux is Chartreux.");
        }
        public void RiTest()
        {
            // Due to Ri Boksenbaum
            var o = new Ontology("test");

            o.ParseAndExecute("sheep and orange are kinds of cat.",
                              "the plural of sheep is sheep");
        }
Example #6
0
        public void ImagineNotKnowingTest()
        {
            var o = new Ontology("Not knowing test")
            {
                IsLocked = true
            };

            o.ParseAndExecute("imagine not knowing what a car is");
        }
        public void NewTest()
        {
            var o = new Ontology("test");

            o.ParseAndExecute("Persian, tabby, Siamese, manx, Chartreux, and Maine coon are kinds of cat.",
                              "Cats are black, white, grey, or ginger.",
                              "The plural of Chartreux is Chartreux",
                              "Chartreux are grey.");
        }
Example #8
0
        public void MonsterTest()
        {
            var o = new Ontology(nameof(MonsterTest));

            foreach (var decl in MonsterSource.Replace("\r", "").Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
            {
                o.ParseAndExecute(decl);
            }
            var g = o.CommonNoun("monster").MakeGenerator(20);

            for (var n = 0; n < 100; n++)
            {
                g.Generate();
            }
            Console.WriteLine(g.Problem.PerformanceStatistics);
            Console.WriteLine($"Average flips per solve: {g.Problem.SolveFlips.Average}");
        }
Example #9
0
        public void PossibleIndividualPartTest()
        {
            var o = new Ontology("PartNamingTest");

            o.ParseAndExecute("A face has eyes",
                              "A face has a mouth",
                              "A face has a nose",
                              "A face has hair");
            var invention = o.Generator("face").Generate();
            var face      = invention.PossibleIndividuals[0];

            Assert.IsTrue(face.IsA("face"));
            Assert.IsTrue(face.Part("eye")[0].IsA("eye"));
            Assert.IsTrue(face.Part("mouth")[0].IsA("mouth"));
            Assert.IsTrue(face.Part("nose")[0].IsA("nose"));
            Assert.IsTrue(face.Part("hair")[0].IsA("hair"));
        }
Example #10
0
        public void PossibleIndividualTest()
        {
            var o = new Ontology("PossibleIndividualTest");

            o.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");
            var i = o.Generator("cat", 10).Generate();

            foreach (var pi in i.PossibleIndividuals)
            {
                Assert.IsTrue(pi.IsA("cat"));
            }
        }
Example #11
0
        public void OverlappingAdjectivesTest()
        {
            var o = new Ontology(nameof(OverlappingAdjectivesTest));

            o.ParseAndExecute("x, y, and z are kinds of thing",
                              "a x is between 4 and 5 of b, c, d, e, f, or g",
                              "a y is between 1 and 2 of b, c, d, e, f, or g",
                              "a z is any 3 of b, c, d, e, f, or g");
            var adjectives = new[] { "b", "c", "d", "e", "f", "g" }.Select(a => o.Adjective(a)).ToArray();
            var g = o.CommonNoun("thing").MakeGenerator();

            for (var i = 0; i < 100; i++)
            {
                var thing = g.Generate().PossibleIndividuals[0];
                var count = adjectives.Count(a => thing.IsA(a));
                Assert.IsTrue(
                    (thing.IsA("x") && count >= 4 && count <= 5) ||
                    (thing.IsA("y") && count >= 1 && count <= 2) ||
                    (thing.IsA("z") && count == 3)
                    );
            }
        }
Example #12
0
        public void IdentifiedAsTest()
        {
            var o = new Ontology(nameof(IdentifiedAsTest));

            o.ParseAndExecute("esoteric crops, dangerous crops, and psychoactive crops are kinds of plant",
                              "wolf's bane, and foo are kinds of esoteric crops",
                              "triffids, poison ivy, and venus flytrap are kinds of dangerous crops",
                              "dartura, wormwood, peyote, ayahuasca, tobacco, and chocolate are kinds of psychoactive crops",
                              "a plant is described as \"[Modifiers] [Noun]\"",
                              "vodka, gin, bourbon, and absinthe are kinds of alcohol base",
                              "an alcohol base is described as \"[Modifiers] [Noun]\"",
                              "an infusion has an alcohol base",
                              "an infusion has a plant",
                              "an infusion is described as \"[plant]-infused [alcohol]\"");
            var g = o.CommonNoun("infusion").MakeGenerator();

            for (var i = 0; i < 100; i++)
            {
                var invention = g.Generate();
                invention.PossibleIndividuals[0].Description();
            }
        }
        public void VerbWithNewNounTest()
        {
            var o = new Ontology("test");

            o.ParseAndExecute("A foo can verb up to 2 foos");
        }