Skip to content

Node.js bindings #181

@tobymarsden

Description

@tobymarsden

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions