fnielsen / ordia

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

The SPARQL for compounds is slow #184

Open fnielsen opened 7 months ago

fnielsen commented 7 months ago

Instead of the below version one can add a WITH block

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