Exemplo n.º 1
0
        public void SparqlPropertyPathEvaluationNonRigorous()
        {
            try
            {
                Graph g = new Graph();
                g.LoadFromFile(@"resources\InferenceTest.ttl");
                InMemoryDataset dataset = new InMemoryDataset(g);

                String query = "SELECT * WHERE { ?subClass <http://www.w3.org/2000/01/rdf-schema#subClassOf>* ?class }";

                SparqlQuery q = new SparqlQueryParser().ParseFromString(query);
                Console.WriteLine(new SparqlFormatter().Format(q));
                Console.WriteLine(q.ToAlgebra().ToString());
                LeviathanQueryProcessor processor = new LeviathanQueryProcessor(dataset);
                SparqlResultSet         results   = processor.ProcessQuery(q) as SparqlResultSet;
                Assert.NotNull(results);

                Console.WriteLine();
                TestTools.ShowResults(results);

                Assert.Equal(73, results.Count);
            }
            finally
            {
                Options.RigorousEvaluation = false;
            }
        }
Exemplo n.º 2
0
        public void SparqlPropertyPathEvaluationCore349NonRigorousEvaluation()
        {
            try
            {
                Options.RigorousEvaluation = false;

                //Test case from CORE-349
                Graph g = new Graph();
                g.LoadFromFile(@"resources\core-349.ttl");
                InMemoryDataset dataset = new InMemoryDataset(g);

                String query = @"SELECT * WHERE 
{ 
  ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?name .
  ?subject <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>* <http://example.org/unnamed#Level1_1> . 
?subject a ?type . } ";

                SparqlQuery q = new SparqlQueryParser().ParseFromString(query);
                Console.WriteLine(new SparqlFormatter().Format(q));
                Console.WriteLine(q.ToAlgebra().ToString());
                LeviathanQueryProcessor processor = new LeviathanQueryProcessor(dataset);
                SparqlResultSet         results   = processor.ProcessQuery(q) as SparqlResultSet;
                Assert.NotNull(results);

                Console.WriteLine();
                TestTools.ShowResults(results);

                Assert.Equal(2, results.Count);
            }
            finally
            {
                Options.RigorousEvaluation = false;
            }
        }
Exemplo n.º 3
0
        public void SparqlPropertyPathEvaluationCore441OneOrMorePath()
        {
            IGraph g = new Graph();

            g.LoadFromFile(@"resources\core-441\data.ttl");

            InMemoryDataset dataset = new InMemoryDataset(g);
            SparqlQuery     query   = new SparqlQueryParser().ParseFromFile(@"resources\core-441\plus-path.rq");

            Console.WriteLine(query.ToAlgebra().ToString());

            LeviathanQueryProcessor processor = new LeviathanQueryProcessor(dataset);
            Object results = processor.ProcessQuery(query);

            Assert.NotNull(results);
            TestTools.ShowResults(results);

            Assert.IsType <SparqlResultSet>(results);
            SparqlResultSet rset = (SparqlResultSet)results;

            Assert.Equal(0, rset.Count);
        }
        public void SparqlGroupByAggregateEmptyGroup2()
        {
            String query = @"PREFIX ex: <http://example.com/>
SELECT (MAX(?value) AS ?max)
WHERE {
	?x ex:p ?value
} GROUP BY ?x";

            SparqlQuery             q         = new SparqlQueryParser().ParseFromString(query);
            LeviathanQueryProcessor processor = new LeviathanQueryProcessor(new TripleStore());

            Console.WriteLine(q.ToAlgebra().ToString());

            SparqlResultSet results = processor.ProcessQuery(q) as SparqlResultSet;

            if (results == null)
            {
                Assert.True(false, "Null results");
            }

            Assert.False(results.IsEmpty, "Results should not be empty");
        }
        public void SparqlPropertyPathEvaluationCore441ZeroOrMorePath()
        {
            IGraph g = new Graph();

            g.LoadFromFile(@"resources\core-441\data.ttl");

            InMemoryDataset dataset = new InMemoryDataset(g);
            SparqlQuery     query   = new SparqlQueryParser().ParseFromFile(@"resources\core-441\star-path.rq");

            Console.WriteLine(query.ToAlgebra().ToString());

            LeviathanQueryProcessor processor = new LeviathanQueryProcessor(dataset);
            Object results = processor.ProcessQuery(query);

            Assert.NotNull(results);
            TestTools.ShowResults(results);

            Assert.IsType(typeof(SparqlResultSet), results);
            SparqlResultSet rset = (SparqlResultSet)results;

            Assert.Equal(1, rset.Count);
            Assert.Equal(g.CreateUriNode("Frame:Sheep"), rset[0]["prey"]);
        }
Exemplo n.º 6
0
        public void SparqlGroupByAggregateEmptyGroup1()
        {
            String query = @"PREFIX ex: <http://example.com/>
SELECT (MAX(?value) AS ?max)
WHERE {
	?x ex:p ?value
}";

            SparqlQuery             q         = new SparqlQueryParser().ParseFromString(query);
            LeviathanQueryProcessor processor = new LeviathanQueryProcessor(new TripleStore());

            Console.WriteLine(q.ToAlgebra().ToString());

            SparqlResultSet results = processor.ProcessQuery(q) as SparqlResultSet;

            if (results == null)
            {
                Assert.Fail("Null results");
            }

            Assert.IsFalse(results.IsEmpty, "Results should not be empty");
            Assert.AreEqual(1, results.Count, "Should be a single result");
            Assert.IsTrue(results.First().All(kvp => kvp.Value == null), "Should be no bound values");
        }