Comments (7)
Thank you for your suggestion.
Answering to your question:
isbnlib.metadata
returns a dictionary with keys ('ISBN-13', 'Title', 'Authors', 'Publisher', 'Year', 'Language') and values as strings (a list of strings for the 'Authors').
These are the common fields to all providers and are fixed in the library. Even then, 'Language' is NOT used with the builtin 'bibformatters' because for bibliographic citations 'Language' is the language in wich the book is written, but that is NOT the meaning of 'Language' in ISBN regestries (is usually the main language of the publisher's country)!
I will take a look at this CSL format and see if it make sense to install it in the core library as a new block in isbnlib/dev/_fmt.py
(probably yes if it is widely used) or as an add-in.
But please, you are free to have a go!
from isbnlib.
From a rush consultation to csl-json, it seems that in order to implemente a formatting in CSL is only necessary to create a new template in isbnlib\dev\_fmt.py
like:
csl = r'''{"type":"book", "id":"$ISBN", "title":"$Title", "issued": {"raw": "$Year"}, "ISBN":"$ISBN", "publisher":"$Publisher", "author": [$AUTHORS]}'''
with pos-processing for $AUTHORS
elif name == 'csl': AUTHORS = ', '.join('{"literal": "$"}'.replace("$", a) for a in authors)
Is this a correct CSL-JSON data fragment and is enough?
from isbnlib.
Agree with the general strategy. A few points / questions:
-
You probably want to set
date_parts
rather thanraw
for issued. It'd be like{'date_parts': [[year]]}
. It's an odd format, but that's what most styles will implement. -
I'm not a fan of hardcoding the JSON structure. Instead, I'd construct a dict/OrderedDict and then
json.dumps
it. For example, will the implementation above escape problematic characters in the fields? -
Are all values guaranteed to be populated? If not, it's better to omit that key-value pair entirely, rather than have a blank value.
-
Setting
URL
may also be nice... is there a way to get a URL for an ISBN?
from isbnlib.
Here is my reply point-by-point:
- Change to
date_parts
its OK, especially if that is what most styles implement. - Hardcoding JSON (and other formats) was an option to simplify the production of small data fragments formatted in some popular bibliographic formats. For most casual users that is all they need.... however, the main goal wasn't formatting but provide metadata. You can always format the data from
isbnlib.metadata
as you which. Some cleaning is done in the data to avoid some obvious problematic cases, but no validation is attempted. - Some fields are mandatory but no filtering is done in order to 'clean' the empty ones.
- The
URL
is very problematic in order to get consistency... by default the metadata for each ISBN is obtained from several providers! Some don't provide anURL
and in some cases theURL
is not deterministic... it depends on the region and the user (e.g. Google Books)!
But maybe it is not a good idea to implement this in the core of isbnlib
, but do a plug-in because:
- formatting is not the main goal of the library,
isbnlib
already supports a general purpose BibJSON format and with some simple pos-processing you can get CSL-JSON from it.
from isbnlib.
Anyway, I have already implemented a 'simple' version to support 'CSL-JSON'! It produces things like this:
{"type":"book",
"id":"9780321534965",
"title":"The Art Of Computer Programming",
"author": [{"literal": "Donald Ervin Knuth"}],
"issued": {"date_parts": [["2008"]]},
"ISBN":"9780321534965",
"publisher":"Addison-Wesley"}
Is this a valid CSL document? Is this useful?
from isbnlib.
@xlcnd that would be useful. If you open a PR, I'd be happy to review. The only issue that I see presently is that 2008 should not be quoted. It should be an int.
from isbnlib.
Its already in the dev branch. Year is now an int.
from isbnlib.
Related Issues (20)
- `mask` fails for issued ISBN HOT 2
- Time to drop Python 3.6? HOT 1
- [Enhancement] `meta` be able to ignore ISBNNotConsistentError HOT 3
- ISBN from words throttling HOT 5
- Add a network pytest mark for tests that use the network HOT 1
- error when using meta(isbn, service='openl') HOT 1
- Books in your language
- Basic Template
- If source returns Unimarc
- If source returns xml from SRU protocol
- Instructions for release
- Dutch Books
- French books
- Portuguese books
- Spanish books
- Italian books
- German books
- Wikipedia provider
- Library of Congress (US)
- Metadata function 'classify' doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isbnlib.