query-46211ba196951c895cdb7e53ecd35eb0
Defining Formulas
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
select
?quantity
(sample(?label) as ?label)
(sample(?desc) as ?desc)
(
strdt(
concat(
"<", "math><mtable columnalign=left rowlines=dashed>",
group_concat(distinct ?formula),
"</mtable></math>"
),
<http://www.w3.org/1998/Math/MathML>
) as ?formulas
)
(
strdt(
concat(
"<", "math><mtable columnalign=left>",
group_concat(distinct ?symbolAndLabel),
"</mtable></math>"
),
<http://www.w3.org/1998/Math/MathML>
) as ?formulaSymbols
)
where {
?quantity wdt:P279+ wd:Q71550118 .
optional { ?quantity rdfs:label ?label . filter (lang(?label) = "de") }
optional { ?quantity schema:description ?desc . filter (lang(?desc) = "de") }
?quantity wdt:P2534 ?formula .
{
select distinct * where {
?quantity p:P7235 [ ps:P7235 ?formulaSymbol ; pq:P9758 ?formulaQuantity ] .
optional { ?formulaQuantity rdfs:label ?formulaQuantityLabel . filter (lang(?formulaQuantityLabel) = "de") }
bind (
concat(
"<mrow>",
str(?formulaSymbol),
"<mtext href="", str(?formulaQuantity), "">",
": ",
coalesce(?formulaQuantityLabel, strafter(str(?formulaQuantity), "http://www.wikidata.org/entity/")),
"</mtext>",
"</mrow>"
) as ?symbolAndLabel
)
}
}
} group by ?quantity