fnielsen / ordia

Wikidata lexemes presentations
https://ordia.toolforge.org
Apache License 2.0
24 stars 13 forks source link

Compounds listing is too slow and can be improved with WITH #171

Open fnielsen opened 1 year ago

fnielsen commented 1 year ago

SELECT
  ?lexeme ?lexemeLabel
  ?lexical_category ?lexical_categoryLabel
  ?other_compounds
WITH {
    SELECT
      ?lexeme
      (GROUP_CONCAT(?compoundLabel; separator=" // ") AS ?other_compounds)
    WHERE {
      ?lexeme wdt:P5238+ wd:L300427 .
      OPTIONAL {
        ?lexeme wdt:P5238 ?compound .
        ?compound wikibase:lemma ?compoundLabel .
        FILTER (?compound != wd:L300427)
      }
    }
    GROUP BY ?lexeme
} AS %compounds
WHERE {
  INCLUDE %compounds
  ?lexeme wikibase:lemma ?lexemeLabel .
  OPTIONAL {
    ?lexeme wikibase:lexicalCategory ?lexical_category .
    ?lexical_category rdfs:label ?lexical_categoryLabel .
    FILTER (LANG(?lexical_categoryLabel) = 'en')
  }
}