Esempio n. 1
0
        private static void Example4()
        {
            var schema = new Graph();

            schema.Assert("http://schema.com#employee", "owl:inverseOf", "http://schema.com#employer");
            schema.Assert("http://schema.com#employee", "rdfs:domain", "http://schema.com#Company");
            schema.Assert("http://schema.com#employee", "rdfs:range", "http://schema.com#Person");

            var graph = new Graph();

            graph.Assert("http://person.com#bob", "http://schema.com#employer", "http://person.com#acme");

            var reasoner = new Reasoner(schema);

            reasoner.Apply(graph);

            foreach (var triple in graph.GetTriples())
            {
                Console.WriteLine(triple);
            }
        }
Esempio n. 2
0
        private static void Example5()
        {
            var schema = new Graph();

            schema.Assert("http://schema.com#employee", "owl:inverseOf", "http://schema.com#employer");
            schema.Assert("http://schema.com#employee", "rdfs:domain", "http://schema.com#Company");
            schema.Assert("http://schema.com#employee", "rdfs:range", "http://schema.com#Person");

            var graph = new Graph();

            graph.Assert("http://person.com#bob", "http://schema.com#employer", "http://person.com#acme");

            var reasoner = new Reasoner(schema);

            var recordingGraph = new RecordingGraph(graph);

            reasoner.Apply(recordingGraph);

            Console.WriteLine("The combined graph:");
            foreach (var triple in graph.GetTriples())
            {
                Console.WriteLine($"  {triple}");
            }
            Console.WriteLine("The inferred graph:");
            foreach (var triple in recordingGraph.Asserted)
            {
                Console.WriteLine($"  {triple}");
            }
            Console.WriteLine("The original graph:");
            var patch    = recordingGraph.CreatePatch();
            var original = graph.Minus(patch.Assert);

            foreach (var triple in graph.GetTriples())
            {
                Console.WriteLine($"  {triple}");
            }
        }