SPARQLAsk
更多信息和选项
- SPARQLAsk can be used in SPARQLExecute to query a SPARQL endpoint.
- The result of executing SPARQLAsk[pattern] is True if there is a subgraph matching pattern, and False otherwise.
- In SPARQLAsk[pattern], pattern can take the same form as in SPARQLSelect[pattern].
范例
打开所有单元 关闭所有单元基本范例 (1)
Needs["GraphStore`"]schema[s_] := URL["http://schema.org/" <> s];
ex[s_] := URL["http://example.org/" <> s];fruitGraph = RDFStore[{
RDFTriple[ex["banana"], schema["color"], "yellow"],
RDFTriple[ex["strawberry"], schema["color"], "red"],
RDFTriple[ex["strawberry"], ex["shape"], ex["round"]]
}];Check whether there is a fruit that is both red and rectangular:
fruitGraph//SPARQLAsk[{
RDFTriple[SPARQLVariable["fruit"], schema["color"], "red"],
RDFTriple[SPARQLVariable["fruit"], ex["shape"], ex["rectangular"]]
}]fruitGraph//SPARQLAsk[{
RDFTriple[SPARQLVariable["fruit"], schema["color"], "red"],
RDFTriple[SPARQLVariable["fruit"], ex["shape"], ex["round"]]
}]Scope (1)
Needs["GraphStore`"]Ask Wikidata whether there is a human (Q5) with German label "Albert Einstein":
rdfs[s_] := URL["http://www.w3.org/2000/01/rdf-schema#" <> s];
wd[s_] := URL["http://www.wikidata.org/entity/" <> s];
wdt[s_] := URL["http://www.wikidata.org/prop/direct/" <> s];SPARQLExecute[
"https://query.wikidata.org/sparql",
SPARQLAsk[{
RDFTriple[SPARQLVariable["human"], wdt["P31"], wd["Q5"]],
RDFTriple[SPARQLVariable["human"], rdfs["label"], RDFString["Albert Einstein", "de"]]
}]
]文本
Wolfram Research (2019),SPARQLAsk,Wolfram 语言函数,https://reference.wolfram.com/language/GraphStore/ref/SPARQLAsk.html.
CMS
Wolfram 语言. 2019. "SPARQLAsk." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/GraphStore/ref/SPARQLAsk.html.
APA
Wolfram 语言. (2019). SPARQLAsk. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/GraphStore/ref/SPARQLAsk.html 年
BibTeX
@misc{reference.wolfram_2026_sparqlask, author="Wolfram Research", title="{SPARQLAsk}", year="2019", howpublished="\url{https://reference.wolfram.com/language/GraphStore/ref/SPARQLAsk.html}", note=[Accessed: 17-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_sparqlask, organization={Wolfram Research}, title={SPARQLAsk}, year={2019}, url={https://reference.wolfram.com/language/GraphStore/ref/SPARQLAsk.html}, note=[Accessed: 17-August-2026]}