SPARQL queries: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Here you find some SPARQL queries that you can use, and also modify or combine. =Lexical Entries= <sparql tryit="1"> # this lists all lexcial entries, with lemma and pos, ordered alphabetically by lemma select ?entry ?lemma ?posLabel where {?entry a ontolex:LexicalEntry; wikibase:lemma ?lemma; wikibase:lexicalCategory [rdfs:label ?posLabel]. filter(lang(?posLabel)="en")} order by lcase(?lemma) </sparql> =Dialectal lemm...") |
(Puno Quechua lexical entries query) |
||
(6 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
Here you find some SPARQL queries that you can use, and also modify or combine. | Here you find some SPARQL queries that you can use, and also modify or combine. To start a query from scratch, you may use this: | ||
<sparql tryit="1"> | |||
PREFIX qwb: <https://qichwa.wikibase.cloud/entity/> | |||
PREFIX qdp: <https://qichwa.wikibase.cloud/prop/direct/> | |||
PREFIX qp: <https://qichwa.wikibase.cloud/prop/> | |||
PREFIX qps: <https://qichwa.wikibase.cloud/prop/statement/> | |||
PREFIX qpq: <https://qichwa.wikibase.cloud/prop/qualifier/> | |||
PREFIX qpr: <https://qichwa.wikibase.cloud/prop/reference/> | |||
PREFIX qno: <https://qichwa.wikibase.cloud/prop/novalue/> | |||
SELECT * WHERE {} | |||
</sparql> | |||
=Lexical Entries= | =Lexical Entries= | ||
==Puno Quechua Lexical entries == | |||
<sparql tryit="1"> | |||
#This is a list of Puno Quechua Lexical entries | |||
PREFIX qwb: <https://qichwa.wikibase.cloud/entity/> | |||
PREFIX qdp: <https://qichwa.wikibase.cloud/prop/direct/> | |||
PREFIX qp: <https://qichwa.wikibase.cloud/prop/> | |||
PREFIX qps: <https://qichwa.wikibase.cloud/prop/statement/> | |||
PREFIX qpq: <https://qichwa.wikibase.cloud/prop/qualifier/> | |||
PREFIX qpr: <https://qichwa.wikibase.cloud/prop/reference/> | |||
PREFIX qno: <https://qichwa.wikibase.cloud/prop/novalue/> | |||
SELECT ?entry ?lemma ?language ?lexical_category ?lex_cat_wikidata ?described_in | |||
?form_representation ?spelling_variant | |||
?sense_gloss_de ?sense_gloss_en ?sense_gloss_es ?sense_gloss_it | |||
WHERE { | |||
BIND("Q5218" AS ?language) #assigning Q5218 = Quechua Wikidata as the language | |||
BIND("qu-x-Q7260479" AS ?spelling_variant) #Assigning the language-code for the form | |||
BIND("Q24905" AS ?lex_cat_wikidata) #Assignning Q24905 = Verb Wikidata as the lexical category | |||
?entry a ontolex:LexicalEntry; | |||
wikibase:lemma ?lemma; | |||
wikibase:lexicalCategory qwb:Q99 ; #Category Q99 = V.tr Qichwabase | |||
wikibase:lexicalCategory [rdfs:label ?lexical_category] ; | |||
qp:P16 [qps:P16 ?form_representation; | |||
qpq:P17 qwb:Q116; #Q116 = Cusco-Collao (aiu) Qichwabase | |||
]. | |||
OPTIONAL { | |||
?entry ontolex:lexicalForm ?form1 . | |||
?form1 ontolex:representation ?wform1; | |||
wikibase:grammaticalFeature [rdfs:label ?wf1_gram_feature_label] . | |||
FILTER(LANG(?featureLabel)="es") | |||
} | |||
OPTIONAL { | |||
?entry ontolex:sense ?sense_de . | |||
?sense_de skos:definition ?sense_gloss_de. | |||
FILTER(LANG(?sense_gloss_de)="de") | |||
} | |||
OPTIONAL { | |||
?entry ontolex:sense ?sense_en . | |||
?sense_en skos:definition ?sense_gloss_en. | |||
FILTER(LANG(?sense_gloss_en)="en") | |||
} | |||
#OPTIONAL { # at least contains spanish gloss | |||
?entry ontolex:sense ?sense_es . | |||
?sense_es skos:definition ?sense_gloss_es. | |||
FILTER(LANG(?sense_gloss_es)="es") | |||
#} | |||
OPTIONAL { | |||
?entry ontolex:sense ?sense_it . | |||
?sense_it skos:definition ?sense_gloss_it. | |||
FILTER(LANG(?sense_gloss_it)="it") | |||
} | |||
} | |||
LIMIT 10 | |||
==Lexical entries with lemma and pos== | |||
<sparql tryit="1"> | <sparql tryit="1"> | ||
# this lists all lexcial entries, with lemma and pos, ordered alphabetically by lemma | # this lists all lexcial entries, with lemma and pos, ordered alphabetically by lemma | ||
Line 10: | Line 75: | ||
order by lcase(?lemma) | order by lcase(?lemma) | ||
</sparql> | </sparql> | ||
==Problematic lexical entries== | |||
<sparql tryit="1"> | |||
# this lists all lexical entries with bracket, semicolon, or comma in the lemma sign | |||
select ?entry ?lemma ?posLabel | |||
where {?entry a ontolex:LexicalEntry; | |||
wikibase:lemma ?lemma; | |||
wikibase:lexicalCategory [rdfs:label ?posLabel]. | |||
filter(lang(?posLabel)="en") | |||
filter(regex(?lemma,'[();,]'))} | |||
order by lcase(?lemma) | |||
</sparql> | |||
=Senses and sense descriptions= | |||
<sparql tryit="1"> | |||
#this lists entries that have senses and sense descriptions | |||
select ?entry ?lemma ?posLabel (group_concat(concat(str(?sensegloss)," (",lang(?sensegloss),")");SEPARATOR="; ") as ?sense_descriptions) | |||
where { | |||
?entry a ontolex:LexicalEntry; | |||
wikibase:lemma ?lemma; | |||
wikibase:lexicalCategory [rdfs:label ?posLabel] . filter(lang(?posLabel)="en") | |||
?entry ontolex:sense [skos:definition ?sensegloss]. | |||
} group by ?entry ?lemma ?posLabel ?sense_descriptions | |||
limit 100 # remove the limit and get all entries that have sense descriptions | |||
</sparql> | |||
=Dialectal lemma variants= | =Dialectal lemma variants= | ||
<sparql tryit="1"> | <sparql tryit="1"> | ||
Line 23: | Line 115: | ||
} | } | ||
GROUP BY ?dialect ?dialectLabel ?variants ORDER BY DESC(?variants) | GROUP BY ?dialect ?dialectLabel ?variants ORDER BY DESC(?variants) | ||
</sparql> | |||
=Part of speech (lexical category)= | |||
==Course-grained (lexical category superclasses)== | |||
<sparql tryit="1"> | |||
#defaultView:BarChart | |||
PREFIX qdp: <https://qichwa.wikibase.cloud/prop/direct/> | |||
select ?pos ?posLabel (count(?entry) as ?count) | |||
where { | |||
?entry a ontolex:LexicalEntry; | |||
wikibase:lemma ?lemma; | |||
wikibase:lexicalCategory ?pos_finegrained. | |||
?pos_finegrained qdp:P4 ?pos. ?pos rdfs:label ?posLabel . filter(lang(?posLabel)="en") | |||
} group by ?pos ?posLabel ?count | |||
order by desc(?count) | |||
</sparql> | |||
==Fine-grained (lexical categories as in Runasimi Dictionary)== | |||
<sparql tryit="1"> | |||
#defaultView:BarChart | |||
#this shows pos distribution (fine-grained categories as in Runasimi dictionary) | |||
select ?pos ?posLabel (count(?entry) as ?count) | |||
where { | |||
?entry a ontolex:LexicalEntry; | |||
wikibase:lemma ?lemma; | |||
wikibase:lexicalCategory ?pos. ?pos rdfs:label ?posLabel . filter(lang(?posLabel)="en") | |||
} group by ?pos ?posLabel ?count | |||
order by desc(?count) | |||
</sparql> | </sparql> |
Latest revision as of 14:38, 20 April 2024
Here you find some SPARQL queries that you can use, and also modify or combine. To start a query from scratch, you may use this:
PREFIX qwb: <https://qichwa.wikibase.cloud/entity/>
PREFIX qdp: <https://qichwa.wikibase.cloud/prop/direct/>
PREFIX qp: <https://qichwa.wikibase.cloud/prop/>
PREFIX qps: <https://qichwa.wikibase.cloud/prop/statement/>
PREFIX qpq: <https://qichwa.wikibase.cloud/prop/qualifier/>
PREFIX qpr: <https://qichwa.wikibase.cloud/prop/reference/>
PREFIX qno: <https://qichwa.wikibase.cloud/prop/novalue/>
SELECT * WHERE {}
Lexical Entries
Puno Quechua Lexical entries
#This is a list of Puno Quechua Lexical entries
PREFIX qwb: <https://qichwa.wikibase.cloud/entity/>
PREFIX qdp: <https://qichwa.wikibase.cloud/prop/direct/>
PREFIX qp: <https://qichwa.wikibase.cloud/prop/>
PREFIX qps: <https://qichwa.wikibase.cloud/prop/statement/>
PREFIX qpq: <https://qichwa.wikibase.cloud/prop/qualifier/>
PREFIX qpr: <https://qichwa.wikibase.cloud/prop/reference/>
PREFIX qno: <https://qichwa.wikibase.cloud/prop/novalue/>
SELECT ?entry ?lemma ?language ?lexical_category ?lex_cat_wikidata ?described_in
?form_representation ?spelling_variant
?sense_gloss_de ?sense_gloss_en ?sense_gloss_es ?sense_gloss_it
WHERE {
BIND("Q5218" AS ?language) #assigning Q5218 = Quechua Wikidata as the language
BIND("qu-x-Q7260479" AS ?spelling_variant) #Assigning the language-code for the form
BIND("Q24905" AS ?lex_cat_wikidata) #Assignning Q24905 = Verb Wikidata as the lexical category
?entry a ontolex:LexicalEntry;
wikibase:lemma ?lemma;
wikibase:lexicalCategory qwb:Q99 ; #Category Q99 = V.tr Qichwabase
wikibase:lexicalCategory [rdfs:label ?lexical_category] ;
qp:P16 [qps:P16 ?form_representation;
qpq:P17 qwb:Q116; #Q116 = Cusco-Collao (aiu) Qichwabase
].
OPTIONAL {
?entry ontolex:lexicalForm ?form1 .
?form1 ontolex:representation ?wform1;
wikibase:grammaticalFeature [rdfs:label ?wf1_gram_feature_label] .
FILTER(LANG(?featureLabel)="es")
}
OPTIONAL {
?entry ontolex:sense ?sense_de .
?sense_de skos:definition ?sense_gloss_de.
FILTER(LANG(?sense_gloss_de)="de")
}
OPTIONAL {
?entry ontolex:sense ?sense_en .
?sense_en skos:definition ?sense_gloss_en.
FILTER(LANG(?sense_gloss_en)="en")
}
#OPTIONAL { # at least contains spanish gloss
?entry ontolex:sense ?sense_es .
?sense_es skos:definition ?sense_gloss_es.
FILTER(LANG(?sense_gloss_es)="es")
#}
OPTIONAL {
?entry ontolex:sense ?sense_it .
?sense_it skos:definition ?sense_gloss_it.
FILTER(LANG(?sense_gloss_it)="it")
}
}
LIMIT 10
==Lexical entries with lemma and pos==
<sparql tryit="1">
# this lists all lexcial entries, with lemma and pos, ordered alphabetically by lemma
select ?entry ?lemma ?posLabel
where {?entry a ontolex:LexicalEntry;
wikibase:lemma ?lemma;
wikibase:lexicalCategory [rdfs:label ?posLabel].
filter(lang(?posLabel)="en")}
order by lcase(?lemma)
Problematic lexical entries
# this lists all lexical entries with bracket, semicolon, or comma in the lemma sign
select ?entry ?lemma ?posLabel
where {?entry a ontolex:LexicalEntry;
wikibase:lemma ?lemma;
wikibase:lexicalCategory [rdfs:label ?posLabel].
filter(lang(?posLabel)="en")
filter(regex(?lemma,'[();,]'))}
order by lcase(?lemma)
Senses and sense descriptions
#this lists entries that have senses and sense descriptions
select ?entry ?lemma ?posLabel (group_concat(concat(str(?sensegloss)," (",lang(?sensegloss),")");SEPARATOR="; ") as ?sense_descriptions)
where {
?entry a ontolex:LexicalEntry;
wikibase:lemma ?lemma;
wikibase:lexicalCategory [rdfs:label ?posLabel] . filter(lang(?posLabel)="en")
?entry ontolex:sense [skos:definition ?sensegloss].
} group by ?entry ?lemma ?posLabel ?sense_descriptions
limit 100 # remove the limit and get all entries that have sense descriptions
Dialectal lemma variants
#defaultView:BarChart
#This shows the distribution of dialectal lemma variants
PREFIX qp: <https://qichwa.wikibase.cloud/prop/>
PREFIX qps: <https://qichwa.wikibase.cloud/prop/statement/>
PREFIX qpq: <https://qichwa.wikibase.cloud/prop/qualifier/>
SELECT ?dialect ?dialectLabel (count (?variant) as ?variants)
WHERE { ?lemma qp:P16 [ qps:P16 ?variant ; qpq:P17 ?dialect ] .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?dialect ?dialectLabel ?variants ORDER BY DESC(?variants)
Part of speech (lexical category)
Course-grained (lexical category superclasses)
#defaultView:BarChart
PREFIX qdp: <https://qichwa.wikibase.cloud/prop/direct/>
select ?pos ?posLabel (count(?entry) as ?count)
where {
?entry a ontolex:LexicalEntry;
wikibase:lemma ?lemma;
wikibase:lexicalCategory ?pos_finegrained.
?pos_finegrained qdp:P4 ?pos. ?pos rdfs:label ?posLabel . filter(lang(?posLabel)="en")
} group by ?pos ?posLabel ?count
order by desc(?count)
Fine-grained (lexical categories as in Runasimi Dictionary)
#defaultView:BarChart
#this shows pos distribution (fine-grained categories as in Runasimi dictionary)
select ?pos ?posLabel (count(?entry) as ?count)
where {
?entry a ontolex:LexicalEntry;
wikibase:lemma ?lemma;
wikibase:lexicalCategory ?pos. ?pos rdfs:label ?posLabel . filter(lang(?posLabel)="en")
} group by ?pos ?posLabel ?count
order by desc(?count)