Ironholds / WikidataR

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

print functions #6

Closed chgrl closed 9 years ago

chgrl commented 9 years ago

As for me, it looks a little bit ugly to get such an output (using find_item("wikidata")):

[[1]]
[[1]]$id
[1] "Q2013"

[[1]]$url
[1] "//www.wikidata.org/wiki/Q2013"

[[1]]$aliases
[[1]]$aliases[[1]]
[1] "wikidata.org"

[[1]]$description
[1] "free knowledge database project hosted by Wikimedia and edited by volunteers"

[[1]]$label
[1] "Wikidata"

[[2]]
[[2]]$id
[1] "Q4847210"

[[2]]$url
[1] "//www.wikidata.org/wiki/Q4847210"

[[2]]$aliases
[[2]]$aliases[[1]]
[1] "Wikidata"

[[2]]$description
[1] "Wikimedia help page about Wikidata"

[[2]]$label
[1] "Wikimedia:Wikidata"

[[3]]
[[3]]$id
[1] "Q8478926"

[[3]]$url
[1] "//www.wikidata.org/wiki/Q8478926"

[[3]]$aliases
[[3]]$aliases[[1]]
[1] "Wikidata"

[[3]]$description
[1] "template used to test and demonstrate data retrieval from Wikidata according to the pattern {{#property:p47}}, where the context title box of Special:ExpandTemplates is used to specify the item about which data are retrieved"

[[3]]$label
[1] "Template:Wikidata"

[[4]]
[[4]]$id
[1] "Q9175810"

[[4]]$url
[1] "//www.wikidata.org/wiki/Q9175810"

[[4]]$aliases
[[4]]$aliases[[1]]
[1] "Wikidata"

[[4]]$description
[1] "Wikimedia project link template"

[[4]]$label
[1] "Template:Wikidata"

[[5]]
[[5]]$id
[1] "Q3938"

[[5]]$url
[1] "//www.wikidata.org/wiki/Q3938"

[[5]]$aliases
[[5]]$aliases[[1]]
[1] "Wikidata:Sandbox"

[[5]]$description
[1] "project page for making test edits (please use Wikidata's own sandbox or Q4115189 for Wikidata test edits)"

[[5]]$label
[1] "Sandbox"

[[6]]
[[6]]$id
[1] "Q4115189"

[[6]]$url
[1] "//www.wikidata.org/wiki/Q4115189"

[[6]]$aliases
[[6]]$aliases[[1]]
[1] "Wikidata BOX"

[[6]]$aliases[[2]]
[1] "Wikidata SandboxItem"

[[6]]$description
[1] "This is a sandbox for testing changes to items. Please be gentle with it. Feel free to change anything on this page! For testing links, try adding ones to userpages."

[[6]]$label
[1] "Wikidata Sandbox"

[[7]]
[[7]]$id
[1] "Q18667213"

[[7]]$url
[1] "//www.wikidata.org/wiki/Q18667213"

[[7]]$label
[1] "Wikidata property about Wikimedia categories"

[[8]]
[[8]]$id
[1] "Q19643892"

[[8]]$url
[1] "//www.wikidata.org/wiki/Q19643892"

[[8]]$label
[1] "Wikidata name property"

In rwikidata I worked plenty of time on print functions to get something like this:


    Wikidata search

Search term:         wikidata 
Number of results:   8 

Results:
1    Wikidata (Q2013) - free knowledge database project hosted by Wikimedia and edited by volunteers 
2    Wikimedia:Wikidata (Q4847210) - Wikimedia help page about Wikidata 
3    Template:Wikidata (Q8478926) - template used to test and demonstrate data retrieval from Wikidata according to the pattern {{#property:p47}}, where the context title box of Special:ExpandTemplates is used to specify the item about which data are retrieved 
4    Template:Wikidata (Q9175810) - Wikimedia project link template 
5    Sandbox (Q3938) - project page for making test edits (please use Wikidata's own sandbox or Q4115189 for Wikidata test edits) 
6    Wikidata Sandbox (Q4115189) - This is a sandbox for testing changes to items. Please be gentle with it. Feel free to change anything on this page! For testing links, try adding ones to userpages. 
7    Wikidata property about Wikimedia categories (Q18667213) 
8    Wikidata name property (Q19643892)

I gladly would provide my print functions for WikidataR and prepare a pull request, if desired. The new REST API is not going to change the data(structure) retrieved from Wikidata, is it? Otherwise I will wait for that to be around too.

Ironholds commented 9 years ago

It shouldn't! If it does I'm sure there'll be a bug report :). Happy to override print() as long as we don't override str() - stick it in a bug report and send it over!

Ironholds commented 9 years ago

@chgrl any chance you feel like taking a stab at this? :)