• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TripleStore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TripleStore的典型用法代码示例。如果您正苦于以下问题:C# TripleStore类的具体用法?C# TripleStore怎么用?C# TripleStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TripleStore类属于命名空间,在下文中一共展示了TripleStore类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EnsureTestResults

        private void EnsureTestResults(TripleStore store)
        {
            foreach (IGraph g in store.Graphs)
            {
                TestTools.ShowGraph(g);
                Console.WriteLine();
            }

            Assert.AreEqual(2, store.Graphs.Count, "Expected 2 Graphs");
            Assert.AreEqual(8, store.Graphs.Sum(g => g.Triples.Count), "Expected 4 Triples");

            IGraph def = store.Graph(null);
            IGraph named = store.Graph(new Uri("http://example.org/bnodes#graph"));

            HashSet<INode> subjects = new HashSet<INode>();
            foreach (Triple t in def.Triples)
            {
                subjects.Add(t.Subject);
            }
            foreach (Triple t in named.Triples)
            {
                subjects.Add(t.Subject);
            }

            Console.WriteLine("Subjects:");
            foreach (INode subj in subjects)
            {
                Console.WriteLine(subj.ToString() + " from Graph " + (subj.GraphUri != null ? subj.GraphUri.ToString() : "Default"));
            }
            Assert.AreEqual(4, subjects.Count, "Expected 4 distinct subjects");
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:31,代码来源:StoreHandlerBlankNodeTests.cs


示例2: SparqlFunctionsIsNumeric

        public void SparqlFunctionsIsNumeric()
        {
            Graph g = new Graph();
            IUriNode subj = g.CreateUriNode(new Uri("http://example.org/subject"));
            IUriNode pred = g.CreateUriNode(new Uri("http://example.org/predicate"));

            g.Assert(subj, pred, (12).ToLiteral(g));
            g.Assert(subj, pred, g.CreateLiteralNode("12"));
            g.Assert(subj, pred, g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeNonNegativeInteger)));
            g.Assert(subj, pred, g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeNonPositiveInteger)));
            g.Assert(subj, pred, g.CreateLiteralNode("1200", new Uri(XmlSpecsHelper.XmlSchemaDataTypeByte)));
            g.Assert(subj, pred, ((byte)50).ToLiteral(g));
            g.Assert(subj, pred, g.CreateLiteralNode("-50", new Uri(XmlSpecsHelper.XmlSchemaDataTypeByte)));
            g.Assert(subj, pred, g.CreateLiteralNode("-50", new Uri(XmlSpecsHelper.XmlSchemaDataTypeUnsignedByte)));
            g.Assert(subj, pred, g.CreateUriNode(new Uri("http://example.org")));

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

            SparqlQueryParser parser = new SparqlQueryParser();
            SparqlQuery q = parser.ParseFromString("SELECT ?obj (IsNumeric(?obj) AS ?IsNumeric) WHERE { ?s ?p ?obj }");

            Object results = store.ExecuteQuery(q);

            Assert.IsTrue(results is SparqlResultSet, "Result should be a SPARQL Result Set");
            TestTools.ShowResults(results);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:27,代码来源:SparqlNewFunctions.cs


示例3: 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


