Open kobrafarshidi opened 1 year ago
Hello,
if I understand correctly you'd like to search for all entities in Wikidata given a label. If so, please have a look at the following query. In the Wikidata Sparql Service, you can generate code snippets in Python.
Using Sparql one can do the following:
SELECT distinct ?item ?itemLabel ?itemDescription WHERE{
?item ?label "Michael Jackson"@en.
?article schema:about ?item .
?article schema:inLanguage "en" .
?article schema:isPartOf <https://en.wikipedia.org/>.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Hi @Patimir Thank you so much for your great reply. Actually, yes, I'd like to search in all of a knowledge and your code is the same, but I have 2 questions yet. I would appreciate if you helped me with this.
1)Is there a way to upgrade this source code to return most relevant labels? (Because when I mention a label that it unknown it can't be most relevant for example when I write qury it can't find any things, but I was hoped to find in knowledge and return query)
2) Is there a way to upgrade this source code to return most score in all of returns of labels (for example for this source it returns the following, but it is unknow that which of them is the best result)
{'itemLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Michael Jackson'}} {'itemLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Mike Jackson'}} {'itemLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Michael R. Jackson'}} {'itemLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Mariléia dos Santos'}}
3) How can I return only just label? (Because when I convert this code to python it returns {'itemLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Michael Jackson'}}
and I want return only 'value': 'Michael Jackson'
)
Thank you so much @Patimir
Hi @Patimir Thank you for your great source and video in youtube. I encounter a question and can't solve my problem. I'd be appreciate if you could help me I understand your source code, but my problem is similar your code. I want to give a word to knowledge base, then that knowledge base compares that word with all of wikipedia's words and finally output will be return whether most relevant word or same word (if not be incorrect). for example, you can use that with SPARQL service (give a word and search in all of the knowledge base) but how to do that? I know I can do that with below source code but it search only in one page. I can't find anywhere similar source code to search in all of knowledge base.