gnames / gnparser

GNparser normalises scientific names and extracts their semantic elements.
MIT License
38 stars 4 forks source link

Node.js bindings #181

Closed tobymarsden closed 2 years ago

tobymarsden commented 3 years ago

Hi @dimus

I put together Node.js bindings for gnparser. My C is worse than my golang so it's... not exactly great for now, but it's dead simple to use and extremely fast: binding to your fabulous shared C library is obviously dramatically more performant than exec'ing to the command line from Node.

Literally just:

const parser = require('gnparser')
const res = parser.parse('Drosera intermedia') // parser.parse(arrayOfStrings) works too
console.log(res)
{
  parsed: true,
  quality: 1,
  verbatim: 'Drosera intermedia',
  normalized: 'Drosera intermedia',
  canonical: {
    stemmed: 'Drosera intermed',
    simple: 'Drosera intermedia',
    full: 'Drosera intermedia'
  },
  cardinality: 2,
  details: { species: { genus: 'Drosera', species: 'intermedia' } },
  words: [
    {
      verbatim: 'Drosera',
      normalized: 'Drosera',
      wordType: 'GENUS',
      start: 0,
      end: 7
    },
    {
      verbatim: 'intermedia',
      normalized: 'intermedia',
      wordType: 'SPECIES',
      start: 8,
      end: 18
    }
  ],
  id: 'f91c4174-1705-5c07-831d-eb2663bc5178',
  parserVersion: 'nightly-1-g03eec2d'
}

I plan to publish it to npm but wanted to check with you about naming. I don't want to tread on toes or imply endorsement, and don't have any strong feelings. As it's a simple wrapper I'd be happy to go with biodiversity or gnparser on npm (node-biodiversity etc is frowned upon now, apparently), or if that's confusing I can pick something more esoteric (ideas welcome!).

Alternatively if you want control under the auspices of gnames, that's fine too.

dimus commented 3 years ago

@tobymarsden it is fantastic you adjusted gnparser for npm, I think gnparser name is clear and straightforward, please just point to Go code in readme, so it is clear where engine comes from, biodiversity gem was originally planned as an analog of bioruby, bioperl etc, but for biodiversity. Later I decided on a small atomic modules approach, but the name stuck

dimus commented 3 years ago

@tobymarsden, please let me know when you publish it to npm, I would like to make a blog post about it and new version of biodiversity gem.

tobymarsden commented 2 years ago

@dimus Well, this has been a royal pain to get working on Mac, though straightforward on Linux. It's here:

https://www.npmjs.com/package/gnparser

If there's anything amiss in the license, readme or links to GNParser please let me know and I'll correct immediately.

I now need to set up CI integration so we can (nearly) automate builds when GNParser is updated, and add Windows support.

tobymarsden commented 2 years ago

Repo here: https://github.com/amazingplants/node-gnparser

dimus commented 2 years ago

Fantastic @tobymarsden, thanks for letting me know! I will add a link in gnparser readme