wikidata

Fuzzy entity query in Wikidata with Sparql times out

眉间皱痕 提交于 2020-02-02 15:14:48
问题 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)) =

Extract related articles in different languages using Wikidata Toolkit

随声附和 提交于 2020-01-23 17:57:07
问题 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,

Wikidata content negotiation

瘦欲@ 提交于 2020-01-22 00:49:38
问题 I was wondering why Wikidata content negotiation results with more than one entities in the file. For instance P2044 in the browser http://www.wikidata.org/entity/P2044.nt gives me triples also about Q6452016 entity: http://www.wikidata.org/entity/Q6452016 I would expect either triples about P2044 or document metadata. Thanks in advance. 回答1: There are many options of what to produce in an RDF output (as well as there is no standard on what to return in a DESCRIBE query result). In Wikidata,

How to get Wikipedia page from Wikidata Id?

大憨熊 提交于 2020-01-14 08:00:29
问题 How to get Wikipedia page (in a particular language, say French) from the Wikidata Id (ex: Q19675)? The question seems obvious but strangely, I find nothing on the web. I'm looking for a url command that I could use with requests Python module, something like: url = "https://www.wikidata.org/w/api.php?action=some_method&ids=Q19675" r = requests.post(url, headers={"User-Agent" : "Magic Browser"}) Someone can help me? 回答1: You have to use MediaWiki API with action=wbgetentities : https://www

Get alias values from wikidata for a given property?

对着背影说爱祢 提交于 2020-01-14 03:25:15
问题 For a given property like 'occupation (P106)', I want to retrieve all its aliases like: profession, job, work, career, employment, craft. All of this is present on the properties wikidata page, under 'Also known as'. How can I go about retrieving this using SPARQL? I tried using the following query. SELECT ?predicate ?object WHERE { wdt:P106 wdt:P1449 ?predicate . //Nickname wdt:P106 wdt:P734 ?predicate . //Family Name wdt:P106 wdt:P735 ?predicate . //Given Name wdt:P106 skos:altLabel

Access JSON item when parent key name is unknown

天大地大妈咪最大 提交于 2020-01-14 00:35:11
问题 I’m requesting JSON from Wikipedia’s API at http://en.wikipedia.org/w/api.php?action=query&prop=description&titles=WTO&prop=extracts&exsentences&explaintext&format=json The response looks like this: { "query": { "pages": { "ramdom_number_here": { "pageid": ramdom_number_here, "ns": 0, "title": "Hello", "extract": "Hello world! Enchanté to meet you" } } } } Given that ramdom_number_here changes each request (so we don't know it), how can extrac or title ’s data be accessed? 回答1: Use Object

Querying property without value with SPARQL in WikiData

痞子三分冷 提交于 2020-01-06 05:50:11
问题 I have got a list of 1200 geographic enties like cities, lakes oder mountains as strings. I would like to enrich these enties with the authority file WikiData ID. This works but as result I get sometimes more than one WikiDataID suggestion. I need to define the right one by the apperance of an country in the Statements. As an example I tried the city Karlsruhe. For the string "Karlsruhe" I get three results. But I want just one specific WikiData ID (in this case: https://www.wikidata.org/wiki

Make filtering people by birthYear and deathYear criteria more performative in SPARQL query

£可爱£侵袭症+ 提交于 2020-01-05 06:17:56
问题 I want to find instances of scientists who both were born and died in prime-numbered years. Building on a previous discussion at this URL, I devised the following query, which is unwieldy and times out: SELECT ?birthYear ?deathYear ?scientist ?scientistLabel WHERE { { select ?value1 { ?number wdt:P31 wd:Q49008. ?number wdt:P1181 ?value1 filter(?value1 < year(now())) } } { select ?value2 { ?number wdt:P31 wd:Q49008. ?number wdt:P1181 ?value2 filter(?value2 < ?value1) } } ?scientist wdt:P106 wd

Use Jena to query wikidata

前提是你 提交于 2020-01-03 08:56:12
问题 Currently, Wikidata has a SPARQL endpoint "https://query.wikidata.org/", I would like to query this site using Jena (3.0.1), I use the following code but I got an error message " Endpoint returned Content-Type: text/html which is not currently supported for SELECT queries ". Is there a way to solve it? the same code works fine with dbpedia. Thanks queryString = "PREFIX bd: <http://www.bigdata.com/rdf#>\n" + "PREFIX wikibase: <http://wikiba.se/ontology#>\n" + "PREFIX wdt: <http://www.wikidata

How to represent this statement in RDF?

左心房为你撑大大i 提交于 2020-01-03 05:56:08
问题 My iPhone 6's screen size is 6 inches and red color. Vocabulary are the following: iPhone 6 screen size 6 inches color red Questions: 1) How to link 'iPhone 6' node with the 'screen' node? 2) 'screen' has two properties: 'size' & color Possible relationships: 1) [iPhone6, screen, ?] what's the object here? 2) [screen, color, red] [screen, size, 6 inches] Is this appropriate to express as Compound Value Type in KB like Freebase? Reading the Freebase's documentation, it seems CVT is intended to