query-53f2a32dcfa0626f1cc7fa13614f6f7f

rq turtle/ttl

Script #1

Should ideally print labels in all pertinent languanges, and include the language after the label.

E.g. "Super Mario Bros. (ENG)"

SELECT # This section thanks to User:VIGNERON

(MIN(?dateYear) AS ?dateYears)

(

CONCAT

(

GROUP_CONCAT(DISTINCT ?gameENLabelTxt; separator = ", "), ", ",

GROUP_CONCAT(DISTINCT ?gameJALabelTxt; separator = ", "), ", ",

GROUP_CONCAT(DISTINCT ?gameHPLabelTxt; separator = ", "), ", ",

GROUP_CONCAT(DISTINCT ?gameZHLabelTxt; separator = ", "), ", ",

GROUP_CONCAT(DISTINCT ?gamePYLabelTxt; separator = ", ")

) AS ?gameNames

)

(GROUP_CONCAT(DISTINCT ?cooLabel; separator = ", ") AS ?cooLabels)

(?game AS ?dataLink)

# This section is an alternate
(MIN(?dateYear) AS  ?dateYears)
(GROUP_CONCAT(DISTINCT  ?gameENLabel;   separator = ", ") AS    ?gameENLabels)      # English label

(GROUP_CONCAT(DISTINCT ?gameNOLabel; separator = ", ") AS ?gameNOTxts) # All non-English labels, too many

(GROUP_CONCAT(DISTINCT  ?gameJALabel;   separator = ", ") AS    ?gameJALabels)      # Japanese label
(GROUP_CONCAT(DISTINCT  ?gameHPLabel;   separator = ", ") AS    ?gameHPLabels)      # Hepburn label

(GROUP_CONCAT(DISTINCT ?gameZHLabel; separator = ", ") AS ?gameZHLabels) # Mandarin label

(GROUP_CONCAT(DISTINCT ?gamePYLabel; separator = ", ") AS ?gamePYLabels) # Pinyin label

(GROUP_CONCAT(DISTINCT  ?cooLabel;      separator = ", ") AS    ?cooLabels)

(?game AS ?dataLink)

WHERE
{

hint:Query hint:optimizer "None".

    # test values

VALUES ?game

{

wd:Q4850488 # Baldur's Gate III: The Black Hound (should have "no value" due to being cancelled)

wd:Q4931588 # Bob's Game (should have "no value" due to not being released yet)

wd:Q5315330 # Dunjonquest (1979)

wd:Q5250229 # Deep Labyrinth (should have multiple dates)

wd:Q1462499 # Starflight (1986, has multiple genres)

wd:Q22124593 # God Wars: Beyond Time (should have blank date since the property does not exist)

}

    # types of item
          {?game wdt:P136 wd:Q744038}   # regular RPGs
    UNION {?game wdt:P136 wd:Q1529437}  # tactical RPGs
    UNION {?game wdt:P136 wd:Q1422746}  # action RPGs
    UNION {?game wdt:P136 wd:Q1143132}  # roguelikes

?game wdt:P136/wdt:P279* wd:Q744038. # any class or subclass of role-playing video game, including MMORPGs

    ?game wdt:P31 wd:Q7889.      # instance of video game

    #country of origin
    OPTIONAL
    {
        ?game wdt:P495 ?country.    # country of origin
        ?country wdt:P297 ?cooLabel.    # abbreviation
    }

    # English label
    OPTIONAL
    {
        ?game rdfs:label ?gameENLabel FILTER(LANG(?gameENLabel) = "en").
        BIND(CONCAT(?gameENLabel, " (EN)") AS ?gameENLabelTxt)
    }
    # All non-English labels. Waaaay too many results! Many duplicates!
    # Ideally, we would only get non-English labels for games that originate from non-English speaking countries. And only get those languages, not others!
    # Only some dates are pertinent to en.wikipedia.

OPTIONAL

{

?game rdfs:label ?gameNOLabel FILTER(LANG(?gameNOLabel) != "en").

BIND(CONCAT(?gameNOLabel, " (", LANG(?gameNOLabel), ")") AS ?gameNOLabelTxt)

}

    # Japanese label
    OPTIONAL
    {
        ?game rdfs:label ?gameJALabel FILTER(LANG(?gameJALabel) = "ja")
        BIND(CONCAT(?gameJALabel, " (JA)") AS ?gameJALabelTxt)
    }
    # Japanese hepburn romanization
    OPTIONAL
    {
        ?game wdt:P2125 ?gameHPLabel
        BIND(CONCAT(?gameHPLabel, " (JA)") AS ?gameHPLabelTxt)
    }
    # Chinese label
    OPTIONAL
    {
        ?game rdfs:label ?gameZHLabel FILTER(LANG(?gameZHLabel) = "zh")
        BIND(CONCAT(?gameZHLabel, " (ZH)") AS ?gameZHLabelTxt)
    }
    # Chinese pinyin transliteration
    OPTIONAL
    {
        ?game wdt:P1721 ?gamePYLabel
        BIND(CONCAT(?gamePYLabel, " (ZH)") AS ?gamePYLabelTxt)
    }

    # release date (simple)
    OPTIONAL {?game wdt:P577 ?date BIND(YEAR(?date) AS ?dateYear)}

    # hepburn romanization and pinyin transliteration (is this still necessary?)

OPTIONAL {?game wdt:P2125 ?hepburn}

OPTIONAL {?game wdt:P1721 ?pinyin}

SERVICE wikibase:label

{

bd:serviceParam wikibase:language "en".

?hepburn rdfs:label ?gameHPLabel.

?pinyin rdfs:label ?gamePYLabel.

}

}

