I want to get entities that have a lat/long and startDate associated with them as well as the count of wikiPageWikiLink. I'm using the following query and seeing two problems:
The count isn't appearing correctly
Spurious lat/longs are appearing in the results
SELECT ?label ?subject ?lat ?long ?startDate (count(?o) as ?num) WHERE {
?subject geo:lat ?lat.
?subject geo:long ?long.
?subject rdfs:label ?label.
?subject dbo:startDate ?startDate.
?subject dbo:wikiPageWikiLink ?o
FILTER (lang(?label) = 'en')
}
GROUP BY ?label ?o ?subject ?lat ?long ?startDate ?num
LIMIT 1000
Example result with the query:
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] 32.7063 -117.162 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] 32.7063 -117.162 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] 32.7063 -117.162 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] 32.7063 -117.162 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] 32.7063 -117.162 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] -0.00170132 -1.31025e-33 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] -0.00170132 -5.90549e+15 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] -0.00170132 -4.56863e+15 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] -0.00170132 -7.06605e+14 "2015-09-17"^^xsd:date 1
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] -0.00170132 -2.34326e-17 "2015-09-17"^^xsd:date 1
Expected result:
"Asia Pop Comic Convention"#en :Asia_Pop_Comic_Convention [http] 32.7063 -117.162 "2015-09-17"^^xsd:date 10
where 10 is the number of wikiPageWikiLink associated with the entity. Please help.
Related
I'm using Apache Jena Fuseki to query my graph using SPARQL.
I need to do subquery with limit, and I found one example similar to my requirements here.
The example looks like this.
Data
#prefix : <http://people.example/> .
:alice :name "Alice", "Alice Foo", "A. Foo" .
:alice :knows :bob, :carol .
:bob :name "Bob", "Bob Bar", "B. Bar" .
:carol :name "Carol", "Carol Baz", "C. Baz" .
Query
PREFIX : <http://people.example/>
SELECT ?y ?name WHERE {
:alice :knows ?y .
{
SELECT ?y ?name WHERE {
?y :name ?name
}
ORDER BY ?name
LIMIT 1
}
}
Result
?y ?name
:bob "B. Bar"
:carol "C. Baz"
I did the same query with the same data on Fuseki, but the result is empty.
Is it problem of SPARQL implementation in Fuseki?
Which SPARQL engine can I use to get the same result as showed in the example?
Trying to figure out this PDDL problem of getting robots to clean tiles but I'm stuck with what I'm doing wrong as far as I understand, I have the movements actions and clean actions only for up and down yet it still doesnt compile. It just gives me an error that says could not parse domain file.
This is the domain:
(define (domain floor-tile)
(:requirements :typing)
;; We have two types: robots and the tiles, both are objects
(:types robot tile - object)
;; define all the predicates as they are used in the probem files
(:predicates
;; described what tile a robot is at
(robot-at ?r - robot ?x - tile)
;; indicates that tile ?x is above tile ?y
(up ?x - tile ?y - tile)
;; indicates that tile ?x is below tile ?y
(down ?x - tile ?y - tile)
;; indicates that tile ?x is right of tile ?y
(right ?x - tile ?y - tile)
;; indicates that tile ?x is left of tile ?y
(left ?x - tile ?y - tile)
;; indicates that a tile is clear (robot can move there)
(clear ?x - tile)
;; indicates that a tile is cleaned
(cleaned ?x - tile)
)
(:action clean-up
:parameters (?r - robot ?x - tile ?y - tile )
:precondition (and (up ?y ?x) (robot-at ?r ?x) (clear ?y))
:effect (and (not (clear ?y)) (cleaned ?y)
)
(:action clean-down
:parameters (?r - robot?x - tile ?y - tile)
:precondition (and (down ?y ?x) (robot-at ?r ?x) (clear ?y))
:effect (and (not (clear ?y)) (cleaned ?y)
)
(:action up
:parameters (?r - robot?x - tile ?y - tile)
:precondition (and (up ?y ?x) (robot-at ?r ?x) (clear ?y))
:effect (and (robot-at ?r ?y) (not(robot-at ?r ?x)))
)
(:action down
:parameters (?r - robot?x - tile ?y - tile)
:precondition (and (down ?y ?x) (robot-at ?r ?x)(clear ?y))
:effect (and (robot-at ?r ?y)
(not(robot-at ?r ?x)))
)
(:action right
:parameters (?r - robot?x - tile ?y - tile)
:precondition (and (right ?y ?x) (robot-at ?r ?x) (clear ?y))
:effect (and (robot-at ?r ?y)
(not(robot-at ?r ?x)))
)
(:action left
:parameters (?r - robot?x - tile ?y - tile)
:precondition (and (left ?y ?x) (robot-at ?r ?x) (clear ?y))
:effect (and (robot-at ?r ?y )
(not(robot-at ?r ?x)))
)
)
Here is the problem:
(define (problem prob001)
(:domain floor-tile)
(:objects tile_0-1 tile_0-2
tile_1-1 tile_1-2
tile_2-1 tile_2-2 - tile
robot1 - robot
)
(:init
(robot-at robot1 tile_1-1)
(clear tile_0-1)
(clear tile_0-2)
(clear tile_1-2)
(clear tile_2-1)
(clear tile_2-2)
(up tile_1-1 tile_0-1)
(up tile_1-2 tile_0-2)
(up tile_2-1 tile_1-1)
(up tile_2-2 tile_1-2)
(down tile_0-1 tile_1-1)
(down tile_0-2 tile_1-2)
(down tile_1-1 tile_2-1)
(down tile_1-2 tile_2-2)
(right tile_0-2 tile_0-1)
(right tile_1-2 tile_1-1)
(right tile_2-2 tile_2-1)
(left tile_0-1 tile_0-2)
(left tile_1-1 tile_1-2)
(left tile_2-1 tile_2-2)
)
(:goal (and
(cleaned tile_0-1)
(cleaned tile_0-2)
(cleaned tile_1-1)
(cleaned tile_2-2)
))
)
Brackets are missing on the :effect of both clean-up and clean-down. After adding those brackets, the online editor's solver indicates that the goal trivially can't be reached, but at least it parses.
I am studying SPARQL and there is this example on the documentation page:
PREFIX : <http://people.example/>
PREFIX : <http://people.example/>
SELECT ?y ?minName
WHERE {
:alice :knows ?y .
{
SELECT ?y (MIN(?name) AS ?minName)
WHERE {
?y :name ?name .
} GROUP BY ?y
}
}
From this dabase:
#prefix : <http://people.example/> .
:alice :name "Alice", "Alice Foo", "A. Foo" .
:alice :knows :bob, :carol .
:bob :name "Bob", "Bob Bar", "B. Bar" .
:carol :name "Carol", "Carol Baz", "C. Baz" .
There is says that this query:
"Return a name (the one with the lowest sort order) for all the people that know Alice and have a name."
and the output is:
y minName
:bob "B. Bar"
:carol "C. Baz"
But I can't understand how "B. Bar" is smaller than "Bob", for example. I cannot understand what the docs means with "lowest sort order".
For me the output should be:
y minName
:bob "Bob"
:carol "Carol"
Thank you for your help.
I have the following code where I get the starring for all films selected:
SELECT ?f ?starring
WHERE {
?f rdf:type dbo:Film .
?f dbo:starring ?starring
}
Is there a way where I can get films of specific starring (actor) like "Tom Hanks" for example?
Just add the DBpedia resource representing the actor, as the object of the tipple pattern:
SELECT ?f
WHERE {
?f rdf:type dbo:Film .
?f dbo:starring dbr:Tom_Hanks .
}
I created this request but does not show the results that can concater with the given name familyName it just displays the givenName and then another line, attorneys in the familyName.
i used jena 3.0 .
why does not work?
PREFIX apf: <http://jena.hpl.hp.com/ARQ/property#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
{?Person foaf:givenName ?x .
?Person foaf:familyName ?y .
?name apf:concat (?x " " ?y) }