示例4: TestConstruct

        private void TestConstruct(IGraph data, IGraph expected, String query)
        {
            TripleStore store = new TripleStore();
            store.Add(data);

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


示例5: SparqlUpdateLoad

        public void SparqlUpdateLoad()
        {
            TripleStore store = new TripleStore();

            LoadCommand loadLondon = new LoadCommand(new Uri("http://dbpedia.org/resource/London"));
            LoadCommand loadSouthampton = new LoadCommand(new Uri("http://dbpedia.org/resource/Southampton"), new Uri("http://example.org"));

            store.ExecuteUpdate(loadLondon);
            store.ExecuteUpdate(loadSouthampton);

            Assert.AreEqual(2, store.Graphs.Count, "Should now be 2 Graphs in the Store");
            Assert.AreNotEqual(0, store.Triples.Count(), "Should be some Triples in the Store");

            foreach (IGraph g in store.Graphs)
            {
                foreach (Triple t in g.Triples)
                {
                    Console.Write(t.ToString());
                    if (g.BaseUri != null)
                    {
                        Console.WriteLine(" from " + g.BaseUri.ToString());
                    }
                    else
                    {
                        Console.WriteLine();
                    }
                }
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:29,代码来源:UpdateTests.cs


示例6: TestUpdate

        private void TestUpdate(IGraph data, IGraph expected, String update)
        {
            TripleStore store = new TripleStore();
            store.Add(data);

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


示例7: Main

        static void Main(string[] args)
        {
            TripleStore ts = new TripleStore(@"http://localhost/SparqlQuery.yada")
            { QueryType = QueryType.RemoteSparqlStore };

            var query = from table in new RdfDataContext(ts).ForType<
        }
开发者ID:Stropek,项目名称:Praca-magisterska,代码行数:7,代码来源:Program.cs


示例8: Setup

 public void Setup()
 {
     this._parser = new SparqlQueryParser();
     TripleStore store = new TripleStore();
     Graph g = new Graph();
     FileLoader.Load(g, "describe-algos.ttl");
     store.Add(g);
     this._data = new InMemoryDataset(store);
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:9,代码来源:DescribeAlgorithms.cs


示例9: ParsingStoreHandlerBlankNodesTriGActual

        public void ParsingStoreHandlerBlankNodesTriGActual()
        {
            EnsureTestData("test-bnodes.trig");

            TriGParser parser = new TriGParser();
            TripleStore store = new TripleStore();
            parser.Load(store, new StreamParams("test-bnodes.trig"));

            EnsureTestResults(store);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:10,代码来源:StoreHandlerBlankNodeTests.cs


示例10: CanConvertCannedDcsToRdf

        public void CanConvertCannedDcsToRdf()
        {
            var store = new TripleStore();
            var converter = new DublinCoreConverter(store);

            converter.Convert(EnumerateCannedInput());

            converter.RdfDocument.ExportToN3("testoutputn3.rdf");
            converter.RdfDocument.ExportToRdfXml("testoutputXML.rdf");
        }
开发者ID:bibliopedia,项目名称:bibliopedia,代码行数:10,代码来源:DublinCoreConverterTests.cs


示例11: Query1

 public void Query1()
 {
     var ts = new TripleStore(CreateMemoryStore());
     IQueryable<Track> qry = new RdfDataContext(ts).ForType<Track>();
     IQueryable<Track> q = from t in qry
                           where t.ArtistName == "Thomas Laqueur"
                           select t;
     var resultList = new List<Track>();
     resultList.AddRange(q);
 }
开发者ID:Stropek,项目名称:Praca-magisterska,代码行数:10,代码来源:IntegrationTests.cs


示例12: EnsureTestData

 private void EnsureTestData()
 {
     if (this._data == null)
     {
         TripleStore store = new TripleStore();
         Graph g = new Graph();
         g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
         store.Add(g);
         this._data = new InMemoryDataset(store);
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:11,代码来源:PropertyPathEvaluationTests.cs


示例13: EnsureTestData

        private void EnsureTestData(String testFile)
        {
            if (!File.Exists(testFile))
            {
                TriGParser parser = new TriGParser();
                TripleStore store = new TripleStore();
                parser.Load(store, new TextReaderParams(new StringReader(TestFragment)));

                store.SaveToFile(testFile);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:11,代码来源:StoreHandlerBlankNodeTests.cs


示例14: JosekiQueryWithProjection

 public void JosekiQueryWithProjection()
 {
     TripleStore ts = new TripleStore(@"http://localhost:2020/music");
     IRdfQuery<Track> qry = new RdfDataContext(ts).ForType<Track>();
     var q = from t in qry
                     where t.Year == "2007" &&
                     t.GenreName == "Rory Blyth: The Smartest Man in the World"
                     select new { t.Title, t.FileLocation };
     foreach (var track in q)
     {
         Console.WriteLine(track.Title + ": " + track.FileLocation);
     }
 }
开发者ID:Stropek,项目名称:Praca-magisterska,代码行数:13,代码来源:JosekiTests.cs


示例15: TestEmptyDatasetParsing

         private void TestEmptyDatasetParsing(IStoreReader reader)
         {
             if (!File.Exists("empty.test"))
             {
                 FileStream temp = File.Create("empty.test");
                 temp.Close();
             }

             TripleStore store = new TripleStore();
             reader.Load(store, new VDS.RDF.Storage.Params.StreamParams("empty.test"));

             Assert.AreEqual(0, store.Graphs.Count, "Store should have no Graphs");
         }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:13,代码来源:EmptyFileParsing.cs


示例16: EnsureTestData

        private void EnsureTestData(String testFile)
        {
            if (!File.Exists(testFile))
            {
                TripleStore store = new TripleStore();
                Graph g = new Graph();
                g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                store.Add(g);
                Graph h = new Graph();
                h.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.Functions.LeviathanFunctionLibrary.ttl");
                store.Add(h);

                store.SaveToFile(testFile);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:15,代码来源:StoreHandlerTests.cs


示例17: WritingTriGActual

        private void WritingTriGActual()
        {
            Graph g = new Graph();
            g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            g.BaseUri = null;
            TripleStore store = new TripleStore();
            store.Add(g);

            TriGWriter writer = new TriGWriter();
            System.IO.StringWriter strWriter = new System.IO.StringWriter();
            writer.Save(store, new TextWriterParams(strWriter));

            Console.WriteLine(strWriter.ToString());

            Assert.IsFalse(strWriter.ToString().Equals(String.Empty));
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:16,代码来源:TriGWriterTests.cs


示例18: LoadFromFile

        public static Object LoadFromFile(java.io.File f, string baseUri, org.openrdf.rio.RDFFormat rdff)
        {
            Object obj;

            if (rdff == dotSesameFormats.RDFFormat.N3)
            {
                obj = new Graph();
                if (baseUri != null) ((IGraph)obj).BaseUri = new Uri(baseUri);
                FileLoader.Load((IGraph)obj, f.getPath(), new Notation3Parser());
            }
            else if (rdff == dotSesameFormats.RDFFormat.NTRIPLES)
            {
                obj = new Graph();
                if (baseUri != null) ((IGraph)obj).BaseUri = new Uri(baseUri);
                FileLoader.Load((IGraph)obj, f.getPath(), new NTriplesParser());
            }
            else if (rdff == dotSesameFormats.RDFFormat.RDFXML)
            {
                obj = new Graph();
                if (baseUri != null) ((IGraph)obj).BaseUri = new Uri(baseUri);
                FileLoader.Load((IGraph)obj, f.getPath(), new RdfXmlParser());
            }
            else if (rdff == dotSesameFormats.RDFFormat.TRIG)
            {
                obj = new TripleStore();
                TriGParser trig = new TriGParser();
                trig.Load((ITripleStore)obj, new StreamParams(f.getPath()));
            }
            else if (rdff == dotSesameFormats.RDFFormat.TRIX)
            {
                obj = new TripleStore();
                TriXParser trix = new TriXParser();
                trix.Load((ITripleStore)obj, new StreamParams(f.getPath()));
            }
            else if (rdff == dotSesameFormats.RDFFormat.TURTLE)
            {
                obj = new Graph();
                if (baseUri != null) ((IGraph)obj).BaseUri = new Uri(baseUri);
                FileLoader.Load((IGraph)obj, f.getPath(), new TurtleParser());
            }
            else
            {
                throw new RdfParserSelectionException("The given Input Format is not supported by dotNetRDF");
            }

            return obj;
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:47,代码来源:SesameHelper.cs


示例19: SparqlDefaultGraphExists2

        public void SparqlDefaultGraphExists2()
        {
            TripleStore store = new TripleStore();
            Graph g = new Graph();
            g.Assert(g.CreateUriNode(new Uri("http://example.org/subject")), g.CreateUriNode(new Uri("http://example.org/predicate")), g.CreateUriNode(new Uri("http://example.org/object")));
            store.Add(g);

            Object results = store.ExecuteQuery("ASK WHERE { GRAPH <dotnetrdf:default-graph> { ?s ?p ?o }}");
            if (results is SparqlResultSet)
            {
                Assert.IsTrue(((SparqlResultSet)results).Result);
            }
            else
            {
                Assert.Fail("ASK Query did not return a SPARQL Result Set as expected");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:17,代码来源:DefaultGraphTests.cs


示例20: WritingTriGUncompressedSingleThreaded

        public void WritingTriGUncompressedSingleThreaded()
        {
            Graph g = new Graph();
            g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            g.BaseUri = null;
            TripleStore store = new TripleStore();
            store.Add(g);

            TriGWriter writer = new TriGWriter();
            writer.UseMultiThreadedWriting = false;
            writer.CompressionLevel = WriterCompressionLevel.None;
            System.IO.StringWriter strWriter = new System.IO.StringWriter();
            writer.Save(store, new TextWriterParams(strWriter));

            Console.WriteLine(strWriter.ToString());

            Assert.IsFalse(strWriter.ToString().Equals(String.Empty));
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:18,代码来源:TriGWriterTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Triplet类代码示例发布时间:2022-05-24
下一篇:
C# Triple类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap