lmpy.data_wrangling.common.accepted_name_wrangler

Module containing a data wrangler base class for resolving taxon names.

Module Contents

Classes

_AcceptedNameWrangler

Constructor for the base accepted name wrangler.

Functions

resolve_names_gbif(names, wait_time=0.5)

Resolve names using GBIF's taxonomic name resolution service.

class lmpy.data_wrangling.common.accepted_name_wrangler._AcceptedNameWrangler(name_map=None, name_resolver=None)[source]

Bases: lmpy.data_wrangling.base._DataWrangler

Constructor for the base accepted name wrangler.

Parameters
  • name_map (dict or str or None) – An existing name mapping.

  • name_resolver (Method or None) – If provided, this should be a function that takes a list of names as input and returns a dictionary of name mappings. If omitted, resolving of new names will be skipped.

_load_name_map(self, name_map)[source]

Attempt to load names from the name_map provided.

Parameters

name_map (dict or str) – A mapping dictionary or a filename with names.

resolve_names(self, names)[source]

Attempts to resolve a list of names.

Parameters

names (list or str) – A list of names to resolve.

Returns

A dictionary of input name keys and resolved name values.

Return type

dict

write_map_to_file(self, filename, output_format, mode='wt')[source]

Write the name map to a file so it can be reused.

Parameters
  • filename (str) – A file location where the map should be written.

  • output_format (str) – The format to write the map, either ‘csv’ or ‘json’.

  • mode (str) – How the file should be opened.

lmpy.data_wrangling.common.accepted_name_wrangler.resolve_names_gbif(names, wait_time=0.5)[source]

Resolve names using GBIF’s taxonomic name resolution service.

Parameters
  • names (list of str) – A list of name strings to resolve.

  • wait_time (number) – A number of seconds to wait after each request to avoid server ire.

Returns

Input names are keys and resolved name or None are values.

Return type

dict