gnabbr resolves abbreviated genera of scientific names found in
documents: C. elegans -> Caenorhabditis elegans. It is a Go library
for gnfinder and bhlindex.
Status: early development.
- Find names with an abbreviated genus: a capital letter with up to
two lowercase letters and a period, then an epithet (
C. alba,Cae. alba). - Group them locally: the same abbreviation in the same section (article, chapter) of the document, split where names are far apart (in characters). Names in a group usually share a genus; a repeated name is reconciled once per group.
- Hint: full names mentioned shortly before (
Carex nigra) give genera the abbreviation may stand for. - Reconcile each group with gnames
abbr_names, adding the taxonomic statistics of the section or the document (main taxon, dominant class), given by the caller. - Accept the best genus when its score reaches a threshold (8 by
default, which favors precision), and expand the group's names with
it (
C. alba->Carex alba). Callers verify expanded names with their other names.
import (
"github.com/gnames/gnabbr"
"github.com/gnames/gnabbr/pkg/config"
"github.com/gnames/gnabbr/pkg/doc"
)
ga := gnabbr.New(config.OptGnamesURL("http://localhost:8888/api/v1/"))
out, err := ga.Resolve(ctx, doc.Document{
ID: "item-1",
Names: []doc.Name{
{ID: "1", Name: "Caenorhabditis elegans", Start: 0},
{ID: "2", Name: "C. briggsae", Start: 2400},
},
TaxonStats: taxonStats, // gnstats stats.Stats of the document
})
// out.Reconciled: groups with an accepted genus and expanded names;
// out.Failed: groups without one, with their verbatims.Callers do not deal with gnames: the root package gnabbr joins the
core logic (pkg/gnabbr) with the internal abbr_names client. pkg/
never imports internal/ and has no configuration file or database
dependencies.
gnabbr needs a gnames with the abbr_names endpoint (gnames branch
137-abbr, not released yet). The default gnames URL,
https://verifier.globalnames.org/api/v1/, works only after such a
gnames is deployed there; until then set it to a local gnames with
config.OptGnamesURL.
gnabbr.go entry point: New(opts...) joins pkg/gnabbr and internal/iognames
pkg/gnabbr core: GNabbr, AbbrNamer, Resolve, Output
pkg/config settings (functional options, no I/O)
pkg/doc input: documents and name occurrences
pkg/abbrname parsing abbreviated names
pkg/group local groups
pkg/hints genus hints
internal/iognames abbr_names REST client (implements pkg/gnabbr.AbbrNamer)