Ejemplo n.º 1
0
            public bool Add(Statement s)
            {
                if (domran == 1 && !(s.Object is Entity))
                {
                    return(true);
                }
                ResSet rs = (ResSet)table[s.Predicate];

                if (rs == null)
                {
                    return(true);
                }
                foreach (Entity e in RDFS.GetClosure(rs, superclasses, true))
                {
                    Statement s1 = new Statement(
                        domran == 0 ? s.Subject : (Entity)s.Object,
                        type,
                        e,
                        s.Meta);
                    if (!sink.Add(s1))
                    {
                        return(false);
                    }
                }
                return(true);
            }
Ejemplo n.º 2
0
 public bool Add(Statement s)
 {
     foreach (Entity e in RDFS.GetClosure(new Resource[] { s.Object }, table, true))
     {
         if (!sink.Add(new Statement(s.Subject, s.Predicate, e, s.Meta)))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 3
0
    public static void Main()
    {
        // Create the instance data

        MemoryStore dataModel = new MemoryStore();

        BNode me = new BNode("me");
        BNode you = new BNode("you");

        Entity rdfType = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
        Entity rdfsLabel= "http://www.w3.org/2000/01/rdf-schema#label";
        Entity foafPerson = "http://xmlns.com/foaf/0.1/Person";
        Entity foafAgent = "http://xmlns.com/foaf/0.1/Agent";
        Entity foafName = "http://xmlns.com/foaf/0.1/name";

        dataModel.Add(new Statement(me, rdfType, foafPerson));
        dataModel.Add(new Statement(you, rdfType, foafPerson));
        dataModel.Add(new Statement(me, foafName, (Literal)"John Doe"));
        dataModel.Add(new Statement(you, foafName, (Literal)"Sam Smith"));

        // Create the RDFS engine and apply it to the data model.

        RDFS engine = new RDFS();
        engine.LoadSchema(RdfReader.LoadFromUri(new Uri("http://xmlns.com/foaf/0.1/index.rdf")));

        dataModel.AddReasoner(engine);

        // Query the data model

        // Ask for who are typed as Agents.  Note that the people are
        // typed as foaf:Person, and the schema asserts that foaf:Person
        // is a subclass of foaf:Agent.
        Console.WriteLine("Who are Agents?");
        foreach (Entity r in dataModel.SelectSubjects(rdfType, foafAgent))
            Console.WriteLine("\t" + r);

        // Ask for the rdfs:labels of everyone.  Note that the data model
        // has foaf:names for the people, and the schema asserts that
        // foaf:name is a subproperty of rdfs:label.
        Console.WriteLine("People's labels:");
        foreach (Statement s in dataModel.Select(new Statement(null, rdfsLabel, null)))
            Console.WriteLine("\t" + s);
    }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var rdfStore = new MemoryStore();

            //rdfStore.Add(new Statement(NS.CSO.classEntity, NS.Rdfs.subClassOf, NS.Rdfs.ClassEntity));
            //rdfStore.Add(new Statement(NS.CSO.interfaceEntity, NS.Rdfs.subClassOf, NS.Rdfs.ClassEntity));

            var rdfsReasoner = new RDFS();
            rdfsReasoner.LoadSchema(rdfStore);
            rdfStore.AddReasoner(rdfsReasoner);

            /*using (var wr = new RdfXmlWriter(Console.Out)) {
                wr.BaseUri = NS.NrMeta;
                wr.Write(rdfStore);
            }*/

            /*var r = rdfStore.Contains(new Statement(
                (Entity)(NS.NrDotNetType + "NReco.Operations.ChainOperationCall"),
                (Entity)NS.Rdfs.subClassOfEntity,
                (Entity)(NS.NrDotNetType + "NReco.Operations.OperationCall") )); //
            Console.WriteLine(r.ToString());*/
            /*foreach (Statement s in rdfStore.Select(new Statement(
                    (Entity)(NS.NrDotNetProp+"ContextFilter"),
                    (Entity)NS.Rdfs.domainEntity,
                    null))) { //Entity)(NS.NrDotNetType + "NReco.IProvider`2")
                Console.WriteLine(s.Object.Uri.ToString());
            }*/
            /*Query query = new GraphMatch(new N3Reader(new StringReader(rdfQuery)));
            QueryResultSink sink = new SparqlXmlQuerySink(Console.Out);
            query.Run(rdfStore, sink); */

            using (RdfXmlWriter wr = new RdfXmlWriter(@"c:\temp\_1.rdf")) {
                //wr.BaseUri = NS.NrMeta;
                //wr.Namespaces.AddNamespace(NS.DotNet.Type, "t");
                //wr.Namespaces.AddNamespace(NS.DotNet.Property, "p");
                wr.Write(rdfStore);
            }
            Console.ReadKey();
        }
Ejemplo n.º 5
0
 public SchemaSink(RDFS parent)
 {
     rdfs = parent;
 }
Ejemplo n.º 6
0
			public SchemaSink(RDFS parent) { rdfs = parent; }