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


C# Graph.LoadFromFile方法代码示例

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


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

示例1: TestExplainProcessor

        private void TestExplainProcessor(String query)
        {
            if (this._processor == null)
            {
                TripleStore store = new TripleStore();
                Graph g = new Graph();
                g.LoadFromFile("InferenceTest.ttl");
                g.BaseUri = null;
                store.Add(g);

                this._processor = new ExplainQueryProcessor(store);
            }

            SparqlQuery q = this._parser.ParseFromString(query);
            Object results;
            Console.WriteLine("Input Query:");
            Console.WriteLine(this._formatter.Format(q));
            Console.WriteLine();

            Console.WriteLine("Explanation with Default Options (Simulated):");
            this._processor.ExplanationLevel = ExplanationLevel.DefaultSimulation;
            results = this._processor.ProcessQuery(q);

            Console.WriteLine();
            Console.WriteLine("Explanation with Default Options:");
            this._processor.ExplanationLevel = ExplanationLevel.Default;
            results = this._processor.ProcessQuery(q);

            Console.WriteLine();
            Console.WriteLine("Explanation with Full Options:");
            this._processor.ExplanationLevel = ExplanationLevel.Full;
            results = this._processor.ProcessQuery(q);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:33,代码来源:ExplainProcessorTests.cs

示例2: SparqlFunctionsRand

        public void SparqlFunctionsRand()
        {
            String query = "SELECT ?s (RAND() AS ?rand) WHERE { ?s ?p ?o } ORDER BY ?rand";
            Graph g = new Graph();
            g.LoadFromFile("InferenceTest.ttl");

            Object results = g.ExecuteQuery(query);
            if (results is SparqlResultSet)
            {
                SparqlResultSet rset = (SparqlResultSet)results;
                TestTools.ShowResults(rset);
            }
            else
            {
                Assert.Fail("Did not get a SPARQL Result Set as expected");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:17,代码来源:SparqlNewFunctions.cs

示例3: ParsingRdfXmlNamespaces

        public void ParsingRdfXmlNamespaces()
        {
            Graph g = new Graph();
            try
            {
                g.LoadFromFile("rdfxml-namespaces.rdf");
                Assert.Fail("Parsing should fail as namespaces are not properly defined in the RDF/XML");
            }
            catch (RdfParseException parseEx)
            {
                Console.WriteLine("Parser Error thrown as expected");
                Assert.IsTrue(parseEx.HasPositionInformation, "Should have position information");
                Console.WriteLine("Line " + parseEx.StartLine + " Column " + parseEx.StartPosition);

                TestTools.ReportError("Parser Error", parseEx, false);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:17,代码来源:RdfXmlNamespaces.cs

示例4: TestWriteToStoreHandler

        private void TestWriteToStoreHandler(IGenericIOManager manager)
        {
            //First ensure that our test file exists
            EnsureTestData();

            //Try to ensure that the target Graph does not exist
            if (manager.DeleteSupported)
            {
                manager.DeleteGraph(TestGraphUri);
            }
            else
            {
                Graph g = new Graph();
                g.BaseUri = TestGraphUri;
                manager.SaveGraph(g);
            }

            Graph temp = new Graph();
            try
            {
                manager.LoadGraph(temp, TestGraphUri);
                Assert.IsTrue(temp.IsEmpty, "Unable to ensure that Target Graph in Store is empty prior to running Test");
            }
            catch
            {
                //An Error Loading the Graph is OK
            }

            WriteToStoreHandler handler = new WriteToStoreHandler(manager, TestGraphUri, 100);
            TurtleParser parser = new TurtleParser();
            parser.Load(handler, "temp.ttl");

            manager.LoadGraph(temp, TestGraphUri);
            Assert.IsFalse(temp.IsEmpty, "Graph should not be empty");

            Graph orig = new Graph();
            orig.LoadFromFile("temp.ttl");

            Assert.AreEqual(orig, temp, "Graphs should be equal");
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:40,代码来源:WriteToStoreHandlerTests.cs

示例5: WritingCollectionCompressionComplex2

        public void WritingCollectionCompressionComplex2()
        {
            Graph g = new Graph();
            g.LoadFromFile("complex-collections.nt");

            CompressingTurtleWriterContext context = new CompressingTurtleWriterContext(g, Console.Out);
            WriterHelper.FindCollections(context);

            NTriplesFormatter formatter = new NTriplesFormatter();
            foreach (KeyValuePair<INode, OutputRdfCollection> kvp in context.Collections)
            {
                Console.WriteLine("Collection Root - " + kvp.Key.ToString(formatter));
                Console.WriteLine("Collection Triples (" + kvp.Value.Triples.Count + ")");
                foreach (Triple t in kvp.Value.Triples)
                {
                    Console.WriteLine(t.ToString(formatter));
                }
                Console.WriteLine();
            }

            this.CheckCompressionRoundTrip(g);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:22,代码来源:CollectionCompressionTests.cs

示例6: StorageStardogReasoningQL

        public void StorageStardogReasoningQL()
        {
            try
            {
                //Options.UseBomForUtf8 = false;

                StardogConnector stardog = this.GetConnection();

                Graph g = new Graph();
                g.LoadFromFile("InferenceTest.ttl");
                g.BaseUri = new Uri("http://example.org/reasoning");
                stardog.SaveGraph(g);

                String query = "PREFIX rdfs: <" + NamespaceMapper.RDFS + "> SELECT * WHERE { { ?class rdfs:subClassOf <http://example.org/vehicles/Vehicle> } UNION { GRAPH <http://example.org/reasoning> { ?class rdfs:subClassOf <http://example.org/vehicles/Vehicle> } } }";
                Console.WriteLine(query);
                Console.WriteLine();

                SparqlResultSet resultsNoReasoning = stardog.Query(query) as SparqlResultSet;
                if (resultsNoReasoning != null)
                {
                    Console.WriteLine("Results without Reasoning");
                    TestTools.ShowResults(resultsNoReasoning);
                }
                else
                {
                    Assert.Fail("Did not get a SPARQL Result Set as expected");
                }

                stardog.Reasoning = StardogReasoningMode.QL;
                SparqlResultSet resultsWithReasoning = stardog.Query(query) as SparqlResultSet;
                if (resultsWithReasoning != null)
                {
                    Console.WriteLine("Results with Reasoning");
                    TestTools.ShowResults(resultsWithReasoning);
                }
                else
                {
                    Assert.Fail("Did not get a SPARQL Result Set as expected");
                }

                Assert.IsTrue(resultsWithReasoning.Count >= resultsNoReasoning.Count, "Reasoning should yield as many if not more results");
            }
            finally
            {
                //Options.UseBomForUtf8 = true;
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:47,代码来源:StardogTests.cs

示例7: SparqlConstructWithOptional

        public void SparqlConstructWithOptional()
        {
            Graph g = new Graph();
            g.LoadFromFile("InferenceTest.ttl");

            Graph expected = new Graph();
            expected.Assert(g.GetTriplesWithPredicate(g.CreateUriNode("rdf:type")));
            expected.Assert(g.GetTriplesWithPredicate(g.CreateUriNode("eg:Speed")));

            String query = "PREFIX ex: <http://example.org/vehicles/> CONSTRUCT { ?s a ?type . ?s ex:Speed ?speed } WHERE { ?s a ?type . OPTIONAL { ?s ex:Speed ?speed } }";

            this.TestConstruct(g, expected, query);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:13,代码来源:ConstructWithOptionalTests.cs

示例8: SparqlUpdateModifyWithOptional2

        public void SparqlUpdateModifyWithOptional2()
        {
            Graph g = new Graph();
            g.LoadFromFile("InferenceTest.ttl");
            g.BaseUri = new Uri("http://example.org/vehicles/");

            Graph def = new Graph();
            def.Merge(g);

            TripleStore store = new TripleStore();
            store.Add(g);
            store.Add(def);

            Graph expected = new Graph();
            expected.NamespaceMap.Import(g.NamespaceMap);
            expected.Merge(g);
            expected.Retract(expected.GetTriplesWithPredicate(expected.CreateUriNode("rdf:type")));
            expected.Retract(expected.GetTriplesWithPredicate(expected.CreateUriNode("eg:Speed")));

            String update = "PREFIX ex: <http://example.org/vehicles/> DELETE { ?s a ?type . ?s ex:Speed ?speed } INSERT { } USING <http://example.org/vehicles/> WHERE { ?s a ?type . OPTIONAL { ?s ex:Speed ?speed } }";

            this.TestUpdate(store, expected, update);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:23,代码来源:ConstructWithOptionalTests.cs

示例9: SparqlUpdateModifyWithOptional

        public void SparqlUpdateModifyWithOptional()
        {
            Graph g = new Graph();
            g.LoadFromFile("InferenceTest.ttl");
            g.BaseUri = new Uri("http://example.org/vehicles/");

            Graph expected = new Graph();
            expected.Assert(g.GetTriplesWithPredicate(g.CreateUriNode("rdf:type")));
            expected.Assert(g.GetTriplesWithPredicate(g.CreateUriNode("eg:Speed")));

            String update = "PREFIX ex: <http://example.org/vehicles/> DELETE { } INSERT { ?s a ?type . ?s ex:Speed ?speed } USING <http://example.org/vehicles/> WHERE { ?s a ?type . OPTIONAL { ?s ex:Speed ?speed } }";

            this.TestUpdate(g, expected, update);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:14,代码来源:ConstructWithOptionalTests.cs


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