mirror of
https://github.com/Babibubebon/lodc2022-culture-art.git
synced 2024-09-22 17:04:21 +09:00
add federated queries
This commit is contained in:
parent
da138f4b36
commit
3d3e673697
2 changed files with 55 additions and 7 deletions
|
@ -104,8 +104,9 @@ WHERE {
|
||||||
(URI(REPLACE(STR(?wikidataEntity), "http://wikidata.dbpedia.org/resource/", "http://www.wikidata.org/entity/"))
|
(URI(REPLACE(STR(?wikidataEntity), "http://wikidata.dbpedia.org/resource/", "http://www.wikidata.org/entity/"))
|
||||||
AS ?wikidataEntity)
|
AS ?wikidataEntity)
|
||||||
{
|
{
|
||||||
|
# 下位カテゴリを含める
|
||||||
<http://ja.dbpedia.org/resource/Category:日本ゲーム大賞受賞ソフト> ^skos:broader* ?category .
|
<http://ja.dbpedia.org/resource/Category:日本ゲーム大賞受賞ソフト> ^skos:broader* ?category .
|
||||||
?dbpediaEntity dcterms:subject ?category;
|
?dbpediaEntity dcterms:subject ?category ;
|
||||||
^owl:sameAs ?wikidataEntity .
|
^owl:sameAs ?wikidataEntity .
|
||||||
FILTER(STRSTARTS(STR(?wikidataEntity), "http://wikidata.dbpedia.org/resource/"))
|
FILTER(STRSTARTS(STR(?wikidataEntity), "http://wikidata.dbpedia.org/resource/"))
|
||||||
}
|
}
|
||||||
|
@ -129,4 +130,45 @@ federatedクエリの実行順序によっては、正しく結果が得られ
|
||||||
RDFストアによっては、クエリオプティマイザに実行順序を指示する方法が用意されており、メディア芸術データベースのSPARQLクエリサービスが使用しているAmazon Neptuneでは `hint:Query hint:joinOrder "Ordered" .` というパターンを記述します。
|
RDFストアによっては、クエリオプティマイザに実行順序を指示する方法が用意されており、メディア芸術データベースのSPARQLクエリサービスが使用しているAmazon Neptuneでは `hint:Query hint:joinOrder "Ordered" .` というパターンを記述します。
|
||||||
|
|
||||||
参照: [Amazon Neptune: SPARQL クエリヒント](https://docs.aws.amazon.com/ja_jp/neptune/latest/userguide/sparql-query-hints.html)
|
参照: [Amazon Neptune: SPARQL クエリヒント](https://docs.aws.amazon.com/ja_jp/neptune/latest/userguide/sparql-query-hints.html)
|
||||||
{{< /hint >}}
|
{{< /hint >}}
|
||||||
|
|
||||||
|
|
||||||
|
### 「タイムトラベルを題材とした作品」を取得する
|
||||||
|
DBpedia JapaneseとWikidataとメディア芸術データベースを連携したfederatedクエリ
|
||||||
|
|
||||||
|
{{< yasgui-query yasgui-id="federated" title="「タイムトラベルを題材とした作品」を取得する" endpoint="https://mediag.bunka.go.jp/sparql" >}}
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
PREFIX owl: <http://www.w3.org/2002/07/owl#>
|
||||||
|
PREFIX dcterms: <http://purl.org/dc/terms/>
|
||||||
|
PREFIX schema: <https://schema.org/>
|
||||||
|
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
||||||
|
PREFIX class: <https://mediaarts-db.bunka.go.jp/data/class#>
|
||||||
|
PREFIX ma: <https://mediaarts-db.bunka.go.jp/data/property#>
|
||||||
|
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
|
||||||
|
PREFIX hint: <http://aws.amazon.com/neptune/vocab/v01/QueryHints#>
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
?MADBID ?genre ?label
|
||||||
|
WHERE {
|
||||||
|
hint:Query hint:joinOrder "Ordered" .
|
||||||
|
# DBpedia Japanese
|
||||||
|
SERVICE <https://ja.dbpedia.org/sparql> {
|
||||||
|
SELECT DISTINCT (URI(REPLACE(STR(?wikidataEntity), "http://wikidata.dbpedia.org/resource/", "http://www.wikidata.org/entity/"))
|
||||||
|
AS ?wikidataEntity) {
|
||||||
|
<http://ja.dbpedia.org/resource/Category:タイムトラベルを題材とした作品> ^skos:broader* ?category .
|
||||||
|
?dbpediaEntity dcterms:subject ?category;
|
||||||
|
^owl:sameAs ?wikidataEntity .
|
||||||
|
FILTER(STRSTARTS(STR(?wikidataEntity), "http://wikidata.dbpedia.org/resource/"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# Wikidata
|
||||||
|
SERVICE <https://query.wikidata.org/sparql> {
|
||||||
|
?wikidataEntity wdt:P7886 ?MADBID .
|
||||||
|
}
|
||||||
|
# メディア芸術データベース
|
||||||
|
?MADBResource schema:identifier ?MADBID ;
|
||||||
|
schema:genre ?genre ;
|
||||||
|
rdfs:label ?label .
|
||||||
|
}
|
||||||
|
LIMIT 200
|
||||||
|
{{< / yasgui-query >}}
|
|
@ -283,21 +283,27 @@ LIMIT 100
|
||||||
|
|
||||||
|
|
||||||
### 登場キャラクター名がタイトルであるアニメ {#anime-character-name-title}
|
### 登場キャラクター名がタイトルであるアニメ {#anime-character-name-title}
|
||||||
|
`schema:actor` の値として以下のような形式で記述されていることを利用し、正規表現を用いて検索します。
|
||||||
|
|
||||||
|
```
|
||||||
|
【キャラクター名】キャスト名 / 【キャラクター名】キャスト名 ...
|
||||||
|
```
|
||||||
|
|
||||||
{{< yasgui-query yasgui-id="madb-lod" title="登場キャラクター名がタイトルであるアニメ" >}}
|
{{< yasgui-query yasgui-id="madb-lod" title="登場キャラクター名がタイトルであるアニメ" >}}
|
||||||
PREFIX schema: <https://schema.org/>
|
PREFIX schema: <https://schema.org/>
|
||||||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
PREFIX class: <https://mediaarts-db.bunka.go.jp/data/class#>
|
PREFIX class: <https://mediaarts-db.bunka.go.jp/data/class#>
|
||||||
SELECT
|
SELECT
|
||||||
?col ?genre ?colName ?actors
|
?series ?genre ?seriesName ?actors
|
||||||
WHERE {
|
WHERE {
|
||||||
?col a ?animeColClasses ;
|
?series a ?animeColClasses ;
|
||||||
schema:name ?colName ;
|
schema:name ?seriesName ;
|
||||||
schema:genre ?genre ;
|
schema:genre ?genre ;
|
||||||
schema:actor ?actors .
|
schema:actor ?actors .
|
||||||
VALUES ?animeColClasses {class:AnimationTVRegularSeries class:AnimationTVSpecialSeries class:AnimationMovieSeries}
|
VALUES ?animeColClasses {class:AnimationTVRegularSeries class:AnimationTVSpecialSeries class:AnimationMovieSeries}
|
||||||
FILTER(LANG(?colName) = "")
|
FILTER(LANG(?seriesName) = "")
|
||||||
FILTER(REGEX(?actors, CONCAT("【", ?colName ,"】")))
|
FILTER(REGEX(?actors, CONCAT("【", ?seriesName ,"】")))
|
||||||
}
|
}
|
||||||
{{< / yasgui-query >}}
|
{{< / yasgui-query >}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue