name-parser-api/src/main/java/org/gbif/nameparser/util/RankUtils.java
/**
   * Tries its best to infer a rank from an atomised name by just looking at the name parts ignoring any existing rank on the instance.
   * As a final resort for higher monomials the suffices are inspected with the help of the supplied nomenclatural code (see LinneanName instance).
   * If no code is given certain suffices are ambiguous (e.g. -idae and -inae) and cannot be inferred!
   *
   * @return the inferred rank or UNRANKED if it cant be found.
   */
Tries its best to infer a rank from an atomised name by just looking at the name parts ignoring any existing rank on the instance.
As a final resort for higher monomials the suffices are inspected with the help of the supplied nomenclatural code .
If no code is given certain suffices are ambiguous  and cannot be inferred!

@return the inferred rank or UNRANKED if it cant be found.
Tries its best to infer a rank from an atomised name by just looking at the name parts ignoring any existing rank on the instance . As a final resort for higher monomials the suffices are inspected with the help of the supplied nomenclatural code . If no code is given certain suffices are ambiguous and cannot be inferred! @return the inferred rank or UNRANKED if it cant be found .
public static Rank inferRank(LinneanName pn) {
    if (pn.getInfraspecificEpithet() != null) {
      return INFRASPECIFIC_NAME;
    } else if (pn.getSpecificEpithet() != null) {
      return SPECIES;
    } else if (pn.getInfragenericEpithet() != null) {
      return INFRAGENERIC_NAME;
    } else if (pn.getUninomial() != null) {
      Map<String, Rank> suffices;
      if (pn.getCode() == null) {
        suffices = GLOBAL_SUFFICES_RANK_MAP;
      } else {
        suffices = SUFFICES_RANK_MAP.getOrDefault(pn.getCode(), Collections.emptyMap());
      }
      for (Map.Entry<String, Rank> e : suffices.entrySet()) {
        if (pn.getUninomial().endsWith(e.getKey())) {
          return e.getValue();
        }
      }
    }
    return UNRANKED;
  }
public static Rank inferRank ( LinneanName pn ) { if ( pn . getInfraspecificEpithet ( ) != null ) { return INFRASPECIFIC_NAME ; } else if ( pn . getSpecificEpithet ( ) != null ) { return SPECIES ; } else if ( pn . getInfragenericEpithet ( ) != null ) { return INFRAGENERIC_NAME ; } else if ( pn . getUninomial ( ) != null ) { Map < String , Rank > suffices ; if ( pn . getCode ( ) == null ) { suffices = GLOBAL_SUFFICES_RANK_MAP ; } else { suffices = SUFFICES_RANK_MAP . getOrDefault ( pn . getCode ( ) , Collections . emptyMap ( ) ) ; } for ( Map . Entry < String , Rank > e : suffices . entrySet ( ) ) { if ( pn . getUninomial ( ) . endsWith ( e . getKey ( ) ) ) { return e . getValue ( ) ; } } } return UNRANKED ; }
Tries its best to infer a rank from an atomised name by just looking at the name parts ignoring any existing rank on the instance.
Tries its best to infer a rank from an atomised name by just looking at the name parts ignoring any existing rank on the instance .
// detect rank based on parsed name // some infraspecific name // a species // some infrageneric name // a suprageneric name, check suffices // default if we cant find anything else