eldur / jwbf

Java Wiki Bot Framework is a library to maintain Wikis like Wikipedia based on MediaWiki.
http://jwbf.sourceforge.net/
Apache License 2.0
78 stars 33 forks source link

Get wikidata page ID for a wikipedia page #14

Closed GitTom closed 10 years ago

GitTom commented 10 years ago

I notice that there has been some discussion about adding some wikidata query functionality to jwbf:
https://github.com/Wikidata/Wikidata-Toolkit/issues/11

I think that sounds great, but I thought I should note that the existing jwbf API doesn't support getting the wikidata page id - which I think is the essential link between the two.

That id is displayed rather prominently in the page info of very wiki page, but I actually don't even know how to retrieve it via the mediawiki API (I don't see a prop for it). Assuming that there is a way, and I'm just missing it, I think it would be appropriate to add that to jwbf when adding wikidata support.

Otherwise one is stuck using dbpedia, or probably the wikidata API has a way to translate a wikipedia id (plus language) into its own page id - but that would have to be inefficient.

eldur commented 10 years ago

I assume it is better to ask at Wikidata-Toolkit or mediawikis api mailinglist for "How to get an itemid of a given wikipedia lemma?" or "How to map a given lemma to an itemid?"

GitTom commented 10 years ago

Ok, apparently wikidata page id can be retrieved for a wikipedia page like this:

https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&prop=pageprops&ppprop=wikibase_item&titles=Roy%20Dowling&format=json

So it could be added to any query, e.g. here a category query:
http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers&gcmtitle=Category:Culture&gcmnamespace=0&format=jsonfm&gcmlimit=max&prop=pageprops&ppprop=wikibase_item

You can close this (unless you think this functionality should be explicitly added to JWBF).

eldur commented 10 years ago

Thanks for your investigation, I've started a experimental branch with wikidata support.

See also #9

fhocutt commented 10 years ago

Would you consider making that branch public? I'd like to contribute to it if possible.

eldur commented 10 years ago

It is public, Wikidata Branch, but a few commits behind the master and fast forwarded to master (rebase) by me (merging may be difficult, if you use this branch directly; better cherry-pick this change).

fhocutt commented 10 years ago

Ok, then if I'm working on it should I just make a branch off of master and send pull requests from there?

eldur commented 10 years ago

Sounds good. I suggest we'll see what works best if you send a request.