GROUP BY $game ORDER BY ASC (?dateYears) ASC (?gameENLabelTxts)

limit 100

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Script #1
# Should ideally print labels in all pertinent languanges, and include the language after the label.
# E.g. "Super Mario Bros. (ENG)"

SELECT
    # This section thanks to User:VIGNERON
#   (MIN(?dateYear) AS  ?dateYears)
#   (
#       CONCAT  
#       (
#           GROUP_CONCAT(DISTINCT ?gameENLabelTxt; separator = ", "), ", ",
#           GROUP_CONCAT(DISTINCT ?gameJALabelTxt; separator = ", "), ", ",
#           GROUP_CONCAT(DISTINCT ?gameHPLabelTxt; separator = ", "), ", ",
#           GROUP_CONCAT(DISTINCT ?gameZHLabelTxt; separator = ", "), ", ",
#           GROUP_CONCAT(DISTINCT ?gamePYLabelTxt; separator = ", ")
#       ) AS ?gameNames
#   )
#   (GROUP_CONCAT(DISTINCT  ?cooLabel;      separator = ", ") AS    ?cooLabels)
#   (?game AS ?dataLink)

    # This section is an alternate
    (MIN(?dateYear) AS  ?dateYears)
    (GROUP_CONCAT(DISTINCT  ?gameENLabel;   separator = ", ") AS    ?gameENLabels)      # English label
#   (GROUP_CONCAT(DISTINCT  ?gameNOLabel;   separator = ", ") AS    ?gameNOTxts)        # All non-English labels, too many
    (GROUP_CONCAT(DISTINCT  ?gameJALabel;   separator = ", ") AS    ?gameJALabels)      # Japanese label
    (GROUP_CONCAT(DISTINCT  ?gameHPLabel;   separator = ", ") AS    ?gameHPLabels)      # Hepburn label
#   (GROUP_CONCAT(DISTINCT  ?gameZHLabel;   separator = ", ") AS    ?gameZHLabels)      # Mandarin label
#   (GROUP_CONCAT(DISTINCT  ?gamePYLabel;   separator = ", ") AS    ?gamePYLabels)      # Pinyin label
    (GROUP_CONCAT(DISTINCT  ?cooLabel;      separator = ", ") AS    ?cooLabels)
