Skip to main content

Crate nameparser

Crate nameparser 

Source
Expand description

A faithful Rust port of the GBIF scientific name parser. parse_name turns a scientific name into its structured atoms — genus, epithets, authorship, rank, nomenclatural code, notes, warnings — as a model::ParsedName. Byte-for-byte cross-validated against the Java name-parser (NameParserImpl) over 11,302 + 6.4M names (0 diffs). The same engine also ships as a native CLI and as Java/Python/R bindings — see the repository README.

Modules§

format
Port of Java org.gbif.nameparser.util.NameFormatter — renders a ParsedName back into a formatted scientific-name string.
model
pipeline
Java org.gbif.nameparser.pipeline.Pipeline — orchestrates the staged parsing pipeline. Each stage mutates the shared [ParseContext].
regexes
Ported StripAndStash patterns. The Java sources carry ~20 possessive quantifiers (14 in Preflight, 6 in StripAndStash); they’re dropped here because the regex crate is a linear-time automaton, so possessive/greedy is moot.
token
unicode
Java org.gbif.nameparser.util.UnicodeUtils — ported subset: normalizeQuotes, plus the homoglyph-replacement table (HOMOGLYHPS/containsHomoglyphs/replaceHomoglyphs) used by pipeline::stripandstash’s step 13. decompose/foldToAscii/ replaceSpecialCases/removeNonAscii/replaceNonAscii/unescapeUnicodeChars/ decodeUtf8Garbage/containsDiacritics/findDiacritics are NOT ported: no call site anywhere in this crate’s (now complete) pipeline reaches them, and the full-corpus Rust-vs-Java parity cross-validation (see BENCHMARKS.md/cross-validation.md, 0 mismatches) confirms their absence isn’t a gap.
viral
Java org.gbif.nameparser.pipeline.ViralSuffix — recognises the standardized ICTV viral rank suffixes on a single word (genus, monomial, or higher-taxon name). Per MSL41 every virus genus ends in one of these, so the suffix alone is a reliable virus signal.

Enums§

ParseResult
The 5.0.0 exceptionless result of parse, mirroring Java org.gbif.nameparser.api.ParseResult: a structurally Parsed name, an Informal semistructured name (a taxon anchor carrying a provisional designation, e.g. Rhizobium sp. RMCC TR1811), or an Unparsable classification (virus, hybrid formula, placeholder, BOLD BIN, …). The 5.5%-of-corpus informal band is split off from Parsed at the parse boundary — see the verbatim-corpus study.

Functions§

parse
The primary 5.0.0 exceptionless entry point (mirrors Java NameParser.parse()): classifies a scientific name into the three-way ParseResult (Parsed | Informal | Unparsable) that every binding exposes, never throwing. The informal split is applied here — a supraspecific taxon carrying a provisional designation with NO species epithet becomes ParseResult::Informal; a name with a species epithet (including cf./aff. and infraspecific-indeterminate binomials) stays ParseResult::Parsed, so its specific_authorship — which a flat anchor could not represent — is preserved. For the raw ParsedName/error shape (no informal split), use parse_name.
parse_name
The lower-level raw parse: a scientific name — optionally alongside a separately supplied authorship string, a requested Rank and a requested NomCode — into a ParsedName, or Err(ParseError) when the input cannot be parsed into a meaningful name. Delegates to pipeline::run.