Project:SPARQL/examples: Difference between revisions

From wikifcd
Jump to navigation Jump to search
(add graph viz taxon source with ref to FCT)
Line 56: Line 56:
GROUP BY ?wbtype
GROUP BY ?wbtype
ORDER BY DESC(?pcount)
ORDER BY DESC(?pcount)
</SPARQL>
==Graph Visualization of Food Items with Stated Taxon Source Referenced to a FCT
<SPARQL>
#defaultView:Graph
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/>
SELECT ?item ?itemLabel ?taxon ("00FFFF" AS ?rgb) ?taxonLabel  WHERE {
?item wbt:P73 ?taxon;
p:P73 [prov:wasDerivedFrom  [pr:P62 ?source ]].
?source wbt:P1 wb:Q12.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
</SPARQL>
</SPARQL>

Revision as of 21:28, 14 August 2022

Food Composition Tables in WikiFCD

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX prov: <http://www.w3.org/ns/prov#>

SELECT ?item ?itemLabel WHERE {
  ?item wbt:P1 wb:Q12. 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  }

WikiFCD federated query for food items with foodOn id and NALT id

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/>
PREFIX dct: <http://purl.org/dc/terms/>

SELECT DISTINCT ?item ?itemLabel ?foodon ?nalt  WHERE {
?food wbt:P73 ?item.
?item wbt:P1 wb:Q20.
?food wbt:P309 ?foodon.
?item wbt:P61 ?wikidata.
?item rdfs:label ?itemLabel 
  SERVICE <https://query.wikidata.org/sparql> {
     ?wikidata wdt:P2004 ?nalt 
  }}

WikiFCD food items with FoodOn identifier

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>

SELECT DISTINCT ?food ?foodLabel ?foodon WHERE {
  ?food wbt:P309 ?foodon;

    rdfs:label ?foodLabel.
}

WikiFCD Count of Properties by Property Type

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>

SELECT (COUNT(?property) as ?pcount ) ?wbtype WHERE {
  ?property rdf:type               wikibase:Property.
  ?property wikibase:propertyType  ?wbtype.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?wbtype
ORDER BY DESC(?pcount)

==Graph Visualization of Food Items with Stated Taxon Source Referenced to a FCT

#defaultView:Graph
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/>

SELECT ?item ?itemLabel ?taxon ("00FFFF" AS ?rgb) ?taxonLabel   WHERE {

?item wbt:P73 ?taxon;

p:P73 [prov:wasDerivedFrom  [pr:P62 ?source ]].
?source wbt:P1 wb:Q12.

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}