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
219 stars 30 forks source link

RIS input - publishing place not returned for type book #214

Closed itsmhuang closed 2 years ago

itsmhuang commented 3 years ago

So I'm trying to parse some RIS and everything I need is returned except the publishing place for type book.

citation-js: 0.5.0 OS: macOS Catalina node: 12.16.2

My RIS:

TY  - BOOK
TI  - The boy, the mole, the fox and the horse
AU  - Mackesy, Charlie
CN  - PN6737.M35 B69 2019
CY  - New York, NY
DA  - 2019
PY  - 2019
DP  - Library of Congress ISBN
ET  - First HarperOne hardcover
PB  - HarperOne
SN  - 978-0-06-297658-1
N1  - <p>"First published in 2019 by Ebury."</p>
KW  - Animals 

My code:

const Cite = require('citation-js');
const result = new Cite(risInput);
const resultFormatted = result.format('data', { format: 'object' });
console.log(resultFormatted);

The output:

[
    {
        author: [{ family: 'Mackesy', given: 'Charlie' }],
        'call-number': 'PN6737.M35 B69 2019',
        issued: { 'date-parts': [[2019]] },
        edition: 'First HarperOne hardcover',
        keyword: 'Animals',
        note: '<p>"First published in 2019 by Ebury."</p>',
        publisher: 'HarperOne',
        ISBN: '978-0-06-297658-1',
        title: 'The boy, the mole, the fox and the horse',
        type: 'book',
        _graph: [...],
        id: 'temp_id_7104361950652149',
    }
]

I expect CY to be kept and parsed as the publishing place, but it's not included in the object. I did skim through the code a bit and found this:

    "source": "CY",
    "target": "event-place",
    "when": {
      "source": {
        "TY": [
          "CONF",
          "CPAPER"
        ]
      },
      "target": {
        "type": [
          "paper-conference"
        ]
      }
    }
  },

Which looks like CY will only be returned if the source is CONF or CPAPER. But it should also be returned for BOOK. I can submit a pull request if this the only change that's needed.

larsgw commented 3 years ago

Thank you for reporting this! Looking at the code I used to define those mappings it seems like I simply did not map publisher-place. I think I made a distinction between place of publication and location of publisher for some reason. I will look into this. The code you cited is actually about mapping CY to event-place (conference venue), which is not what you need here (you want publisher-place).

larsgw commented 3 years ago

Where did you get this RIS by the way? Could I add it to https://github.com/citation-js/ris-examples?

itsmhuang commented 3 years ago

Ah ok, mapping CY to publisher-place would be great.

Just something I made. You can go ahead and add it :)