Zubair Ahmed
Zubair Ahmed

Reputation: 17

how to use Reality Gem to query wikidata to find properties such as part_of & Instance_of

I'm using Reality Gem to Query Wikidata, using this code below. But it gives nil output. i've checked using result.methods command but i dont't see any method to view "part_of" or "instance_of" property values

require 'reality'    
result = Reality::Entity("Enterprise JavaBeans")
result.part_of
=> nil

However on wikidata page these properties are available:

https://www.wikidata.org/wiki/Q742961

Can someone help me please?

Upvotes: 0

Views: 120

Answers (1)

Lucas Costa
Lucas Costa

Reputation: 1129

I don't know why this error is happening.
I guess it's because the document structures on Wikidata and Wikipedia aren't the same.

But you can get around with the following hacky:

require 'reality'

w = Reality::Wikidata::Entity.one_by_id('Q742961')
e = Reality::Entity::WikidataPredicates.parse(w)
e[:part_of]

Upvotes: 1

Related Questions