fnielsen / ordia

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

Guess Image From Pronunciation #241

Closed fnielsen closed 2 days ago

fnielsen commented 2 days ago

Variation of https://ordia.toolforge.org/guess-word-from-pronunciation/ and https://ordia.toolforge.org/guess-word-from-image/

fnielsen commented 2 days ago
SELECT 
  (CONCAT('<option value="', SUBSTR(STR(?language), 32), '">', ?local_label, ' - ', ?code, ' - ', ?english_label, '</option>') AS ?string)

  ?audios 
  # ?language ?languageLabel
WITH {
SELECT
  (COUNT(?audio) AS ?audios)
  (COUNT(?image) AS ?images)
  ?language
WHERE {
  [] dct:language ?language ;
     ontolex:lexicalForm / wdt:P443 ?audio ;
     ontolex:sense / wdt:P18 ?image
}
GROUP BY ?language
HAVING (?audios >= 10)
} AS %languages
WHERE {
  INCLUDE %languages 
  ?language rdfs:label ?english_label, ?local_label ;
  wdt:P424 ?code .
  FILTER (LANG(?english_label) = 'en')
  FILTER (LANG(?local_label) = ?code)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
ORDER BY ?code
fnielsen commented 2 days ago
SELECT 
  (CONCAT('<option value="', SUBSTR(STR(?language), 32), '">', ?local_label, ' - ', ?code, ' - ', ?english_label, '</option>') AS ?string)

  ?audios ?images
  # ?language ?languageLabel
WITH {
SELECT
  (COUNT(?audio) AS ?audios)
  (COUNT(?image) AS ?images)
  ?language
WHERE {
  [] dct:language ?language ;
     ontolex:lexicalForm / wdt:P443 ?audio ;
     ontolex:sense ?sense .
  { ?sense wdt:P18 ?image_via_sense }
  UNION
  { ?sense wdt:P5137 / wdt:P18 ?image_via_q }
  BIND(COALESCE(?image_via_sense, ?image_via_q) AS ?image)
}
GROUP BY ?language
HAVING (?audios >= 10)
} AS %languages
WHERE {
  INCLUDE %languages 
  ?language rdfs:label ?english_label, ?local_label ;
  wdt:P424 ?code .
  FILTER (LANG(?english_label) = 'en')
  FILTER (LANG(?local_label) = ?code)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
ORDER BY ?code