larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
222 stars 30 forks source link

Wikidata importer fails on special value types unknown and no-value #167

Closed nichtich closed 5 years ago

nichtich commented 5 years ago

If a property such as author (P50) is set to no-value, the Wikidata importer will fail with an error ("Cannot read property 'value' of undefined"). The special case "somevalue" must be treated specially because it the value may still be given as qualifier. See for an example https://www.wikidata.org/wiki/Q57926700 where the editors (P98) are only known by name (qualifier named as (P1810))

larsgw commented 5 years ago

I'll implement this after 0.4.0 together with a bunch of the other mapping things, as I'm busy this week. The release will mainly be a re-organisation of the project, and most code-related preparations are already in place. A completely backwards-compatible package will remain in place right here, so that shouldn't be a problem. It's planned for nest week, depending on how far I get with everything. I hope that's okay? I'm really looking forward to finally start working normally again on these relatively contained things.

larsgw commented 5 years ago

Just a small update on the progress of 0.4.0: I'm about halfway done with setting up a lerna repository with all the components. Progress can be tracked here. I haven't decided on a repo name yet*, so the repository itself is not available yet, but there isn't much going on right now.

* citation-js/core, citation-js/citation-js, citation-js/citation.js?

nichtich commented 5 years ago

Interesting, I did not know about lerna before. This makes sense but adds another layer of complexity to the already intimidating package.json. About naming I'd stick to the established name citation-js for the umbrella package and add suffixes for individual packages, e.g. citation-js-cli, citation-js-bibtex... (but no ...-other).

larsgw commented 5 years ago

This makes sense but adds another layer of complexity to the already intimidating package.json.

Which package.json? Either way, this package will be exactly the same on the outside (same API, same way of importing, same URLs, same name, etc.) but just be a wrapper on the "inside".

add suffixes for individual packages, e.g. citation-js-cli, citation-js-bibtex...

The individual packages will be available on npm under a scope as @citation-js/..., with plugin- prefixed to distinguish plugins from other packages. My repo naming comment is about GitHub; I have the citation-js organisation now, so github.com/citation-js/citation-js would be double, but github.com/citation-js/citation.js can be annoying with forks and github.com/citation-js/core is just untrue. I agree the first is the best option though.

(but no ...-other).

The -other package could be named "common" or "shared"; it's just basic functionality like JSON and URLs, and some shortcuts (HTML & jQuery elements). It will be included by default, as many other plugins depend on it, mainly the first parts.

larsgw commented 5 years ago

I see you opened an issue on this in wikidata-sdk too (https://github.com/maxlath/wikidata-sdk/issues/41). Can't do much with this at the moment:

https://runkit.com/larsgw/wdk-and-somevalue-novalue

nichtich commented 5 years ago

Yes, better wait until the simplification of special values is supported by wikidata-sdk.

larsgw commented 5 years ago

Well, I made a mistake in the commit message of https://github.com/citation-js/citation-js/commit/664644b39b078010b272ebd25c3f423d3be98868 but the next release should support named as so as soon as the simplification of special values while keeping qualifiers is fixed, it should work. I'll add a test case soon too.

larsgw commented 5 years ago

The item you provided works now, and I added some cases for other cases (novalue/somevalue but no qualifiers, novalue/somevalue on other properties) for which I haven't been able to find actual examples (which also means I haven't been able to test it properly).