Difference between revisions of "MatVoc:SPARQL"

From matvoc.nims.go.jp
Jump to navigation Jump to search
Line 4: Line 4:
  
 
== Examples ==
 
== Examples ==
 +
=== 英日両方のラベルが存在する物質タイプ ===
 
{{SPARQL | query = # Sample query: Narrower concepts of `material types` where both enlabel and jalabel exist
 
{{SPARQL | query = # Sample query: Narrower concepts of `material types` where both enlabel and jalabel exist
 
SELECT ?item ?enlabel ?jalabel
 
SELECT ?item ?enlabel ?jalabel
Line 10: Line 11:
 
   ?item rdfs:label ?enlabel FILTER (LANG(?enlabel) = "en") .
 
   ?item rdfs:label ?enlabel FILTER (LANG(?enlabel) = "en") .
 
   ?item rdfs:label ?jalabel FILTER (LANG(?jalabel) = "ja") .
 
   ?item rdfs:label ?jalabel FILTER (LANG(?jalabel) = "ja") .
 +
}
 +
ORDER BY ?enlabel
 +
}}
 +
 +
=== 日本語ラベルは存在するが英語のラベルが入力されていないものすべて ===
 +
{{SPARQL | query =
 +
# enlabel exists but jalabel not exists
 +
SELECT ?item ?enlabel ?jalabel
 +
WHERE
 +
{
 +
  ?item rdfs:label ?jalabel FILTER (LANG(?jalabel) = "ja") .
 +
  FILTER(NOT EXISTS {
 +
    ?item rdfs:label ?enlabel FILTER(LANG(?enlabel) = "en")
 +
  } )
 
}
 
}
 
ORDER BY ?enlabel
 
ORDER BY ?enlabel
 
}}
 
}}

Revision as of 06:07, 22 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!

日本語ラベルは存在するが英語のラベルが入力されていないものすべて

# enlabel exists but jalabel not exists
SELECT ?item ?enlabel ?jalabel
WHERE 
{
  ?item rdfs:label ?jalabel FILTER (LANG(?jalabel) = "ja") .
  FILTER(NOT EXISTS {
    ?item rdfs:label ?enlabel FILTER(LANG(?enlabel) = "en") 
  } )
}
ORDER BY ?enlabel

▶️ Try it!