Spaces:
Sleeping
Sleeping
File size: 41,238 Bytes
6523110 dd2e1d7 6523110 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 |
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 = Template("Images of collections produced by $x")
fashion_collection_images_query = Template("""
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 $x@en.} # Match label
UNION
{ ?fashion_house skos:altLabel $x@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 = Template("Which designers were born in $x?")
year_designers_birth_query = Template("""
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) = $x)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} """)
fashion_house_directors_question = Template("Which designers have been creative directors of $x ?")
fashion_house_directors_query = Template("""
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 $x@en.} # Match label
UNION
{ ?fashion_house skos:altLabel $x@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 = Template("In which fashion house did $x work as a creative director?")
designer_fashion_house_directors_query = Template("""
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 $x@en.} # Match label
UNION
{ ?fashion_designer skos:altLabel $x@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 = Template("In which fashion house did $x work as a creative director?")
designer_fashion_director_query2 = Template("""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 $x@en.} # Match label
UNION
{ ?creative_director skos:altLabel $x@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 = Template("Which designers are from $x ?")
country_designer_query = Template("""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 $x@en.} # Match label
UNION
{ ?country skos:altLabel $x@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 = Template("""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 $x@en.} # Match label
UNION
{ ?country skos:altLabel $x@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 = Template("Which fashion collections did $x work on?")
designer_order_fashion_collection_query = Template("""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 $x@en.} # Match label
UNION
{ ?fashion_designer skos:altLabel $x@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.substitute({ "x": f"{"Chanel"}"}), "query": fashion_house_directors_query},
# { "question": designer_fashion_house_directors_question.substitute({ "x": f"{"Alexander McQueen"}"}), "query": designer_fashion_house_directors_query},
# { "question": country_designer_question.substitute({ "x": f"{"Italy"}"}), "query": country_designer_query},
# { "question": designer_order_fashion_collection_question.substitute({ "x": f"{"Alexander McQueen"}"}), "query": designer_order_fashion_collection_query},
# { "question": designer_fashion_director_question2.substitute({ "x": f"{"Alexander McQueen"}"}), "query": designer_fashion_director_query2},
# { "question": year_designers_birth_question.substitute({ "x": f"{"1970"}"}), "query": year_designers_birth_query}]
questions_queries_dict_entity = [{"question": fashion_house_directors_question.substitute({ "x": "Chanel"}), "query": fashion_house_directors_query},
{ "question": designer_fashion_house_directors_question.substitute({ "x": "Alexander McQueen"}), "query": designer_fashion_house_directors_query},
{ "question": country_designer_question.substitute({ "x": "Italy"}), "query": country_designer_query},
{ "question": designer_order_fashion_collection_question.substitute({ "x": "Alexander McQueen"}), "query": designer_order_fashion_collection_query},
{ "question": designer_fashion_director_question2.substitute({ "x": "Alexander McQueen"}), "query": designer_fashion_director_query2},
{ "question": year_designers_birth_question.substitute({ "x": "1970"}), "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?"
|