shexjs / shex.js

shex.js javascript package
MIT License
58 stars 17 forks source link

can't parse Wikidata EntitySchema shex with shex-to-json #90

Open maxlath opened 3 years ago

maxlath commented 3 years ago

the following command

shex-to-json  https://www.wikidata.org/wiki/Special:EntitySchemaText/E233

fails with this error:

aborting: Error: error parsing JSON https://www.wikidata.org/wiki/Special:EntitySchemaText/E233: SyntaxError: Unexpected token P in JSON at position 0
    at parseShExJ (/some/project/node_modules/shex/lib/ShExLoader.js:274:14)
    at /some/project/node_modules/shex/lib/ShExLoader.js:103:14
    at tryCatcher (/some/project/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/some/project/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/some/project/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/some/project/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/some/project/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/some/project/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues (/some/project/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate (internal/timers.js:461:21)

It seems it can't parse the PREFIX keyword(?). This shex doesn't seem to be a problem for the python library. Any clue on what's wrong?

ericprud commented 3 years ago

Did you get shex-to-json from an npm package or from github? I just tried with github and it gave me 268 lines of JSON. If your answer is npm, was it https://www.npmjs.com/package/shex or https://www.npmjs.com/package/@shexjs/cli ? (The latter is newer; I should really re-package the former.)

maxlath commented 3 years ago

I got it from the shex module on npm; using @shexjs/cli fixes the problem indeed.

It comes with another (minor) issue though:

Error: Cannot find module '@shexjs/parser'
Require stack:
- /path/node_modules/@shexjs/loader/shex-loader.js
- /path/node_modules/@shexjs/cli/bin/shex-to-json

Running npm i @shexjs/parser solves that missing dependency problem

ericprud commented 3 years ago

according to CI tests, this should be resolved in the reorg-tests branch (top-level package.json doesn't have e.g. @shexjs/parser deps). I'll keep this open until I merge into main and publish new NPMs.