Ask-FashionDB / example_queries.py
traopia
queries and other fizes
e9b2c9e
# Example SPARQL queries for FashionDB
EXAMPLE_QUERIES = {
# "All fashion houses with country and city": (
# """
# PREFIX wbt: <https://fashionwiki.wikibase.cloud/prop/direct/>
# PREFIX wb: <https://fashionwiki.wikibase.cloud/entity/>
# PREFIX pq: <https://fashionwiki.wikibase.cloud/prop/qualifier/>
# PREFIX pr: <https://fashionwiki.wikibase.cloud/prop/reference/>
# PREFIX ps: <https://fashionwiki.wikibase.cloud/prop/statement/>
# PREFIX p: <https://fashionwiki.wikibase.cloud/prop/>
# SELECT ?fashion_house ?fashion_houseLabel ?countryLabel ?cityLabel WHERE {
# ?fashion_house wbt:P31 wb:Q783794; # instance of fashion house (example)
# wbt:P17 ?country. # country
# OPTIONAL { ?fashion_house wbt:P131 ?city. } # located in the administrative territorial entity
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
# }
# LIMIT 50
# """
# ),
"which designer were born in 1969": (
"PREFIX wbt: <https://fashionwiki.wikibase.cloud/prop/direct/>\nPREFIX wb: <https://fashionwiki.wikibase.cloud/entity/>\nPREFIX ps: <https://fashionwiki.wikibase.cloud/prop/statement/> \nPREFIX pq: <https://fashionwiki.wikibase.cloud/prop/qualifier/> \nPREFIX p: <https://fashionwiki.wikibase.cloud/prop/> \nPREFIX prov: <http://www.w3.org/ns/prov#> \nPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n\nSELECT ?designerLabel ?birthdate WHERE {\n ?designer wbt:P3 ?birthdate .\n FILTER (YEAR(?birthdate) = 1969)\n\n SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\". }\n}"
),
"Which designers studied at Central Saint Martins?": (
"PREFIX wbt: <https://fashionwiki.wikibase.cloud/prop/direct/>\nPREFIX wb: <https://fashionwiki.wikibase.cloud/entity/>\nPREFIX pq: <https://fashionwiki.wikibase.cloud/prop/qualifier/> \nPREFIX pr: <https://fashionwiki.wikibase.cloud/prop/reference/>\nPREFIX ps: <https://fashionwiki.wikibase.cloud/prop/statement/> \nPREFIX p: <https://fashionwiki.wikibase.cloud/prop/> \nPREFIX prov: <http://www.w3.org/ns/prov#> \n\nSELECT ?fashion_designerLabel (SAMPLE(?reference_URL) AS ?reference_URL) {\n # Restrict to designers who are instances of fashion designer (Q5)\n\n ?fashion_designer wbt:P2 wb:Q5.\n ?fashion_designer wbt:P9 ?educated_at.\n ?educated_at rdfs:label 'Central Saint Martins'@en . \n\n\n # Retrieve references from the statement\n OPTIONAL {\n ?statement prov:wasDerivedFrom ?reference.\n ?reference pr:P24 ?reference_URL.\n }\n\n # Retrieve labels for the fashion designer\n SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\". } \n} \nGROUP BY ?fashion_designerLabel \nORDER BY ?fashion_designerLabel"
),
}