Wikipedia API 和 SPARQL 在单个查询中 [英] Wikipedia API and SPARQL in a single query
问题描述
我需要搜索在全文中包含某些特定词的维基百科页面.为了改善结果,我想将结果限制为描述实体的页面,这些实体是特定实体的实例.
为了搜索全文,我可以使用 Wikipedia API,使用查询操作和搜索生成器.
对于给定实体的过滤实例,我可以使用 Wikidata API 和 SPARQL 查询.
有没有办法在同时应用两个过滤器的单个查询中执行这两个操作?
自 2017 年 6 月以来,可能从维基数据 SPARQL 调用维基媒体 API:
SELECT ?wikidata_item ?wikipedia_title {服务维基库:mwapi {bd:serviceParam wikibase:endpoint "en.wikipedia.org" .bd:serviceParam wikibase:api "Generator" .bd:serviceParam mwapi:generator "search" .bd:serviceParam mwapi:gsrsearch "triplestore" .bd:serviceParam mwapi:gsrlimit "max" .?wikidata_item wikibase:apiOutputItem mwapi:item .?wikipedia_title wikibase:apiOutput mwapi:title .}# 提示:先前提示:运行第一真".?wikidata_item wdt:P31 wd:Q3539533.过滤器 (?wikipedia_title != "Blazegraph")}
试试吧!>
I need to search for Wikipedia pages that contain some specific words in their full text. To improve the results I want to limit the results to pages describing entities that are instances of a specific entity.
For searching the full text I can use the Wikipedia APIs, using the query action and the search generator.
For filtering instances of a given entity I can use the Wikidata APIs and a SPARQL query.
Is there a way to execute both operations in a single query that applies both filters?
Since June 2017, it is possible to call out to Wikimedia APIs from Wikidata SPARQL:
SELECT ?wikidata_item ?wikipedia_title {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "en.wikipedia.org" .
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam mwapi:generator "search" .
bd:serviceParam mwapi:gsrsearch "triplestore" .
bd:serviceParam mwapi:gsrlimit "max" .
?wikidata_item wikibase:apiOutputItem mwapi:item .
?wikipedia_title wikibase:apiOutput mwapi:title .
}
# hint:Prior hint:runFirst "true".
?wikidata_item wdt:P31 wd:Q3539533 .
FILTER (?wikipedia_title != "Blazegraph")
}
这篇关于Wikipedia API 和 SPARQL 在单个查询中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!