private static void Main() { // Initializing required database engine modules: // - Basic operations // - N3-Interpreter // - Brain Initializer.Initialize(); Logics.N3.Initializer.Initialize(); Logics.Think.Initializer.Initialize(); using (var model = ModelManager.CreateInMemoryModel(Names.DatabaseName).AutoDispose().Think(Names.Brain)) { using (var reader = new StreamReader("Ontology/testData.n3")) { model.AddStatements(reader.Parse()); } SwapListAppend(model); SwapListLast(model); SwapListMember(model); SwapLogConjunction(model); SwapLogContent(model); SwapLogIncludes(model); SwapLogNotIncludes(model); SwapLogEqualTo(model); SwapLogNotEqualTo(model); SwapLogSupports(model); SwapLogSemantics(model); SwapLogUri(model); SwapMathDifference(model); SwapMathEqualTo(model); SwapMathGreaterThan(model); SwapMathIntegerQuotient(model); SwapMathLessThan(model); SwapMathNegation(model); SwapMathNotEqualTo(model); SwapMathNotGreaterThan(model); SwapMathNotLessThan(model); SwapMathProduct(model); SwapMathQuotient(model); SwapMathRemainder(model); SwapMathSum(model); SwapStringConcatenation(model); SwapStringFormat(model); SwapStringGreaterThan(model); SwapStringLessThan(model); SwapStringMatches(model); SwapStringNotGreater(model); SwapStringNotLessThan(model); SwapStringNotMatches(model); SwapTimeInSeconds(model); } }
private static void Main() { // Initializing required database engine modules: // - Basic operations // - N3-Interpreter // - Brain Initializer.Initialize(); Logics.N3.Initializer.Initialize(); Logics.Think.Initializer.Initialize(); // Simple inference example using (var model = ModelManager.CreateInMemoryModel(Names.DatabaseName).AutoDispose().Think(Names.Brain)) { model.AddStatements(@" @prefix : <http://www.example.com/logics/example#>. :Paul :mother :Rita. :Rita :mother :Caroline. { ?x :mother ?y. ?y :mother ?z. } => { ?x :grandmother ?z }. ".ParseString()); var grandmother = model.GetFact(Names.Paul, Names.Grandmother); Console.WriteLine("Paul's grandmother is: {0}", Helpers.Beautify(grandmother)); } // Recursion example using (var model = ModelManager.CreateInMemoryModel(Names.DatabaseName).AutoDispose().Think(Names.Brain)) { model.AddStatements(@" @prefix : <http://www.example.com/logics/example#>. :Paul a :Person; :child :Rita; :child :Caroline. :Rita a :Person. :Caroline a :Person; :child :Dirk. :Dirk a :Person. :Greta a :Person; :child :Jos. :Jos a :Person. # First rule: end of recursion { ?x a :Person. ?x :child ?y. } => { ?x :descendants ?y. }. # Second rule: recursion body { ?x a :Person. ?x :child ?z. ?z :descendants ?y. } => { ?x :descendants ?y. }. ".ParseString()); var descendants = model.GetFacts(Names.Paul, Names.Example.CreateName("descendants")).ToArray(); Console.WriteLine("Paul's descendants: {0}", string.Join(", ", descendants.Select(Helpers.Beautify))); } }