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 exceptionless result of parse, mirroring Java org.gbif.nameparser.api.ParseResult: a structurally Parsed name or an Unparsable classification (virus, hybrid formula, placeholder, BOLD BIN, …). Informal names — provisional, open-nomenclature and indetermined ones like Rhizobium sp. RMCC TR1811 or Abies cf. alba — are Parsed names of type NameType::Informal; ParsedName::anchor gives the real taxon they hang off.

Functions§

parse
The primary exceptionless entry point (mirrors Java NameParser.parse()): classifies a scientific name into the ParseResult (Parsed | Unparsable) that every binding exposes, never throwing. Informal names are Parsed, typed NameType::Informal. For the raw ParsedName/error shape, 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.