Package org.genesys.taxonomy.checker
Class InMemoryTaxonomyDatabase
java.lang.Object
org.genesys.taxonomy.checker.InMemoryTaxonomyDatabase
- All Implemented Interfaces:
TaxonomyDatabase
- Direct Known Subclasses:
CachingInMemoryTaxonomyDatabase
List based in-memory "database". NOT THREAD-SAFE!-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublePercentage margin from best score. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsGenus(String genus) Case insensitive search for genus.booleancontainsSpecies(String genus, String species) Does the database contain at least one record that exactly matches specified genus and species?.booleancontainsSpecies(String genus, String species, String spAuthor) Does the database contain at least one record that exactly matches specified genus and species?.booleancontainsSubtaxa(String genus, String species, String subtaxa) Does the database contain at least one record that exactly matches specified genus, species and subtaxa?.booleanDoes the database contain at least one record that exactly matches specified genus, species and subtaxa?.findSimilar(String genus, String species, String spAuthor, String subtaxa, String subtAuthor, int maxSize) Suggest a list of matches.findSimilarGenera(String genus, int maxSize) Find similar genera.findSimilarGenus(String genus, int maxSize) Ifgenusis registered return empty list, otherwise search for similar genera.findSimilarSpecies(String genus, String species, String spAuthor, int maxSize) Return a list of species close to the specified genus and species.findSimilarSubtaxa(String genus, String species, String subtaxa, int maxSize) Suggest a list of subtaxafindSimilarSubtaxa(String genus, String species, String spAuthor, String subtaxa, String subtAuthor, int maxSize) Suggest a list of subtaxaList<org.genesys.taxonomy.gringlobal.model.IGrinSpecies>findSpeciesRow(String genus, String species, String subtaxa) Find SpeciesRows matching the definitionList<org.genesys.taxonomy.gringlobal.model.IGrinSpecies>Find SpeciesRows matching the definitionfindTaxa(String genus, String species, String spAuthor, String subtaxa, String subtAuthor, int maxSize) protected List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies>getAllGenusSpecies(@NonNull String genus) Get all species for one genusprotected List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies>getAllGenusSpecies(@NonNull List<String> genera) Gets the all species for specified genera.getGenus(long genusId) Get genus by genusIdgetSpeciesAuthority(String genus, String species) Return the species authority for the specified species within genus.getSpeciesAuthority(String genus, String species, String spAuthor) Return the species authority for the specified species within genus.org.genesys.taxonomy.gringlobal.model.IGrinSpeciesgetSpeciesRow(long speciesId) Get species by speciesIdgetSubtaxaAuthority(String genus, String species, String subtaxa) Return the authority for the specified subtaxagetSubtaxaAuthority(String genus, String species, String spAuthor, String subtaxa, String subtAuthor) Return the authority for the specified subtaxaGet exact match.List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies>listSpecies(String genus, String species, int maxSize) Return all subtaxa for genus and speciesstatic voidPrints the.static <T> voidprint(Suggestion<T> suggestion) Prints the.voidregisterGenus(Long genusId, String genus) Add a genus to the database.voidregisterSpecies(org.genesys.taxonomy.gringlobal.model.IGrinSpecies speciesRow) Add species to the database.doublesimilarityScore(String original, String candidate) similarityScore returns a string similarity value in the range [0, 1.0] (where 1.0 is full match).toString()
-
Field Details
-
NONMATCH_MARGIN
public static final double NONMATCH_MARGINPercentage margin from best score. Matches with scores below bestScore * margin are ignored.- See Also:
-
-
Constructor Details
-
InMemoryTaxonomyDatabase
public InMemoryTaxonomyDatabase()
-
-
Method Details
-
registerGenus
Add a genus to the database.- Parameters:
genusId- the genus idgenus- the genus
-
registerSpecies
public void registerSpecies(org.genesys.taxonomy.gringlobal.model.IGrinSpecies speciesRow) throws TaxonomyException Add species to the database.- Parameters:
speciesRow- the species row- Throws:
TaxonomyException- the taxonomy exception
-
toString
-
containsGenus
Case insensitive search for genus.- Specified by:
containsGenusin interfaceTaxonomyDatabase- Parameters:
genus- the genus- Returns:
- true, if successful
-
findSimilarGenera
Find similar genera. UnlikefindSimilarGenus(String, int), this method will look for similar names regardless of input.- Parameters:
genus- base search namemaxSize- max matches to return- Returns:
- List of names
-
findSimilarGenus
Ifgenusis registered return empty list, otherwise search for similar genera.- Specified by:
findSimilarGenusin interfaceTaxonomyDatabase- Parameters:
genus- base search namemaxSize- max matches to return- Returns:
- list of suggestions, ordered by preference (best first), never null.
-
print
Prints the.- Type Parameters:
T- the generic type- Parameters:
suggestion- the suggestion
-
print
Prints the.- Parameters:
suggestion- the suggestion
-
getAllGenusSpecies
protected List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies> getAllGenusSpecies(@NonNull @NonNull String genus) Get all species for one genus- Parameters:
genus- genus name- Returns:
- list of species, never null
-
getAllGenusSpecies
protected List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies> getAllGenusSpecies(@NonNull @NonNull List<String> genera) Gets the all species for specified genera.- Parameters:
genera- the list of genera- Returns:
- the all genus species
-
containsSpecies
Description copied from interface:TaxonomyDatabaseDoes the database contain at least one record that exactly matches specified genus and species?.- Specified by:
containsSpeciesin interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the species- Returns:
trueif there is at least one record
-
containsSpecies
Description copied from interface:TaxonomyDatabaseDoes the database contain at least one record that exactly matches specified genus and species?.- Specified by:
containsSpeciesin interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the speciesspAuthor- species authority- Returns:
trueif there is at least one record
-
findSimilar
public List<TaxonomyChecker.Taxon> findSimilar(String genus, String species, String spAuthor, String subtaxa, String subtAuthor, int maxSize) Description copied from interface:TaxonomyDatabaseSuggest a list of matches.- Specified by:
findSimilarin interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- valid speciesspAuthor- species authoritysubtaxa- subtaxa to checksubtAuthor- species authority at the lowest classification levelmaxSize- maximum number of suggestions to return- Returns:
- list of suggestions, ordered by preference, never null
-
findSimilarSpecies
Description copied from interface:TaxonomyDatabaseReturn a list of species close to the specified genus and species.- Specified by:
findSimilarSpeciesin interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- speciesspAuthor- species authoritymaxSize- maximum number of suggestions to return- Returns:
- list of suggestions, ordered by preference (best first), never null.
-
similarityScore
similarityScore returns a string similarity value in the range [0, 1.0] (where 1.0 is full match).- Specified by:
similarityScorein interfaceTaxonomyDatabase- Parameters:
original- the originalcandidate- the candidate- Returns:
- the score between 0 and 1.0 where 0 is no similarity and 1.0 is full match
-
getSpeciesAuthority
Description copied from interface:TaxonomyDatabaseReturn the species authority for the specified species within genus.- Specified by:
getSpeciesAuthorityin interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the species- Returns:
- the authority or
null
-
getSpeciesAuthority
Description copied from interface:TaxonomyDatabaseReturn the species authority for the specified species within genus.- Specified by:
getSpeciesAuthorityin interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the speciesspAuthor- species authority- Returns:
- the authority or
null
-
containsSubtaxa
Description copied from interface:TaxonomyDatabaseDoes the database contain at least one record that exactly matches specified genus, species and subtaxa?.- Specified by:
containsSubtaxain interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- valid speciessubtaxa- subtaxa to check- Returns:
trueif there is at least one record
-
containsSubtaxa
public boolean containsSubtaxa(String genus, String species, String spAuthor, String subtaxa, String subtAuthor) Description copied from interface:TaxonomyDatabaseDoes the database contain at least one record that exactly matches specified genus, species and subtaxa?.- Specified by:
containsSubtaxain interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- valid speciesspAuthor- species authoritysubtaxa- subtaxa to checksubtAuthor- species authority at the lowest classification level- Returns:
trueif there is at least one record
-
findSimilarSubtaxa
Description copied from interface:TaxonomyDatabaseSuggest a list of subtaxa- Specified by:
findSimilarSubtaxain interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- valid speciessubtaxa- subtaxa to checkmaxSize- maximum number of suggestions to return- Returns:
- list of suggestions, ordered by preference, never null
-
findSimilarSubtaxa
public List<String> findSimilarSubtaxa(String genus, String species, String spAuthor, String subtaxa, String subtAuthor, int maxSize) Description copied from interface:TaxonomyDatabaseSuggest a list of subtaxa- Specified by:
findSimilarSubtaxain interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- valid speciesspAuthor- species authoritysubtaxa- subtaxa to checksubtAuthor- species authority at the lowest classification levelmaxSize- maximum number of suggestions to return- Returns:
- list of suggestions, ordered by preference, never null
-
getSubtaxaAuthority
Description copied from interface:TaxonomyDatabaseReturn the authority for the specified subtaxa- Specified by:
getSubtaxaAuthorityin interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the speciessubtaxa- subtaxa to check- Returns:
- the authority or
null
-
getSubtaxaAuthority
public List<String> getSubtaxaAuthority(String genus, String species, String spAuthor, String subtaxa, String subtAuthor) Description copied from interface:TaxonomyDatabaseReturn the authority for the specified subtaxa- Specified by:
getSubtaxaAuthorityin interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the speciesspAuthor- species authoritysubtaxa- subtaxa to checksubtAuthor- species authority at the lowest classification level- Returns:
- the authority or
null
-
listSpecies
public List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies> listSpecies(String genus, String species, int maxSize) Description copied from interface:TaxonomyDatabaseReturn all subtaxa for genus and species- Specified by:
listSpeciesin interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- valid speciesmaxSize- maximum number of rows to return- Returns:
- list of species matching genus and species name
-
findSpeciesRow
public List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies> findSpeciesRow(String genus, String species, String subtaxa) Description copied from interface:TaxonomyDatabaseFind SpeciesRows matching the definition- Specified by:
findSpeciesRowin interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the speciessubtaxa- the MCPD subtaxa- Returns:
- list of matching SpeciesRows
-
findSpeciesRows
public List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies> findSpeciesRows(String genus, String species, String spAuthor, String subtaxa, String subtAuthor) Description copied from interface:TaxonomyDatabaseFind SpeciesRows matching the definition- Specified by:
findSpeciesRowsin interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the speciesspAuthor- species authoritysubtaxa- the MCPD subtaxasubtAuthor- species authority at the lowest classification level- Returns:
- list of matching SpeciesRows
-
getTaxon
public TaxonomyChecker.Taxon getTaxon(String genus, String species, String spAuthor, String subtaxa, String subtAuthor) Description copied from interface:TaxonomyDatabaseGet exact match.- Specified by:
getTaxonin interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- valid speciesspAuthor- species authoritysubtaxa- subtaxa to checksubtAuthor- species authority at the lowest classification level- Returns:
- One exactly matching record
-
findTaxa
public List<TaxonomyChecker.Taxon> findTaxa(String genus, String species, String spAuthor, String subtaxa, String subtAuthor, int maxSize) - Specified by:
findTaxain interfaceTaxonomyDatabase- Parameters:
genus- the genusspecies- the speciesspAuthor- species authoritysubtaxa- the MCPD subtaxasubtAuthor- species authority at the lowest classification levelmaxSize- maximum rows to return- Returns:
- list of taxa
-
getSpeciesRow
public org.genesys.taxonomy.gringlobal.model.IGrinSpecies getSpeciesRow(long speciesId) Description copied from interface:TaxonomyDatabaseGet species by speciesId- Specified by:
getSpeciesRowin interfaceTaxonomyDatabase- Parameters:
speciesId- duh- Returns:
- SpeciesRow or null if not found
-
getGenus
Description copied from interface:TaxonomyDatabaseGet genus by genusId- Specified by:
getGenusin interfaceTaxonomyDatabase- Parameters:
genusId- duh- Returns:
- genus name or null
-