#   (?game AS ?dataLink)

    WHERE
    {
#       hint:Query hint:optimizer "None".

        # test values
#       VALUES ?game
#       {
#           wd:Q4850488     # Baldur's Gate III: The Black Hound (should have "no value" due to being cancelled)
#           wd:Q4931588     # Bob's Game (should have "no value" due to not being released yet)
#           wd:Q5315330     # Dunjonquest (1979)
#           wd:Q5250229     # Deep Labyrinth (should have multiple dates)
#           wd:Q1462499     # Starflight (1986, has multiple genres)
#           wd:Q22124593        # God Wars: Beyond Time (should have blank date since the property does not exist)
#       }

        # types of item
              {?game wdt:P136 wd:Q744038}   # regular RPGs
        UNION {?game wdt:P136 wd:Q1529437}  # tactical RPGs
        UNION {?game wdt:P136 wd:Q1422746}  # action RPGs
        UNION {?game wdt:P136 wd:Q1143132}  # roguelikes
#       ?game wdt:P136/wdt:P279* wd:Q744038.    # any class or subclass of role-playing video game, including MMORPGs
        ?game wdt:P31 wd:Q7889.      # instance of video game

        #country of origin
        OPTIONAL
        {
            ?game wdt:P495 ?country.    # country of origin
            ?country wdt:P297 ?cooLabel.    # abbreviation
        }

        # English label
        OPTIONAL
        {
            ?game rdfs:label ?gameENLabel FILTER(LANG(?gameENLabel) = "en").
            BIND(CONCAT(?gameENLabel, " (EN)") AS ?gameENLabelTxt)
        }
        # All non-English labels. Waaaay too many results! Many duplicates!
        # Ideally, we would only get non-English labels for games that originate from non-English speaking countries. And only get those languages, not others!
        # Only some dates are pertinent to en.wikipedia.
#       OPTIONAL
#       {
#           ?game rdfs:label ?gameNOLabel FILTER(LANG(?gameNOLabel) != "en").
#           BIND(CONCAT(?gameNOLabel, " (", LANG(?gameNOLabel), ")") AS ?gameNOLabelTxt)
#       }
        # Japanese label
        OPTIONAL
        {
            ?game rdfs:label ?gameJALabel FILTER(LANG(?gameJALabel) = "ja")
            BIND(CONCAT(?gameJALabel, " (JA)") AS ?gameJALabelTxt)
        }
        # Japanese hepburn romanization
        OPTIONAL
        {
            ?game wdt:P2125 ?gameHPLabel
            BIND(CONCAT(?gameHPLabel, " (JA)") AS ?gameHPLabelTxt)
        }
        # Chinese label
        OPTIONAL
        {
            ?game rdfs:label ?gameZHLabel FILTER(LANG(?gameZHLabel) = "zh")
            BIND(CONCAT(?gameZHLabel, " (ZH)") AS ?gameZHLabelTxt)
        }
        # Chinese pinyin transliteration
        OPTIONAL
        {
            ?game wdt:P1721 ?gamePYLabel
            BIND(CONCAT(?gamePYLabel, " (ZH)") AS ?gamePYLabelTxt)
        }

        # release date (simple)
        OPTIONAL {?game wdt:P577 ?date BIND(YEAR(?date) AS ?dateYear)}

        # hepburn romanization and pinyin transliteration (is this still necessary?)
#       OPTIONAL {?game wdt:P2125   ?hepburn}
#       OPTIONAL {?game wdt:P1721   ?pinyin}
#       SERVICE wikibase:label
#       {
#           bd:serviceParam wikibase:language "en".
#           ?hepburn rdfs:label ?gameHPLabel.
#           ?pinyin rdfs:label  ?gamePYLabel.
#       }
    }
GROUP BY $game
ORDER BY ASC (?dateYears) ASC (?gameENLabelTxts)
#limit 100

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?cooLabel"):::projected v21("?cooLabels") v7("?country") v16("?date") v17("?dateYear"):::projected v18("?dateYears") v6("?game") v5("?gameENLabel"):::projected v9("?gameENLabelTxt") v2("?gameENLabelTxts") v18("?gameENLabels") v11("?gameHPLabel"):::projected v12("?gameHPLabelTxt") v20("?gameHPLabels") v4("?gameJALabel"):::projected v10("?gameJALabelTxt") v19("?gameJALabels") v14("?gamePYLabel") v15("?gamePYLabelTxt") v3("?gameZHLabel") v13("?gameZHLabelTxt") c5(["wd:Q744038"]):::iri c7(["wd:Q1422746"]):::iri c6(["wd:Q1529437"]):::iri c10(["wd:Q7889"]):::iri c8(["wd:Q1143132"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v6 --"wdt:P136"--> c8 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v6 --"wdt:P136"--> c7 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v6 --"wdt:P136"--> c6 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v6 --"wdt:P136"--> c5 end union0r <== or ==> union0l end v6 --"wdt:P31"--> c10 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P495".-> v7 v7 --"wdt:P297"--> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v6 -."rdfs:label".-> v5 bind0[/"concat(?gameENLabel,' (EN)')"/] v5 --o bind0 bind0 --as--o v9 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v6 -."rdfs:label".-> v4 bind1[/"concat(?gameJALabel,' (JA)')"/] v4 --o bind1 bind1 --as--o v10 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P2125".-> v11 bind2[/"concat(?gameHPLabel,' (JA)')"/] v11 --o bind2 bind2 --as--o v12 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v6 -."rdfs:label".-> v3 bind3[/"concat(?gameZHLabel,' (ZH)')"/] v3 --o bind3 bind3 --as--o v13 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P1721".-> v14 bind4[/"concat(?gamePYLabel,' (ZH)')"/] v14 --o bind4 bind4 --as--o v15 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P577".-> v16 bind5[/"year-from-dateTime(?date)"/] v16 --o bind5 bind5 --as--o v17 end bind11[/"min(?dateYear)"/] v17 --o bind11 bind11 --as--o v18 bind12[/"?gameENLabel"/] v5 --o bind12 bind12 --as--o v18 bind13[/"?gameJALabel"/] v4 --o bind13 bind13 --as--o v19 bind14[/"?gameHPLabel"/] v11 --o bind14 bind14 --as--o v20 bind15[/"?cooLabel"/] v8 --o bind15 bind15 --as--o v21