Skip to content

Latest commit

 

History

History
83 lines (69 loc) · 4.81 KB

SPARQLsample.md

File metadata and controls

83 lines (69 loc) · 4.81 KB

Japanese

Example Queries

Example SPARQL queries for the knowledge graphs of the Knowledge Graph Reasoning Challenge.

SPARQL endpoint is http://kg.hozo.jp/fuseki/kgrc2020v2/sparql

Get hasPredicate (predicate representing the content of the scene) for scene 36 of "Speckled Band."

select ?o
from <http://kgc.knowledge-graph.jp/data/SpeckledBand>
where
{<http://kgc.knowledge-graph.jp/data/SpeckledBand/36> <http://kgc.knowledge-graph.jp/ontology/kgc.owl#hasPredicate> ?o .}

View the results

Get the contents (triple list) of the specified scene (e.g., scene 36 of "Speckled Band")

select ?p ?o
from <http://kgc.knowledge-graph.jp/data/SpeckledBand>
where
{<http://kgc.knowledge-graph.jp/data/SpeckledBand/36> ?p ?o .}

View the results

Get a list of scenes

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX kgc: <http://kgc.knowledge-graph.jp/ontology/kgc.owl#>

SELECT ?s 
FROM <http://kgc.knowledge-graph.jp/data/SpeckledBand>
WHERE{
?s rdf:type kgc:Situation .
}

View the results

This SPARQL endpoint contains data for eight novels, so if you want to retrieve data only for a specific novel, specify the graph IRI of the novel to be retrieved as in FROM <>.

Get a list of scenes (search target is limited to "The Dancing Men")

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX kgc: <http://kgc.knowledge-graph.jp/ontology/kgc.owl#>

SELECT ?s 
FROM <http://kgc.knowledge-graph.jp/data/DancingMen>
WHERE{
?s rdf:type kgc:Situation .
}

View the results

Get a list of scenes that satisfy the conditions.

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX kgc: <http://kgc.knowledge-graph.jp/ontology/kgc.owl#>

SELECT ?s ?sc
WHERE{
?s kgc:subject	<http://kgc.knowledge-graph.jp/data/DancingMen/Qubit> ;
   kgc:source  ?sc.
FILTER(lang(?sc)="ja")
}

View the results

Get connections between scenes

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX kgc: <http://kgc.knowledge-graph.jp/ontology/kgc.owl#>
PREFIX dm: <http://kgc.knowledge-graph.jp/data/DancingMen/>

SELECT ?s ?p ?o
FROM <http://kgc.knowledge-graph.jp/data/DancingMen>
WHERE{
?s ?p ?o.
?s rdf:type kgc:Situation .
?o rdf:type kgc:Situation .
}

View the results