当前位置: 首页>>代码示例>>C#>>正文


C# Store.AddReasoner方法代码示例

本文整理汇总了C#中Store.AddReasoner方法的典型用法代码示例。如果您正苦于以下问题:C# Store.AddReasoner方法的具体用法?C# Store.AddReasoner怎么用?C# Store.AddReasoner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Store的用法示例。


在下文中一共展示了Store.AddReasoner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnLoad

    protected override void OnLoad(EventArgs e)
    {
        RdfStore = new MemoryStore();
        RdfStore.Import(
            new RdfXmlReader(@"c:\temp\_1.rdf"));

        string depRules = @"
        @prefix n: <urn:schemas-nreco:metadata:terms#>.
        @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
        @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.

        { ?a n:dependentFrom ?b . ?b n:dependentFrom ?c .} => {?a n:dependentFrom ?c}.
        { ?a n:dependentFrom ?b } => { ?b n:usedBy ?a}.
        { ?a n:usedBy ?b . ?b n:usedBy ?c .} => {?a n:usedBy ?c}.
        ";

        Euler engine = new Euler(new N3Reader(new StringReader(depRules)));

        RdfStore.AddReasoner(new RDFS(RdfStore));
        RdfStore.AddReasoner(engine);

        string rdfQuery = @"
        @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
        @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
        @prefix p: <urn:schemas-nreco:metadata:dotnet:property#>.
        @prefix t: <urn:schemas-nreco:metadata:dotnet:type#>.
        @prefix w: <file:///d:/Vitalik/GoogleCode/NReco/examples/NReco.Examples.WebApp/web/#>.
        @prefix cso: <http://cos.ontoware.org/cso#>.
        @prefix n: <urn:schemas-nreco:metadata:terms#>.
        w:db n:usedBy ?t2.
        ";

        Query query = new GraphMatch(new N3Reader(new StringReader(rdfQuery)));
        StringWriter wr = new StringWriter();
        QueryResultSink sink = new SparqlXmlQuerySink(wr);
        query.Run(RdfStore, sink);
        Result = wr.ToString();

        base.OnLoad(e);
    }
开发者ID:Mariamfelicia,项目名称:nreco,代码行数:40,代码来源:Default.aspx.cs

示例2: Main

    public static void Main(string[] args)
    {
        if (args.Length < 2) {
            Console.WriteLine("Usage: euler.exe axioms.n3 axioms... {questions.n3 | -sparql query.sparql}");
            return;
        }

        // Load Axioms

        bool sparql = false;

        MemoryStore axioms = new MemoryStore();
        for (int i = 0; i < args.Length-1; i++) {
            if (i > 0 && i == args.Length-2 && args[i] == "-sparql") {
                sparql = true;
                break;
            }

            N3Reader axiomsreader = new N3Reader(args[i]);
            axiomsreader.BaseUri = "http://www.example.org/arbitrary/base#";
            axioms.Import(axiomsreader);
        }

        Euler engine = new Euler(axioms);

        // Load question
        if (!sparql) {
            MemoryStore question = new MemoryStore();
            question.Import(new N3Reader(args[args.Length-1]));

            Proof[] proofs = engine.Prove(null, question.ToArray());

            foreach (Proof p in proofs) {
                Console.WriteLine(p.ToString());
            }
        } else {
            using (StreamReader fs = new StreamReader(args[args.Length-1])) {
                string q = fs.ReadToEnd();

                Store store = new Store();
                store.AddReasoner(engine);

                SparqlEngine s = new SparqlEngine(q);
                s.Run(store, Console.Out);
            }
        }
    }
开发者ID:JoshData,项目名称:semweb-dotnet,代码行数:47,代码来源:euler.cs


注:本文中的Store.AddReasoner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。