MatVoc:SPARQL

From matvoc.nims.go.jp
Revision as of 08:10, 21 November 2019 by MediaWiki default (talk | contribs)
Jump to navigation Jump to search

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

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!

Implemented in the batch system

Query 01: 語彙定義

# 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

▶️ Try it!