Difference between revisions of "MatVoc:SPARQL"

From matvoc.nims.go.jp
Jump to navigation Jump to search
Line 1: Line 1:
 
This vocabulary can be queried by SPARQL at [{{SERVER}}/query the query service].  
 
This vocabulary can be queried by SPARQL at [{{SERVER}}/query the query service].  
 +
 +
See [[/batch]] for the queries designed for the batch export system.
  
 
== Examples ==
 
== Examples ==
Line 10: Line 12:
 
}
 
}
 
ORDER BY ?enlabel
 
ORDER BY ?enlabel
}}
 
 
== Implemented in the batch system ==
 
 
=== Query 01: 語彙定義 ===
 
{{SPARQL | query = # DPFC vocabulary delivery query 01 version 2019-08-21
 
SELECT ?linetype ?itemid ?dictid ?item ?enlabel ?jalabel ?datemodified
 
WHERE {
 
  VALUES ?urlbase  {"http://voctest.nims.go.jp/entity/"}
 
  VALUES ?linetype {"01"}
 
 
 
  # Labels
 
  OPTIONAL {?item rdfs:label ?enlabel FILTER (LANG(?enlabel) = "en") .}
 
  OPTIONAL {?item rdfs:label ?jalabel FILTER (LANG(?jalabel) = "ja") .}
 
 
 
  # Belongs to which dictionary
 
  OPTIONAL {?item wdt:P11 ?dict.}
 
 
 
  # Last modified timestamp
 
  ?item schema:dateModified ?datemodified .
 
 
 
  # Exclude properties
 
  FILTER NOT EXISTS {?item rdf:type <http://wikiba.se/ontology#Property>}
 
 
  # Post-process
 
  BIND (STRAFTER (STR(?item), ?urlbase) AS ?itemid)
 
  BIND (STRAFTER (STR(?dict), ?urlbase) AS ?dictid) 
 
 
 
  # Fallback to preset string if no dictionary is defined?
 
  # BIND (IF (BOUND(?dict), STRAFTER (STR(?dict), ?urlbase), "common") AS ?dictid)
 
 
 
  # Wikibase Label Service not used for now
 
  # SERVICE wikibase:label { bd:serviceParam wikibase:language "en,ja" . } 
 
}
 
ORDER BY ?itemid
 
 
}}
 
}}

Revision as of 08:12, 21 November 2019

This vocabulary can be queried by SPARQL at the query service.

See /batch for the queries designed for the batch export system.

Examples

# Sample query: Narrower concepts of `material types` where both enlabel and jalabel exist
SELECT ?item ?enlabel ?jalabel
WHERE {
  ?item wdt:P8 wd:Q26.
  ?item rdfs:label ?enlabel FILTER (LANG(?enlabel) = "en") .
  ?item rdfs:label ?jalabel FILTER (LANG(?jalabel) = "ja") .
}
ORDER BY ?enlabel

▶️ Try it!