SPARQLConstruct
更多信息和选项
- SPARQLConstruct can be used in SPARQLExecute to query a SPARQL endpoint.
- The result of executing SPARQLConstruct[patterntemplate] is a RDFStore object containing for each solution the triples of template where variables have been replaced with values of this solution.
- In SPARQLConstruct[pattern], pattern can take the same form as in SPARQLSelect[pattern].
范例
打开所有单元 关闭所有单元基本范例 (1)
Needs["GraphStore`"]Specify a graph of first and family names:
foaf[s_] := URL["http://xmlns.com/foaf/0.1/" <> s];
ex[s_] := URL["http://example.org/" <> s];peopleGraph = RDFStore[{
RDFTriple[ex["tom"], foaf["firstName"], "Tom"],
RDFTriple[ex["tom"], foaf["familyName"], "Smith"],
RDFTriple[ex["alice"], foaf["firstName"], "Alice"],
RDFTriple[ex["alice"], foaf["familyName"], "Meier"]
}];Construct a graph with only the family names:
peopleGraph//SPARQLConstruct[RDFTriple[SPARQLVariable["person"], foaf["firstName"], SPARQLVariable["first"]]]Scope (1)
Needs["GraphStore`"]Retrieve a graph of cats and their names from Wikidata:
rdfs[s_] := URL["http://www.w3.org/2000/01/rdf-schema#" <> s];
wikibase[s_] := URL["http://wikiba.se/ontology#" <> s];
bd[s_] := URL["http://www.bigdata.com/rdf#" <> 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",
SPARQLConstruct[{
RDFTriple[SPARQLVariable["item"], wdt["P31"], wd["Q146"]],
SPARQLService[wikibase["label"], RDFTriple[bd["serviceParam"], wikibase["language"], "en"]]
} -> RDFTriple[SPARQLVariable["item"], rdfs["label"], SPARQLVariable["itemLabel"]]
]
]文本
Wolfram Research (2019),SPARQLConstruct,Wolfram 语言函数,https://reference.wolfram.com/language/GraphStore/ref/SPARQLConstruct.html.
CMS
Wolfram 语言. 2019. "SPARQLConstruct." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/GraphStore/ref/SPARQLConstruct.html.
APA
Wolfram 语言. (2019). SPARQLConstruct. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/GraphStore/ref/SPARQLConstruct.html 年
BibTeX
@misc{reference.wolfram_2026_sparqlconstruct, author="Wolfram Research", title="{SPARQLConstruct}", year="2019", howpublished="\url{https://reference.wolfram.com/language/GraphStore/ref/SPARQLConstruct.html}", note=[Accessed: 10-July-2026]}
BibLaTeX
@online{reference.wolfram_2026_sparqlconstruct, organization={Wolfram Research}, title={SPARQLConstruct}, year={2019}, url={https://reference.wolfram.com/language/GraphStore/ref/SPARQLConstruct.html}, note=[Accessed: 10-July-2026]}