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


C# SparqlResultSet.Trim方法代码示例

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


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

示例1: WritingSparqlXmlWithNulls

        public void WritingSparqlXmlWithNulls()
        {
            TripleStore store = new TripleStore();
            store.Add(new Graph());
            Graph g = new Graph();
            g.BaseUri = new Uri("http://example.org/graph");
            store.Add(g);

            Object results = store.ExecuteQuery("SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }");
            if (results is SparqlResultSet)
            {
                SparqlResultSet rset = (SparqlResultSet)results;
                SparqlXmlWriter writer = new SparqlXmlWriter();
                writer.Save(rset, "temp.srx");

                SparqlXmlParser parser = new SparqlXmlParser();
                SparqlResultSet rset2 = new SparqlResultSet();
                parser.Load(rset2, "temp.srx");

                rset.Trim();
                Console.WriteLine("Original Results");
                TestTools.ShowResults(rset);
                Console.WriteLine();

                rset2.Trim();
                Console.WriteLine("Serializes and Parsed Results");
                TestTools.ShowResults(rset2);
                Console.WriteLine();

                Assert.AreEqual(rset, rset2, "Result Sets should be equal");
            }
            else
            {
                Assert.Fail("Query did not return a Result Set as expected");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:36,代码来源:SparqlXmlTests.cs

示例2: ProcessEvaluationTest


//.........这里部分代码省略.........
                        this.ReportError("Result Set Parser Error", parseEx);
                        testsIndeterminate++;
                        testsEvaluationIndeterminate++;
                        Console.WriteLine("# Test Result - Error loading expected Result Set (Test Indeterminate)");
                        return 0;
                    }
                }
                else if (resultFile.EndsWith(".ttl") || resultFile.EndsWith(".rdf"))
                {
                    try
                    {
                        SparqlRdfParser resultSetParser = new SparqlRdfParser();
                        resultSetParser.Load(expectedResults, resultFile);
                    }
                    catch (RdfParseException parseEx)
                    {
                        this.ReportError("Result Set Parser Error", parseEx);
                        testsIndeterminate++;
                        testsEvaluationIndeterminate++;
                        Console.WriteLine("# Test Result - Error loading expected Result Set (Test Indeterminate)");
                        return 0;
                    }
                }
                else
                {
                    testsIndeterminate++;
                    testsEvaluationIndeterminate++;
                    Console.WriteLine("# Test Result - Unable to load the expected Result Set (Test Indeterminate)");
                    return 0;
                }

                try
                {
                    ourResults.Trim();
                    expectedResults.Trim();
                    if (ourResults.Equals(expectedResults))
                    {
                        testsPassed++;
                        testsEvaluationPassed++;
                        Console.WriteLine("# Test Result - Result Set as expected (Test Passed)");
                        return 1;
                    }
                    else
                    {
                        Console.WriteLine("Final Query");
                        Console.WriteLine(query.ToString());
                        Console.WriteLine();
                        this.ShowTestData(store);
                        this.ShowResultSets(ourResults, expectedResults);
                        testsFailed++;
                        testsEvaluationFailed++;
                        Console.WriteLine("# Test Result - Result Set not as expected (Test Failed)");
                        return -1;
                    }
                }
                catch (NotImplementedException)
                {
                    this.ShowResultSets(ourResults, expectedResults);
                    testsIndeterminate++;
                    testsEvaluationIndeterminate++;
                    Console.WriteLine("# Test Result - Unable to establish if Result Set was as expected (Test Indeterminate)");
                    return 0;
                }
            }
            else if (results is Graph)
            {
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:67,代码来源:SparqlEvaluationTestSuite.cs

示例3: SparqlResultSetEquality

        public void SparqlResultSetEquality()
        {
            SparqlXmlParser parser = new SparqlXmlParser();
            SparqlRdfParser rdfparser = new SparqlRdfParser();
            SparqlResultSet a = new SparqlResultSet();
            SparqlResultSet b = new SparqlResultSet();

            parser.Load(a, "list-3.srx");
            parser.Load(b, "list-3.srx.out");

            a.Trim();
            b.Trim();
            Assert.IsTrue(a.Equals(b));

            a = new SparqlResultSet();
            b = new SparqlResultSet();
            parser.Load(a, "no-distinct-opt.srx");
            parser.Load(b, "no-distinct-opt.srx.out");

            a.Trim();
            b.Trim();
            Assert.IsTrue(a.Equals(b));

            a = new SparqlResultSet();
            b = new SparqlResultSet();
            rdfparser.Load(a, "result-opt-3.ttl");
            parser.Load(b, "result-opt-3.ttl.out");

            a.Trim();
            b.Trim();
            Assert.IsTrue(a.Equals(b));
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:32,代码来源:SparqlTests.cs


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