Spaces:
Sleeping
Sleeping
| import sys | |
| import os | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from src.sparql_query_wikibase import * | |
| fashion_collection_images_question = "Images of collections produced by Chanel" | |
| fashion_collection_images_query = """ | |
| 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?statement ?fashion_collectionLabel ?image_url ?reference_URL | |
| ?fashion_seasonLabel (YEAR(?fashion_year) AS ?year) ?categoryLabel WHERE { | |
| { ?fashion_house rdfs:label "Chanel"@en.} # Match label | |
| UNION | |
| { ?fashion_house skos:altLabel "Chanel"@en. } # Match alias | |
| ?fashion_house p:P31 ?statement. | |
| ?statement ps:P31 ?fashion_collection. | |
| OPTIONAL { ?fashion_collection wbt:P32 ?fashion_season. } | |
| OPTIONAL {?fashion_collection wbt:P28 ?fashion_year.} | |
| OPTIONAL {?fashion_collection wbt:P38 ?category.} | |
| OPTIONAL { | |
| ?statement pq:P35 ?image_url. | |
| } | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| } | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } | |
| """ | |
| year_designers_birth_question = "Which designers were born in 1963?" | |
| year_designers_birth_query = """ | |
| PREFIX wbt: <https://fashionwiki.wikibase.cloud/prop/direct/> | |
| PREFIX wb: <https://fashionwiki.wikibase.cloud/entity/> | |
| PREFIX ps: <https://fashionwiki.wikibase.cloud/prop/statement/> | |
| PREFIX pq: <https://fashionwiki.wikibase.cloud/prop/qualifier/> | |
| PREFIX p: <https://fashionwiki.wikibase.cloud/prop/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | |
| SELECT ?designerLabel ?birthdate WHERE { | |
| ?designer wbt:P3 ?birthdate . | |
| FILTER (YEAR(?birthdate) = 1963) | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } """ | |
| fashion_house_directors_question = "Which designers have been creative directors of Chanel ?" | |
| fashion_house_directors_query = """ | |
| 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT | |
| ?creative_directorLabel (COALESCE(YEAR(?start_time), YEAR(?point_time), YEAR(?inception)) AS ?start_year) | |
| (YEAR(?end_time) AS ?end_year) ?title ?statement ?reference_URL_source | |
| WHERE { | |
| # Fashion house identified by brand name | |
| ?fashion_house wbt:P2 wb:Q1. | |
| { ?fashion_house rdfs:label "Chanel"@en.} # Match label | |
| UNION | |
| { ?fashion_house skos:altLabel "Chanel"@en. } # Match alias | |
| # Link through designer employed (P29) property for the fashion house - the property for designer employment is P10 | |
| { | |
| ?fashion_house p:P29 ?statement. | |
| ?statement ps:P29 ?creative_director. | |
| # Optional qualifiers for P29 regarding the time frame | |
| OPTIONAL { ?statement pq:P15 ?start_time. } | |
| OPTIONAL { ?statement pq:P28 ?point_time. } | |
| OPTIONAL { ?statement pq:P16 ?end_time. } | |
| OPTIONAL { ?statement pq:P25 ?title. } | |
| OPTIONAL { ?fashion_house wbt:P11 ?inception. } | |
| # Retrieve references for P29 | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| BIND( | |
| IF(CONTAINS(STR(?reference_URL), "ollama") || CONTAINS(STR(?reference_URL), "gpt"), ?reference_URL, "") AS ?reference_URL_model | |
| ) | |
| BIND( | |
| IF(!(CONTAINS(STR(?reference_URL), "ollama") || CONTAINS(STR(?reference_URL), "gpt")), ?reference_URL, "") AS ?reference_URL_source | |
| ) | |
| } | |
| } | |
| UNION | |
| # Link through founded_by (P14) property for the fashion house | |
| { | |
| ?fashion_house p:P14 ?statement. | |
| ?statement ps:P14 ?creative_director. | |
| # Optional qualifiers for P14 (start_year as inception) | |
| OPTIONAL { ?statement pq:P15 ?start_time. } | |
| OPTIONAL { ?statement pq:P28 ?point_time. } | |
| OPTIONAL { ?statement pq:P16 ?end_time. } | |
| OPTIONAL { ?statement pq:P25 ?title. } | |
| # Retrieve references for P14 | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| BIND( | |
| IF(CONTAINS(STR(?reference_URL), "ollama") || CONTAINS(STR(?reference_URL), "gpt"), ?reference_URL, "") AS ?reference_URL_model | |
| ) | |
| BIND( | |
| IF(!(CONTAINS(STR(?reference_URL), "ollama") || CONTAINS(STR(?reference_URL), "gpt")), ?reference_URL, "") AS ?reference_URL_source | |
| ) | |
| } | |
| } | |
| # Filter for relevant titles (creative director, founder, etc.) to retrieve relevant employment as creative director | |
| FILTER ( | |
| REGEX(?title, "director", "i") || | |
| REGEX(?title, "head designer", "i") || | |
| REGEX(?title, "chief", "i") || | |
| REGEX(?title, "founder", "i") | |
| ) | |
| FILTER(?reference_URL_source != "") | |
| # Retrieve labels | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } ORDER BY ?start_year """ | |
| designer_fashion_house_directors_question = "In which fashion house did Alessandro Michele work as a creative director?" | |
| designer_fashion_house_directors_query = """ | |
| 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?fashion_houseLabel | |
| (COALESCE(YEAR(?start_time), YEAR(?point_time), YEAR(?inception)) AS ?start_year) | |
| (YEAR(?end_time) AS ?end_year) | |
| ?title ?reference_URL_source ?statement | |
| WHERE { | |
| # Designer linked to fashion house through roles or founded_by | |
| ?fashion_designer wbt:P2 wb:Q5. | |
| { ?fashion_designer rdfs:label "Alessandro Michele"@en.} # Match label | |
| UNION | |
| { ?fashion_designer skos:altLabel "Alessandro Michele"@en. } # Match alias | |
| # Link through employer (P10) | |
| ?fashion_designer p:P10 ?statement. | |
| ?statement ps:P10 ?fashion_house. | |
| # Optional start and end time qualifiers for roles | |
| OPTIONAL { ?statement pq:P15 ?start_time. } | |
| OPTIONAL { ?statement pq:P28 ?point_time. } | |
| OPTIONAL { ?statement pq:P16 ?end_time. } | |
| OPTIONAL { ?statement pq:P25 ?title. } | |
| # Inception as fallback for start year | |
| OPTIONAL { ?fashion_house wbt:P11 ?inception. } | |
| # Filter for relevant roles (director, founder, etc.) | |
| FILTER ( | |
| REGEX(?title, "director", "i") || | |
| REGEX(?title, "head designer", "i") || | |
| REGEX(?title, "chief","i") || | |
| REGEX(?title, "founder","i") | |
| ) | |
| # Retrieve references for the statement | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| BIND( | |
| IF(CONTAINS(STR(?reference_URL), "ollama") || CONTAINS(STR(?reference_URL), "gpt"), ?reference_URL, "") AS ?reference_URL_model | |
| ) | |
| BIND( | |
| IF(!(CONTAINS(STR(?reference_URL), "ollama") || CONTAINS(STR(?reference_URL), "gpt")), ?reference_URL, "") AS ?reference_URL_source | |
| ) | |
| } | |
| FILTER(?reference_URL_source != "") | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } | |
| """ | |
| designer_fashion_director_question2 = "In which fashion house did Alessandro Michele work as a creative director?" | |
| designer_fashion_director_query2 = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT | |
| ?fashion_houseLabel ?creative_directorLabel (COALESCE(YEAR(?start_time), YEAR(?point_time), YEAR(?inception)) AS ?start_year) (YEAR(?end_time) AS ?end_year) ?title ?statement ?reference_URL_source | |
| WHERE { | |
| # Fashion designer identified by name | |
| ?creative_director wbt:P2 wb:Q5. | |
| { ?creative_director rdfs:label "Alessandro Michele"@en.} # Match label | |
| UNION | |
| { ?creative_director skos:altLabel "Alessandro Michele"@en. } # Match alias | |
| # Link through designer employed (P29) property for the fashion house - the property for designer employment is P30 | |
| { | |
| ?fashion_house p:P29 ?statement. | |
| ?statement ps:P29 ?creative_director. | |
| # Optional qualifiers for P29 regarding the time frame | |
| OPTIONAL { ?statement pq:P15 ?start_time. } | |
| OPTIONAL { ?statement pq:P28 ?point_time. } | |
| OPTIONAL { ?statement pq:P16 ?end_time. } | |
| OPTIONAL { ?statement pq:P25 ?title. } | |
| OPTIONAL { ?fashion_house wbt:P11 ?inception. } | |
| # Retrieve references for P29 | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| BIND( | |
| IF(CONTAINS(STR(?reference_URL), "ollama") || CONTAINS(STR(?reference_URL), "gpt"), ?reference_URL, "") AS ?reference_URL_model | |
| ) | |
| BIND( | |
| IF(!(CONTAINS(STR(?reference_URL), "ollama") || CONTAINS(STR(?reference_URL), "gpt")), ?reference_URL, "") AS ?reference_URL_source | |
| ) | |
| } | |
| } | |
| FILTER ( | |
| REGEX(?title, "director", "i") || | |
| REGEX(?title, "head designer", "i") || | |
| REGEX(?title, "chief", "i") || | |
| REGEX(?title, "founder", "i") | |
| ) | |
| FILTER(?reference_URL_source != "") | |
| # Retrieve labels | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } ORDER BY ?start_year """ | |
| country_designer_question = "Which designers are from Italy ?" | |
| country_designer_query = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?fashion_designerLabel (SAMPLE(?statement) AS ?statement) | |
| (SAMPLE(?reference_URL) AS ?reference_URL) WHERE { | |
| # Restrict to designers who are instances of fashion designer (Q5) | |
| ?fashion_designer wbt:P2 wb:Q5. | |
| # Access the statement for the country relationship | |
| ?fashion_designer p:P6 ?statement. | |
| ?statement ps:P6 ?country. | |
| { ?country rdfs:label "Italy"@en.} # Match label | |
| UNION | |
| { ?country skos:altLabel "Italy"@en. } # Match alias | |
| # Retrieve references from the statement | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| } | |
| # Retrieve labels for the fashion designer | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } | |
| GROUP BY ?fashion_designerLabel | |
| ORDER BY ?fashion_designerLabel """ | |
| country_designer_query = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?fashion_designerLabel (SAMPLE(?reference_URL) AS ?reference_URL) { | |
| # Restrict to designers who are instances of fashion designer (Q5) | |
| ?fashion_designer wbt:P2 wb:Q5. | |
| ?fashion_designer wbt:P6 ?country. | |
| ?fashion_designer p:P6 ?statement. | |
| { ?country rdfs:label "Italy"@en.} # Match label | |
| UNION | |
| { ?country skos:altLabel "Italy"@en. } # Match alias | |
| # Retrieve references from the statement | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| } | |
| # Retrieve labels for the fashion designer | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } | |
| GROUP BY ?fashion_designerLabel | |
| ORDER BY ?fashion_designerLabel """ | |
| designer_order_fashion_collection_question = "Which fashion collections did Alessandro Michele work on?" | |
| designer_order_fashion_collection_query = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?fashion_houseLabel | |
| (COALESCE(YEAR(?start_time), YEAR(?point_time), YEAR(?inception)) AS ?start_year) | |
| (YEAR(?end_time) AS ?end_year) | |
| ?title ?reference_URL_source ?statement ?fashion_collectionLabel ?image_url | |
| (YEAR(?fashion_year) as ?year ) ?fashion_seasonLabel ?categoryLabel WHERE { | |
| # Designer linked to fashion house through roles or founded_by | |
| ?fashion_designer wbt:P2 wb:Q5. | |
| { ?fashion_designer rdfs:label "Alessandro Michele"@en.} # Match label | |
| UNION | |
| { ?fashion_designer skos:altLabel "Alessandro Michele"@en. } # Match alias | |
| # Link through "creative director" or other roles | |
| ?fashion_designer p:P10 ?statement_designer. | |
| ?statement_designer ps:P10 ?fashion_house. | |
| OPTIONAL { ?statement_designer pq:P15 ?start_time. } | |
| OPTIONAL { ?statement_designer pq:P28 ?point_time. } | |
| OPTIONAL { ?statement_designer pq:P16 ?end_time. } | |
| OPTIONAL { ?statement_designer pq:P25 ?title. } | |
| OPTIONAL { ?fashion_house wbt:P11 ?inception. } | |
| FILTER ( | |
| REGEX(?title, "director", "i") || | |
| REGEX(?title, "head designer", "i") || | |
| REGEX(?title, "chief","i") || | |
| REGEX(?title, "founder","i") | |
| ) | |
| ?fashion_house p:P31 ?statement. | |
| ?statement ps:P31 ?fashion_collection. | |
| OPTIONAL {?fashion_collection wbt:P28 ?fashion_year.} | |
| OPTIONAL { ?fashion_collection wbt:P32 ?fashion_season. } | |
| OPTIONAL {?fashion_collection wbt:P38 ?category.} | |
| OPTIONAL {?statement pq:P35 ?image_url.} | |
| OPTIONAL {?statement pq:P37 ?fashion_date.} | |
| # Use the adjusted fashion year in the FILTER condition | |
| FILTER( | |
| (YEAR(?start_time) <= YEAR(?fashion_year) && (!BOUND(?end_time) || YEAR(?end_time) >= YEAR(?fashion_year))) || | |
| (YEAR(?point_time) <= YEAR(?fashion_year)) || | |
| (REGEX(?title, "founder", "i") && YEAR(?inception) <= YEAR(?fashion_year)) | |
| ) | |
| # Retrieve references for the statement | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL_source. | |
| } | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } ORDER BY ?year """ | |
| education_most_popular_question = "What are the most popular educational institutions for fashion designers?" | |
| education_most_popular_query = """ 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?schoolLabel (COUNT(?fashion_designer) AS ?designer_count) WHERE { | |
| # Retrieve all fashion designers and their schools | |
| ?fashion_designer wbt:P9 ?school. | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } | |
| GROUP BY ?schoolLabel | |
| ORDER BY DESC(?designer_count) """ | |
| brands_founded_question = Template("Which fashion houses were founded in $x") | |
| brands_founded_query = Template(""" PREFIX wbt: <https://fashionwiki.wikibase.cloud/prop/direct/> | |
| PREFIX wb: <https://fashionwiki.wikibase.cloud/entity/> | |
| PREFIX p: <https://fashionwiki.wikibase.cloud/prop/> | |
| SELECT ?fashion_houseLabel ?inception | |
| WHERE { | |
| ?fashion_house wbt:P2 wb:Q1. | |
| ?fashion_house wbt:P11 ?inception. | |
| FILTER(YEAR(?inception) = $x) | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| }""") | |
| how_many_directors_per_fashion_house_question = "How many designers have worked for each fashion house as creative directors?" | |
| how_many_directors_per_fashion_house_query = """ 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?fashion_houseLabel (COUNT(DISTINCT ?fashion_designer) AS ?creative_director_count) WHERE { | |
| # Match fashion houses linked to designers via employer property | |
| ?fashion_designer p:P10 ?statement. | |
| ?statement ps:P10 ?fashion_house. | |
| # Filter for roles related to creative direction | |
| OPTIONAL { ?statement pq:P25 ?title. } | |
| FILTER ( | |
| REGEX(?title, "creative director", "i") || | |
| REGEX(?title, "head designer", "i") || | |
| REGEX(?title, "chief", "i") || | |
| REGEX(?title, "founder", "i") | |
| ) | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } | |
| GROUP BY ?fashion_houseLabel | |
| ORDER BY DESC(?creative_director_count) | |
| """ | |
| how_many_designers_per_fashion_house_question = "How many designers have worked for each fashion house?" | |
| how_many_designers_per_fashion_house_query = """ 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?fashion_houseLabel (COUNT(?designer) AS ?designer_count) WHERE { | |
| ?fashion_house wbt:P29 ?designer . | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } | |
| GROUP BY ?fashion_houseLabel | |
| ORDER BY DESC(?designer_count) """ | |
| designers_multiple_houses_question = "Which designers have worked for more than one fashion house?" | |
| designers_multiple_houses_query = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?designerLabel WHERE { | |
| ?designer wbt:P10 ?house . | |
| ?designer wbt:P10 ?anotherHouse . | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language 'en'. } | |
| } | |
| GROUP BY ?designerLabel | |
| HAVING (COUNT(?house) > 1)""" | |
| award_question = "Which designers won which awards?" | |
| award_query = """ 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?designerLabel ?awardLabel WHERE { | |
| ?designer wbt:P18 ?award . | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| }""" | |
| fashion_houses_with_collections_question ="Which distinct fashion houses have at least a fashion collection?" | |
| fashion_houses_with_collections_query = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT DISTINCT ?houseLabel WHERE { | |
| ?house wbt:P31 ?collection . | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } """ | |
| popular_year_inception_question = "In which years were the most fashion houses founded?" | |
| popular_year_inception_query = """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 ?year_inception (COUNT(DISTINCT ?fashion_house) AS ?count) | |
| WHERE { | |
| ?fashion_house wbt:P11 ?year. | |
| BIND(YEAR(?year) AS ?year_inception) | |
| } | |
| GROUP BY ?year_inception | |
| ORDER BY DESC(?count) """ | |
| longest_serving_director_question = "Which fashion houses have had the longest-serving creative director?" | |
| longest_serving_director_query = """ 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | |
| PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
| SELECT ?fashion_houseLabel ?duration ?designerLabel | |
| WHERE { | |
| ?fashion_house p:P29 ?statement. | |
| ?statement ps:P29 ?designer. | |
| OPTIONAL { ?statement pq:P15 ?startTime. } | |
| OPTIONAL { ?statement pq:P16 ?endTime. } | |
| # Ensure we only calculate when both dates exist | |
| FILTER(BOUND(?startTime) && BOUND(?endTime)) | |
| # Compute duration safely | |
| BIND(YEAR(?endTime) - YEAR(?startTime) AS ?duration) | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } | |
| ORDER BY DESC(?duration)""" | |
| houses_most_collections_question = "Which fashion houses have the most collections recorded in the database?" | |
| houses_most_collections_query = """ 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?fashionHouseLabel (COUNT(?collection) AS ?collection_count) WHERE { | |
| ?fashionHouse wbt:P31 ?collection . | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } | |
| GROUP BY ?fashionHouseLabel | |
| ORDER BY DESC(?collection_count)""" | |
| collections_sustainability_theme_question = "Which collections include sustainability as a key theme?" | |
| collections_sustainability_theme_query = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?collectionLabel ?fashion_houseLabel ?reference_URL WHERE { | |
| ?fashion_house p:P31 ?statement. | |
| ?statement ps:P31 ?collection. | |
| ?statement pq:P34 ?description . | |
| FILTER (regex(?description, "sustainability", "i")) | |
| # Retrieve references for the statement | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| } | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } """ | |
| collections_jeans_question = "Which collections showcase products made with jeans?" | |
| collections_jeans_query = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?collectionLabel ?fashion_houseLabel ?reference_URL WHERE { | |
| ?fashion_house p:P31 ?statement. | |
| ?statement ps:P31 ?collection. | |
| ?statement pq:P34 ?description . | |
| FILTER (regex(?description, "jeans", "i")) | |
| # Retrieve references for the statement | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| } | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } """ | |
| creative_directors_school_question = "To which school went most designers who later became creative directors of fashion houses?" | |
| creative_directors_school_query = """ 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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?schoolLabel (COUNT(DISTINCT ?designer) AS ?designer_count) WHERE { | |
| ?designer p:P10 ?fashion_house . | |
| OPTIONAL { ?fashion_house pq:P25 ?title. } | |
| FILTER ( | |
| REGEX(?title, "creative director", "i") || | |
| REGEX(?title, "head designer", "i") || | |
| REGEX(?title, "chief", "i") || | |
| REGEX(?title, "founder", "i") | |
| ) | |
| OPTIONAL { ?designer wbt:P9 ?school . } | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language 'en'. } | |
| } | |
| GROUP BY ?schoolLabel | |
| ORDER BY DESC(?designer_count)""" | |
| fashion_houses_thematic_collection_question = "Which fashion houses had collections with a sustainability theme, and how many of them?" | |
| fashion_houses_thematic_collection_query = """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/> | |
| PREFIX prov: <http://www.w3.org/ns/prov#> | |
| SELECT ?fashion_houseLabel (COUNT(DISTINCT ?collection) AS ?collection_count) WHERE { | |
| ?fashion_house p:P31 ?statement. | |
| ?statement ps:P31 ?collection. | |
| ?statement pq:P34 ?description . | |
| FILTER (regex(?description, "sustainability", "i")) | |
| # Retrieve references for the statement | |
| OPTIONAL { | |
| ?statement prov:wasDerivedFrom ?reference. | |
| ?reference pr:P24 ?reference_URL. | |
| } | |
| SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | |
| } GROUP BY ?fashion_houseLabel | |
| ORDER BY DESC(?collection_count) """ | |
| questions_queries_dict = [ { "question": education_most_popular_question, "query": education_most_popular_query}, | |
| { "question": how_many_designers_per_fashion_house_question, "query": how_many_designers_per_fashion_house_query}, | |
| {"question": how_many_directors_per_fashion_house_question, "query": how_many_directors_per_fashion_house_query}, | |
| {"question": designers_multiple_houses_question, "query":designers_multiple_houses_query }, | |
| {"question": award_question, "query": award_question}, | |
| {"question": fashion_houses_with_collections_question, "query": fashion_houses_with_collections_query}, | |
| {"question": popular_year_inception_question, "query": popular_year_inception_query}, | |
| {"question": longest_serving_director_question, "query": longest_serving_director_query}, | |
| {"question": houses_most_collections_question, "query": houses_most_collections_query}, | |
| {"question": collections_sustainability_theme_question, "query": collections_sustainability_theme_query}, | |
| ] | |
| questions_queries_dict_entity = [{"question": fashion_house_directors_question, "query": fashion_house_directors_query}, | |
| { "question": designer_fashion_house_directors_question, "query": designer_fashion_house_directors_query}, | |
| { "question": country_designer_question, "query": country_designer_query}, | |
| { "question": designer_order_fashion_collection_question, "query": designer_order_fashion_collection_query}, | |
| { "question": designer_fashion_director_question2, "query": designer_fashion_director_query2}, | |
| { "question": year_designers_birth_question, "query": year_designers_birth_query}] | |
| # Designers | |
| designers_born_in_year_question = "Which designers were born in year $x?" | |
| creative_directors_of_house_question = "Which designers have been creative directors of $x?" | |
| designers_multiple_houses_question = "Which designers have worked for more than one fashion house?" | |
| educated_at_school_question = "Which designers were educated at $x fashion school?" | |
| won_award_question = "Which designers have won the $x award?" | |
| launched_own_label_question = "Which designers launched their own fashion label?" | |
| worked_at_x_between_years_question = "Which designers worked at $x between year $y and $z?" | |
| designers_multiple_collaborations_question = "Which designers have collaborated with multiple fashion houses?" | |
| designers_lived_in_city_question = "Which designers have lived in $x city?" | |
| designers_active_decade_question = "Which designers were active during the $x decade?" | |
| # Fashion Houses | |
| designers_worked_for_house_question = "Which designers have worked for fashion house $x?" | |
| creative_directors_per_house_question = "How many designers have worked for each fashion house as creative directors?" | |
| houses_founded_in_year_question = "Which fashion houses were founded in year $x?" | |
| houses_most_director_changes_question = "Which fashion houses have undergone the most creative director changes?" | |
| longest_serving_director_question = "Which fashion houses have had the longest-serving creative director?" | |
| houses_collaborations_question = "Which fashion houses have collaborated with other fashion houses or brands?" | |
| houses_haute_couture_question = "Which fashion houses have produced haute couture collections?" | |
| houses_active_decade_question = "Which fashion houses were active during the $x decade?" | |
| houses_most_collections_question = "Which fashion houses have the most collections recorded in the database?" | |
| # Fashion Collections | |
| designer_worked_on_collections_question = "Which fashion collections did $x work on?" | |
| collections_inspired_by_theme_question = "Which fashion house produced a collection inspired by $x theme?" | |
| collections_high_critical_acclaim_question = "Which collections received the highest critical acclaim?" | |
| collections_historical_references_question = "Which collections feature references to historical fashion styles?" | |
| collections_sustainability_theme_question = "Which collections include sustainability as a key theme?" | |
| collections_per_house_per_year_question = "How many collections did each fashion house produce in year $x?" | |
| collections_avant_garde_question = "Which collections have been described as avant-garde?" | |
| collections_stylistic_similarity_question = "Which collections share stylistic similarities with $x?" | |
| collections_evolution_over_time_question = "How has the style of $x fashion house evolved over the years?" | |
| collections_shown_at_fashion_week_question = "Which collections were showcased at $x fashion week?" | |
| # Designers & Fashion Houses | |
| studied_then_director_question = "Which designers who studied at $x fashion school later became creative directors at $y fashion house?" | |
| worked_at_both_houses_question = "Which designers have worked at both $x and $y fashion houses?" | |
| launched_label_after_working_question = "Which designers who launched their own fashion labels had previously worked at $x fashion house?" | |
| won_award_then_worked_question = "Which designers who won the $x award also worked for $y fashion house?" | |
| lived_in_city_and_director_question = "Which designers who lived in $x city have worked as creative directors for $y fashion house?" | |
| worked_for_three_houses_question = "Which designers have worked for at least three different fashion houses during their career?" | |
| designed_for_two_brands_same_year_question = "Which designers who were creative directors at $x fashion house also designed collections for another brand in the same year?" | |
| creative_director_and_label_founder_question = "Which designers were both fashion house creative directors and independent label founders at the same time?" | |
| collaborated_with_two_houses_question = "Which designers have collaborated with both $x and $y fashion houses?" | |
| worked_at_x_before_y_question = "Which designers worked at $x fashion house before moving to $y?" | |
| # Designers & Collections | |
| designed_for_multiple_houses_same_season_question = "Which designers have designed collections for multiple fashion houses in the same season?" | |
| couture_and_ready_to_wear_question = "Which designers who specialized in haute couture have also designed ready-to-wear collections?" | |
| similar_theme_collections_question = "Which designers who worked on $x collection had previously worked on a similar-themed collection for another brand?" | |
| award_winner_inspired_by_history_question = "Which designers who have won an award have produced a collection inspired by $x historical period?" | |
| alma_mater_referenced_in_collection_question = "Which designers who studied at $x school designed a collection that referenced their alma mater?" | |
| # Fashion Houses & Collections | |
| same_historical_period_collections_question = "Which fashion houses have produced collections inspired by the same historical period?" | |
| collaborations_with_artists_question = "Which fashion houses have produced collections featuring collaborations with artists from $x field (e.g., photography, sculpture, film)?" | |
| change_director_different_collection_question = "Which fashion houses have changed creative directors and immediately released a significantly different collection?" | |
| avant_garde_and_minimalist_question = "Which fashion houses have produced both avant-garde and minimalist collections?" | |
| inspired_by_other_brands_question = "Which fashion houses have produced a collection inspired by a previous designer’s work from another brand?" | |
| # Multi-Category (Designers, Houses, Collections) | |
| designer_worked_house_then_influenced_question = "Which designers who worked for $x fashion house also designed a collection influenced by $y movement?" | |
| designer_lived_in_city_referenced_collection_question = "Which designers who lived in $x city during year $y produced a collection with references to that place?" | |
| multiple_designers_same_collection_question = "Which fashion houses have had at least three designers contribute to the same collection?" | |
| worked_elsewhere_during_collection_question = "Which collections were created by a designer who was also working at another fashion house at the time?" | |
| education_influenced_collection_question = "Which fashion collections were influenced by a designer’s education at $x fashion school?" | |
| # Designers & Fashion Houses | |
| studied_then_director_question = "Which designers who studied at $x fashion school later became creative directors at $y fashion house?" | |
| worked_at_both_houses_question = "Which designers have worked at both $x and $y fashion houses?" | |
| launched_label_after_working_question = "Which designers who launched their own fashion labels had previously worked at $x fashion house?" | |
| won_award_then_worked_question = "Which designers who won the $x award also worked for $y fashion house?" | |
| lived_in_city_and_director_question = "Which designers who lived in $x city have worked as creative directors for $y fashion house?" | |
| worked_for_three_houses_question = "Which designers have worked for at least three different fashion houses during their career?" | |
| designed_for_two_brands_same_year_question = "Which designers who were creative directors at $x fashion house also designed collections for another brand in the same year?" | |
| creative_director_and_label_founder_question = "Which designers were both fashion house creative directors and independent label founders at the same time?" | |
| collaborated_with_two_houses_question = "Which designers have collaborated with both $x and $y fashion houses?" | |
| worked_at_x_before_y_question = "Which designers worked at $x fashion house before moving to $y?" | |
| # Designers & Collections | |
| designed_for_multiple_houses_same_season_question = "Which designers have designed collections for multiple fashion houses in the same season?" | |
| couture_and_ready_to_wear_question = "Which designers who specialized in haute couture have also designed ready-to-wear collections?" | |
| similar_theme_collections_question = "Which designers who worked on $x collection had previously worked on a similar-themed collection for another brand?" | |
| award_winner_inspired_by_history_question = "Which designers who have won an award have produced a collection inspired by $x historical period?" | |
| alma_mater_referenced_in_collection_question = "Which designers who studied at $x school designed a collection that referenced their alma mater?" | |
| # Fashion Houses & Collections | |
| same_historical_period_collections_question = "Which fashion houses have produced collections inspired by the same historical period?" | |
| collaborations_with_artists_question = "Which fashion houses have produced collections featuring collaborations with artists from $x field (e.g., photography, sculpture, film)?" | |
| change_director_different_collection_question = "Which fashion houses have changed creative directors and immediately released a significantly different collection?" | |
| avant_garde_and_minimalist_question = "Which fashion houses have produced both avant-garde and minimalist collections?" | |
| inspired_by_other_brands_question = "Which fashion houses have produced a collection inspired by a previous designer’s work from another brand?" | |
| # Multi-Category (Designers, Houses, Collections) | |
| designer_worked_house_then_influenced_question = "Which designers who worked for $x fashion house also designed a collection influenced by $y movement?" | |
| designer_lived_in_city_referenced_collection_question = "Which designers who lived in $x city during year $y produced a collection with references to that place?" | |
| multiple_designers_same_collection_question = "Which fashion houses have had at least three designers contribute to the same collection?" | |
| worked_elsewhere_during_collection_question = "Which collections were created by a designer who was also working at another fashion house at the time?" | |
| education_influenced_collection_question = "Which fashion collections were influenced by a designer’s education at $x fashion school?" | |