wikidata

Wikipedia API and SPARQL in a single query

梦想与她 提交于 2019-12-10 16:08:36
问题 I need to search for Wikipedia pages that contain some specific words in their full text . To improve the results I want to limit the results to pages describing entities that are instances of a specific entity. For searching the full text I can use the Wikipedia APIs, using the query action and the search generator . For filtering instances of a given entity I can use the Wikidata APIs and a SPARQL query. Is there a way to execute both operations in a single query that applies both filters?

Find which direct property applied in a SPARQL query

﹥>﹥吖頭↗ 提交于 2019-12-10 14:56:15
问题 I have a list of properties I want to apply to a specific entity mathematics: wd:Q395 . In this case: instanceOf: 'wdt:P31' subclassOf: 'wdt:P279' The results are: Mathematics is instance of academic discipline and Mathematics is subclass of exact science and formal science Instead of making two different queries I would like to make them all at once: SELECT ?field ?fieldLabel ?propertyApplied WHERE { wd:Q395 wdt:P31 | wdt:P279 ?field. SERVICE wikibase:label { bd:serviceParam wikibase

How do you find the list of wikidata (or freebase or DBpedia) topics that a text is about?

你说的曾经没有我的故事 提交于 2019-12-10 10:44:37
问题 I am looking for a solution to extract the list of concepts that a text (or html) document is about. I'd like the concepts to be wikidata topics (or freebase or DBpedia). For example " Bad is a song by Mikael Jackson " should return Michael Jackson (the artist, wikidata Q2831) and Bad (the song, wikidata Q275422). As this example shows, the system should be robust to spelling mistakes (Mikael) and ambiguity (Bad). Ideally the system should work across multiple languages, it should work both

Fuzzy entity query in Wikidata with Sparql times out

五迷三道 提交于 2019-12-08 08:30:30
I'm trying to do a fuzzy (ie.. partial or case-insensitive) entity label lookup in Wikidata with Sparql (via the online endpoint). Unfortunately these return a " QueryTimeoutException: Query deadline is expired. " I'm assuming this is because the query is returning too many results to run through the filter in Wikidata's 1 minute timeout. Here's the specific query: def findByFuzzyLabel(self, item_label): qstring = ''' SELECT ?item WHERE { ?item rdfs:label ?label . FILTER( lcase(str(?label)) = "%s") } LIMIT 20 ''' % (item_label) results = self.query(qstring) Is there a way to do a partial

Wikidata - request limit for SPARQL queries

喜夏-厌秋 提交于 2019-12-08 03:47:09
问题 Is there a limit for queries on Wikidata (SPARQL queries only, not editing)? I couldn't find any official documentation about this. I wonder how strong queries are limited per minute/hour (and per IP-address). 回答1: Yes, there are limits. Single query is currently limited to 1 minute runtime. Docs are here: https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual Also, each IP is limited to 5 concurrent requests currently. There's no limit on how many sequential requests can be

Extract related articles in different languages using Wikidata Toolkit

放肆的年华 提交于 2019-12-07 13:05:40
I'm trying to extract interlanguage related articles in Wikidata dump. After searching on the internet, I found out there is a tool named Wikidata Toolkit that helps to work with these type of data. But there is no information about how to find related articles in different languages. For example, the article: "Dresden" in the English language is related to the article: "Dresda" in the Italiano one. I mean the second one is the translated version of the first one. I tried to use the toolkit, but I couldn't find any solution. Please write some example about how to find this related article. you

How can I query wikidata with a freebase id from a youtube video?

六月ゝ 毕业季﹏ 提交于 2019-12-07 10:31:43
问题 I am using the youtube API to retrieve the freebase topic details of particular videos. Since freebase is closing down how do I use wikidata to query for a specific topic id? For example the following topic id /m/0181lj should give the following information I have tried playing with the wikidata REST API but I haven't found a request which matches what I need. Update Freebase have released the Knowledge graph which allows you to query via topicId as so https://kgsearch.googleapis.com/v1

SPARQL: How to obtain label in available languages if first option is not available

[亡魂溺海] 提交于 2019-12-07 05:23:21
问题 If a Wikidata resource returned by my query has no available label in the language I filtered for I obtained an empty cell. SELECT * WHERE { ?country wdt:P31 wd:Q6256. ?country rdfs:label ?country_name FILTER(LANG(?country_name) = 'jbo'). } link How to request to have a label returned in one of any of the available languages if the first language fails? 回答1: First, prefer langMatches for checking language tags. This is especially important in your case, since you might want, for instance, a

What are values starting with “t” and how to ignore them for counting

喜你入骨 提交于 2019-12-06 15:09:39
I am trying to query the frequency of certain attributes in Wikidata , using SPARQL. For example, to find out what the frequency of different values for gender is, I have the following query: SELECT ?rid (COUNT(?rid) AS ?count) WHERE { ?qid wdt:P21 ?rid. BIND(wd:Q5 AS ?human) ?qid wdt:P31 ?human. } GROUP BY ?rid I get the following result: wd:Q6581097 2752163 wd:Q6581072 562339 wd:Q1052281 223 wd:Q1097630 68 wd:Q2449503 67 wd:Q48270 36 wd:Q44148 8 wd:Q43445 4 t152990852 1 t152990762 1 t152990752 1 t152990635 1 t152775383 1 t152775370 1 t152775368 1 ... I have the following questions regarding

How to get Wikidata labels by ID using SPARQL?

☆樱花仙子☆ 提交于 2019-12-06 01:27:13
问题 How can I get the labels in English or any other language in Wikidata by ID using SPARQL endpoint? 回答1: Suppose wd:Q146190 is your wikidata entity ID get the label in a specific language of your specific entity ID: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX wd: <http://www.wikidata.org/entity/> SELECT * WHERE { wd:Q146190 rdfs:label ?label . FILTER (langMatches( lang(?label), "EN" ) ) } LIMIT 1 live example in english live example in german get all the labels in any language