예제 #1
0
        protected void TestReasoner(DalcRdfStore dalcStore)
        {
            var store = new Store(dalcStore);
            Euler engine = new Euler(new N3Reader(new StringReader(eulerRules)));
            store.AddReasoner(engine);

            Console.WriteLine(
                "Is Adam a parent of Bill? "+
                store.Contains(
                    new Statement(baseNs + "persons#1", baseNs + "terms#is_parent", (Entity)(baseNs + "persons#4"))).ToString());
            Console.WriteLine(
                "Is Eve a parent of Bill? " +
                store.Contains(
                    new Statement(baseNs + "persons#2", baseNs + "terms#is_parent", (Entity)(baseNs + "persons#4"))).ToString());

            Console.Write("Children of Eve: ");
            var res = store.Select(new Statement(null, baseNs + "terms#is_child", (Entity)(baseNs + "persons#2") ));
            foreach (var st in res) {
                var nameRes = store.Select( new Statement( st.Subject.Uri, ns_foaf_name, null) );
                Console.Write(String.Format("({0})", dalcStore.GetDataKey(st.Subject).Id));
                foreach (var nameSt in nameRes)
                    Console.Write( nameSt.Object.ToString() + " ");
            }
            Console.WriteLine();
        }