Skip to content
/ parsers Public

Various GBIF parsers for dates, countries, language, taxon ranks, etc

License

Notifications You must be signed in to change notification settings

gbif/parsers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GBIF Parsers

A parser is a software component that takes input data (frequently text) and builds a data structure [1].

The GBIF parsers library provides:

  • Dictionary backed parsers for countries, language, taxon ranks, etc.
  • Parsers for dates and coordinates

To build the project

mvn clean install

Usage

Country parsing

// Get a Country by the defined enumeration
Country mexicoFromEnum = Country.MEXICO;

// Get a Country from a String
ParseResult<Country> parsed = CountryParser.getInstance().parse("México");
if (parsed.getConfidence() == ParseResult.CONFIDENCE.DEFINITE) {
  Country mexicoFromParser = parsed.getPayload();
  String iso2LetterCode = mexicoFromParser.getIso2LetterCode();
}

Date parsing

TemporalParser dateParser = DateParsers.defaultTemporalParser();
ParseResult<TemporalAccessor> ta = dateParser.parse("2nd jan. 1999");

LocalDate localDate = LocalDate.from(ta.getPayload());

// or using the date parts
ta = dateParser.parse("1999", "jan.", "2");
localDate = LocalDate.from(ta.getPayload());

// or use ONLY the provided format to parse the date
// other formats will return a parse failure with possible dates
ta = dateParser.parse("1980-1-0", DateComponentOrdering.YMD);

// or use a list of possible formats
ta = dateParser.parse("12/08/2020", DateComponentOrdering.DMY_FORMATS);

For more information and details about the date parsing see the Date Parsing Documentation.

Policies

  • Built as Java 8 artifact

Documentation

[1] "Parser." Wikipedia: The Free Encyclopedia. Wikimedia Foundation, Inc. Retrieved June 28, 2016, from https://en.wikipedia.org/wiki/Parsing#Parser

About

Various GBIF parsers for dates, countries, language, taxon ranks, etc

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages