Ironholds / WikidataR

An R package for the Wikidata API
Other
53 stars 14 forks source link

Search for Item based on Property Value #25

Closed bshor closed 7 years ago

bshor commented 7 years ago

Hello,

I'm enjoying playing around with this great tool. One thing I'd love to do, but don't know how, is to find an item associated with a property, and find_item doesn't do what I need.

For example, I'd like to find Mike Enzi's (https://www.wikidata.org/wiki/Q432431) item given his Vote Smart ID, which is property P3344, with a value of 558.

So without knowing a name to search for, but only the Vote Smart ID of 558, I'd like to find the Mike Enzi item. But searching for 558 doesn't work.

Thanks!

Ironholds commented 7 years ago

Does the underlying API actually support this?

bshor commented 7 years ago

I'm not sure. Perhaps we need to use the R Wikidata Query package from @serenasignorelli ? It seems surprising that such a simple lookup would necessitate such a complex tool.

Ironholds commented 7 years ago

It makes more sense if you know wikidata is a hackjob of JSON blobs stored in normal wiki pages and so what query services actually do is grab the page content and strip out said JSON ;p.

serenasignorelli commented 7 years ago

My package actually doesn't do this, but I can play around a little bit to make it work. The only issue is that you can query for an item setting a property value, but the result will not necessarily be just one item but a list of items.

bshor commented 7 years ago

That would be awesome. There are lots of unique identifiers for many prominent individuals in Wikidata, and accessing them via those identifiers would be very helpful in many areas of inquiry. That would allow merging of data across many individual sources with Wikidata identifiers.

Getting a list is no problem, although I'd expect most lists to be size 1 because the whole idea of these identifiers is to be unique. They're not always unique though, and in those cases of course the list would be greater than 1.

serenasignorelli commented 7 years ago

Do you have a list of unique identifiers to test? I'm adding the function that allows to do this to the package. It works perfectly with Mike Enzi, but I would like to test it a little bit before releasing it.

bshor commented 7 years ago

Sure:

I can send you a fuller list privately.

Ironholds commented 7 years ago

Sounds like this is moving over to Serena's package, so unless we want to continue with the pattern of integrating both together can I suggest switching discussion over to that repo?

bshor commented 7 years ago

Agreed, thanks!