Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to query logo_image #17

Closed
bricemaurin opened this issue Nov 6, 2015 · 4 comments
Closed

Unable to query logo_image #17

bricemaurin opened this issue Nov 6, 2015 · 4 comments

Comments

@bricemaurin
Copy link

I'm trying to get the logo_image of some companies. For example, Apple.

First, I get Apple Item

apple = Wikidata::Item.find_by_title 'Apple Inc.'
=> <Wikidata::Item id: Q312, title: "Apple Inc."> 

But when trying to get its logo_image, i get an error:

apple.logo_image
NoMethodError: undefined method `logo_image' for <Wikidata::Item id: Q312, title: "Apple Inc.">:Wikidata::Item

The logo exists: https://www.wikidata.org/wiki/Q312

How should i request it ?

Thanks !

@klacointe
Copy link
Owner

This property is missing from mapping: https://github.com/klacointe/wikidata-client/blob/master/config/mapping.yml but you can request it using the wikidata property code P154:

% bundle console
Resolving dependencies...
irb(main):001:0> require 'wikidata'                                                                                                                            
=> true
irb(main):002:0> apple = Wikidata::Item.find_by_title 'Apple Inc.'                                                                                             
=> <Wikidata::Item id: Q312, title: "Apple Inc.">
irb(main):003:0> apple.property('P154')
=> #<Wikidata::Property::CommonsMedia:0x0055a24fd7bb70 @property=#<Hashie::Mash id="q312$5B574C40-5C57-4246-A143-F8D32584CE81" mainsnak=#<Hashie::Mash datatype="commonsMedia" datavalue=#<Hashie::Mash type="string" value="Apple logo black.svg"> property="P154" snaktype="value"> rank="normal" type="statement">>
irb(main):004:0> apple.property('P154').url
=> "https://upload.wikimedia.org/wikipedia/commons/f/fa/Apple_logo_black.svg"

@bricemaurin
Copy link
Author

the "logo_image" is in the mapping: https://github.com/klacointe/wikidata-client/blob/master/config/mapping.yml , that's weird

but I'll use the property instead, that's perfect

Thanks !

@klacointe
Copy link
Owner

Ok I understand, I forgot to push a new version on rubygems with last mapping updates.

You can use https://rubygems.org/gems/wikidata-client/versions/0.0.9

@bricemaurin
Copy link
Author

Perfect ! It's working fine now.

Thanks Kevin ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants