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

SPARQL request failed #52

Closed jaygray0919 closed 1 year ago

jaygray0919 commented 1 year ago

previously wdtaxonomy worked perfectly wdtaxonomy -V 0.6.6

recently I upgraded to Node.js v19.6.0 now when I run, for example: wdtaxonomy -c Q35120

I see: SPARQL request failed

Have I made an error (forgetting something since the last time I successfully used wdtaxonomy)? Is some dependency causing this error? Is there a work-around? Do you need more information from me to debug this issue?

Thanks for your help here. /jay

jaygray0919 commented 1 year ago

Update: As you might expect, RunKit operates correctly I will down-release my local node.js version to an earlier working release to isolate the issue. /jay

jaygray0919 commented 1 year ago

OK, i've down released to node.js 6.17.1 (confirmed using node -v) When I run: wdtaxonomy Q634 the error message is: SPARQL request failed

i reinstalled wdtaxonomy using: npm install -g wikidata-taxonomy

now wdtaxonomy -V echoes 0.6.7 but still see the error message is: SPARQL request failed

Any suggestions?

jaygray0919 commented 1 year ago

Here is the program I run on RunKit

var wikidataTaxonomy = require("wikidata-taxonomy")
const { queryTaxonomy } = require('wikidata-taxonomy')

var options = { lang: 'en', brief: true }
queryTaxonomy('Q634')
.then(taxonomy => {
  taxonomy.concepts.forEach(concept => {
    var qid = concept.notation[0]
    var label = (concept.prefLabel || {}).en || '???'
    console.log('%s %s', qid, label)
  })
})
.catch(error => console.error("E",error))

this fails when running Node 6.17 when I switch to Node 16, the results are not the expected results as advertised on https://npm.runkit.com/wikidata-taxonomy

FYI

nichtich commented 1 year ago

Running wdtaxonomy Q634 via command line works with wikidata-taxonomy 0.6.7 on a fresh node v19.6.0 on my machine but wdtaxonomy Q35120 also quits with SPARQL request failed. I bet this is a query timeout. You can omit some information, e.g. only get direct children with wdtaxonomy -c Q35120 to reduce the query time.

jaygray0919 commented 1 year ago

Thank you for the quick response. I removed node.js and then reinstalled. I am running v18.14.0 Then I reinstalled wdtaxonomy. This query works perfectly: wdtaxonomy -c Q35120 This query also works perfectly: wdtaxonomy Q634

Me thinks that juggling node.js versions and nvm can corrupt the overall node environment. Since first installing wd-taxonomy I've also installed other node.js packages - some of which depend on specific releases. They are gone now. The clean environment works as advertised.

I realize that you are packaging specific SPARQL queries for your users. When I ran into the problems above, I reverted to writing a SPARQL program that created the child-based tree. My program does not work as well as wdtaxonomy with its options! It's quite easy to follow the parents with WD properties - but getting the children of a parent is a real challenge.

Thank you for your assistance here. /jay

jaygray0919 commented 1 year ago

Also: the RunKit instance above is identical to the node.js CLI command: wdtaxonomy Q634 The result is "as advertised". But it's interesting that node version 6.17 failed but node version 16 is correct. Go figure ...