gnparser

gRPC client to gnparser project

Overview

gnparser is a Ruby gem that allows to parse scientific names extremely fast using remote gRPC method calls to gnparser written in Go.

Install

gem install gnparser

Usage

Download the latest version of Go gnparser, and start it on your local machine as a grpc server:

gnparser -g 8778

Now you will be able to use Ruby gnparser with its default settings.

require 'gnparser'
gnp = GNparser::Client.new

Output format

gem supports the following formats:

compact : JSON output in one line. This is the default format.

pretty : Pretty JSON output.

simple : Pipe-separated string where the fiels are, id, verbatim name, canonical form, extended canonical form, authorship, year, quality of parsing.

debug : Abtract Syntax Tree of the parsed result.

Parse one name

res = gnp.parse('Puma concolor L.')
puts res.value
puts res.error

For non-default format:

res = gnp.parse('Puma concolor (Linn.)', :pretty)
...
res = gnp.parse('Puma concolor (Linn.)', 'pretty')
...
res = gnp.parse('Puma concolor (Linn.)', 'simple')
...
res = gnp.parse('Puma concolor (Linn.)', :simple)
...

Parse an array of names

names = ['Plantago major L.', 'Homo sapiens Linn. 1758', 'Bubo bubo']
res = gnp.parse_ary(names, :pretty)

Parse names from a file

File should have one name string per line.

path = File.join(__dir__, "path", "to", "names.txt")
res = gnp.parse_file(path, :compact)