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?.booleancontainsSubtaxa(String genus, String species, String subtaxa) Does the database contain at least one record that exactly matches specified genus, species and subtaxa?.findSimilarGenus(String genus, int maxSize) Return a list of genera close to the specified genus.findSimilarSpecies(String genus, String species, 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 subtaxaList<org.genesys.taxonomy.gringlobal.model.IGrinSpecies>findSpeciesRow(String genus, String species, String subtaxa) Find SpeciesRows matching the definitionprotected List<org.genesys.taxonomy.gringlobal.model.IGrinSpecies>getAllGenusSpecies(String genus) Gets the all genus species.getGenus(long genusId) Get genus by genusIdgetSpeciesAuthority(String genus, String species) 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 subtaxaList<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
-
findSimilarGenus
Description copied from interface:TaxonomyDatabaseReturn a list of genera close to the specified genus.- Specified by:
findSimilarGenusin interfaceTaxonomyDatabase- Parameters:
genus- genusmaxSize- TODO- 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
Gets the all genus species.- Parameters:
genus- the genus- 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
-
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- speciesmaxSize- 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
-
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
-
findSimilarSubtaxa
Description copied from interface:TaxonomyDatabaseSuggest a list of subtaxa- Specified by:
findSimilarSubtaxain interfaceTaxonomyDatabase- Parameters:
genus- valid genusspecies- valid speciessubtaxa- current subtaxamaxSize- 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- 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
-
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
-