DOI Gem Version Continuous Integration Status CodePolice Dependency Status

Parses taxonomic scientific name and breaks it into semantic elements.

WARNING, IMPORTANT!: Support for Ruby 1.8.7 IS DROPPED. Both biodiversity and biodiversity19 will be for Ruby > 1.9.1 and will be identical gems.

biodiversity19 is now deprecated and will not be updated anymore. You are strongly encouraged to change your dependencies from biodiversity19 to biodiversity

Follow biodiversity issues on


sudo gem install biodiversity

Example usage

As a command line script

You can parse file with taxonomic names from command line. File should contain one scientific name per line

nnparse file_with_names

The resuls will be put into parsed.json file in the current directory. To save results into a different file:

nnparse file_with_names output_file

As a socket server

If you do not use Ruby and need a fast access to the parser functionality you can use a socket server


parserver -h
Usage: parserver [options]

    -r, --canonical_with_rank        Adds infraspecies rank
                                     to canonical forms

    -o, --output=output              Specifies the type of the output:
                                     json - parsed results in json
                                     canonical - canonical form only
                                     Default: json

    -H, --host=host                  Specifies host as "",
                                     "localhost" etc.

    -p, --port=port                  Specifies the port number
                                     Default: 4334

    -h, --help                       Show this help message.

parserver --output=canonical

With default settings you can access parserserver via 4334 port using a socket client library of your programming language. You can find socket client script example in the examples directory of the gem.

If you want to check if socket server works for you:

#run server in one terminal

#in another terminal window type
telnet localhost 4334

If you enter a line with a scientific name -- server will send you back parsed information in json format.

To stop telnet client type any of end,exit,q, . instead of scientific name

$ telnet localhost 4334
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Acacia abyssinica Hochst. ex Benth. ssp. calophylla Brenan
{"scientificName":{"canonical":"Acacia abyssinica calophylla"...}}

As a library

You can use it as a library in Ruby, JRuby etc.

require 'biodiversity'

parser =

#to find version number

# to fix capitalization in canonicals
ScientificNameParser.fix_case("QUERCUS (QUERCUS) ALBA")
# Output: Quercus (Quercus) alba

# to parse a scientific name into a ruby hash
parser.parse("Plantago major")

#to get json representation

# to clean name up
parser.parse("      Plantago       major    ")[:scientificName][:normalized]

# to get only cleaned up latin part of the name
parser.parse("Pseudocercospora dendrobii (H.C. Burnett) U. \
Braun & Crous 2003")[:scientificName][:canonical]

# to get canonical form with infraspecies ranks
parsed = parser.parse("Seddera latifolia Hochst. & Steud. var. latifolia")
ranked = ScientificNameParser.add_rank_to_canonical(parsed)
parser = true)
ranked = parser.parse("Seddera latifolia Hochst. & Steud. var. latifolia")

# to get detailed information about elements of the name
parser.parse("Pseudocercospora dendrobii (H.C. Burnett 1883) U. \
Braun & Crous 2003")[:scientificName][:details]

Returned result is not always linear, if name is complex. To get simple linear representation of the name you can use:

parser.parse("Pseudocercospora dendrobii (H.C. Burnett) \
U. Braun & Crous 2003")[:scientificName][:position]
# returns {0=>["genus", 16], 17=>["species", 26],
# 28=>["author_word", 32], 33=>["author_word", 40],
# 42=>["author_word", 44], 45=>["author_word", 50],
# 53=>["author_word", 58], 59=>["year", 63]}
# where the key is the char index of the start of
# a word, first element of the value is a semantic meaning
# of the word, second element of the value is the character index
# of end of the word

'Surrogate' is a broad group which includes 'Barcode of Life' names, and various undetermined names with cf. sp. spp. nr. in them:

parser.parse("Coleoptera BOLD:1234567")[:scientificName][:surrogate]

What is "id" in the parsed results?

ID field contains UUID v5 hexadecimal string. ID is generated out of bytes from the name string itself, and identical id can be generated using any popular programming language. You can read more about UUID version 5 in a blog post

For example "Homo sapiens" should generate "16f235a0-e4a3-529c-9b83-bd15fe722110" UUID

Parse using several CPUs (4 threads seem to be optimal)

parser =
# will try to run 4 processes if hardware allows
array_of_names = ["Betula alba", "Homo sapiens"....]
# Output: {"Betula alba" => {:scientificName...},
# "Homo sapiens" => {:scientificName...}, ...}

parallel parser takes list of names and returns back a hash with names as keys and parsed data as values

Canonicals with ranks for infraspecific epithets:

parser = true)
parser.parse('Cola cordifolia var. puberula \
A. Chev.')[:scientificName][:canonical]
# Output: Cola cordifolia var. puberula

Resolving lsid and geting back RDF file



If nnparse or parserver do not start -- try to run

gem uninstall biodiversity
gem uninstall biodiversity19

and make sure you remove all versions and all nnparse and parserver scripts. Then install biodiversity again

gem install biodiversity

It should fix the problem.


Authors: Dmitry Mozzherin

Copyright (c) 2008-2018 Dmitry Mozzherin. See LICENSE for further details.