internal static void AdviceTests() { var mind = new MindSet(); mind .AddPattern("$something", "can", "have", "$something2") .HowToEvaluate(c => c["something"].ExtendByAnswer("what does @ have?", c["something2"]) ) .AddPattern("every", "$something") .HowToEvaluate(c => DbConstraint.Entity(null).ExtendByAnswer("what @ is?", c["something"]) ) .AddPattern("blue", "$something") ; mind.AddFact("dog", "what color @ has?", "black"); mind.AddFact("whale", "what color @ has?", "blue"); mind.AddFact("whale", "where @ lives?", "sea"); mind.AddFact("dog", "what @ is?", "mammal"); mind.AddFact("whale", "what @ is?", "mammal"); var evaluation = mind.Evaluator.Evaluate("every blue mammal", Evaluator.HowToEvaluateQ); wl(evaluation.ToString()); foreach (var value in mind.Database.Query(evaluation.Constraint)) { Console.WriteLine("Result: " + value.Substitution); } //what is sky? //the stuff above //what is a blue color? //its an example of a color wl("S: What is The Great Britain?"); wl("U: It is a country."); wl("S: What is a country?"); wl("U: Its a location with a culture, people and so on."); wl("U: USA is a country."); wl("U: Country is a word."); wl("...."); //writes // - how is defined? A location // - which extra props. it has? culture // - which extra props. it has? people wl("S: What culture a country has?"); wl("U: It depends on a concrete country."); wl("S: So do you know some country?"); wl("U: Sure, e.g. germany with their strict culture."); }
internal static void DbTests() { var mind = new MindSet(); mind.AddFact("dog", "how @ is defined?", "animal with four legs"); mind.AddFact("dog", "what does @ eat?", "meat"); var constraint = new DbConstraint( ConstraintEntry.AnswerWhere("dog", "how @ is defined?") ); foreach (var entity in mind.Database.Query(constraint)) { Console.WriteLine(entity.Substitution); } }