nichtich / wikidata-taxonomy

command-line tool to extract taxonomies from Wikidata
https://www.npmjs.org/package/wikidata-taxonomy
MIT License
124 stars 11 forks source link

feature request #48

Open jaygray0919 opened 5 years ago

jaygray0919 commented 5 years ago

The reverse switch (-r) takes the query identifier and creates a reverse tree. In other words, the query is on line 1, the superclass is on line 2, etc. Would it be possible to provide an extra switch that would change the order of the 'reverse' switch? In other words, line 1 would be the root term (e.g. entity) and the tree would be constructed from the root to the query term. What is the reasoning for this? In order to see a large class structure, one might run a children (subclass) query from, for example, level 5 in the class tree. That query produces the target result where the 'top' term is the target and the children are listed below. Now I would like to integrate the subclass results with the superclasses for the search term. But the superclass query result is not in the same form/shape as the subclass query results. I have to do significant editing to reorder the superclass query to fit with the subclass query. A switch -rt (reverse top) would allow the simple combination of a superclass query and a subclass query.

Thanks for creating a really useful tool.

nichtich commented 5 years ago

could you add a small example of existing items and expected output?

jaygray0919 commented 5 years ago

will do. be back to you over the weekend with simple and more complex examples

jaygray0919 commented 5 years ago

here is the use case: build complete taxonomy for bos but starting from the root [biota (Q2382443)] is indiscriminate, even if SPARQL would process the query, and too large. so the starting point is bos using this query: Bos (Q237993); parent taxon (P171); wdtaxonomy Q237993 -P P171 which produces the following (abbreviated)

image

then wdtaxonomy Q237993 -P P171 -r produces (abbreviated) image

But to 'concatenate' (hook-up) the two structures, I need to manually reverse the parent results as follows: image

so the feature request is to provide a switch that produces (in the formal wdtaxonomy format) a structure like the last image. that feature would simplify the combination of results from wdtaxonomy parent and wdtaxonomy children into a single structure - from root to nodes.