MatVoc:SPARQL
Jump to navigation
Jump to search
語彙はSPARQLでクエリできます。 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
別名一覧をタブ区切りで返す
skos:altLabel が存在する項目について、日・英の rdfs:label と、すべての skos:altLabel をタブ区切りにして返す。
SELECT ?synonyms
WHERE {
{
SELECT ?item (GROUP_CONCAT (DISTINCT ?label ; separator = "\t") AS ?labels)
WHERE {
?item rdfs:label ?label .
}
GROUP BY ?item
}
{
SELECT ?item (GROUP_CONCAT (DISTINCT ?altLabel ; separator = "\t") AS ?altLabels)
WHERE {
?item skos:altLabel ?altLabel.
}
GROUP BY ?item
}
BIND(CONCAT(?labels,"\t",?altLabels) as ?synonyms).
}
英日どちらかのラベルが欠けている項目
# only one of enlabel or jalabel 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") } )
}
UNION
{
?item rdfs:label ?enlabel FILTER (LANG(?enlabel) = "en") .
FILTER(NOT EXISTS {?item rdfs:label ?jalabel FILTER(LANG(?jalabel) = "ja") } )
}
}
ORDER BY ?item
文がひとつもない項目 Items without any statements
SELECT *
WHERE {
?item wikibase:statements 0 .
}
辞書ごとの項目数集計
SELECT * WHERE {
VALUES ?top { wd:Q21 wd:Q713 wd:Q1863 wd:Q1864 wd:Q1881 wd:Q1882 wd:Q1883 wd:Q1907 }
?top rdfs:label ?label .
FILTER (LANG(?label)="ja")
{
SELECT ?top (COUNT(?child) AS ?childcount) WHERE {
?child wdt:P8+ ?top .
} GROUP BY ?top
}
} ORDER BY DESC(?childcount)
グラフ表示
#defaultView:Graph
SELECT ?categ ?categLabel ?item ?itemLabel WHERE {
?categ wdt:P8 wd:Q21 .
?item wdt:P8 ?categ .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
How to add examples
このページにクエリ文を追加したい場合、下記の命令に挟んで書くと、色付き・お試しリンク付きで表示されます。
{{SPARQL | query = (insert your query here) }}