name-parser/src/main/java/org/gbif/nameparser/ParsingJob.java
/**
   * Parse very special cases and return true if the parsing succeeded and has thereby ended completely!
   */
Parse very special cases and return true if the parsing succeeded and has thereby ended completely!
Parse very special cases and return true if the parsing succeeded and has thereby ended completely!
private boolean specialCases() throws UnparsableNameException, InterruptedException {
    ParsedName over = configs.forName(name);
    if (over != null) {
      pn.copy(over);
      LOG.debug("Manual override found for name: {}", name);
      return true;
    }
    Matcher m = matcherInterruptable(OTU_PATTERN, name);
    if (m.find()) {
      pn.setUninomial(m.group(1).toUpperCase());
      pn.setType(NameType.OTU);
      pn.setRank(Rank.UNRANKED);
      pn.setState(ParsedName.State.COMPLETE);
      return true;
    }
    m = matcherInterruptable(GTDB_MONOMIAL_PATTERN, name);
    if (m.find()) {
      pn.setUninomial(m.group());
      pn.setType(NameType.OTU);
      pn.setRank(Rank.UNRANKED);
      pn.setState(ParsedName.State.COMPLETE);
      return true;
    }
    m = matcherInterruptable(GTDB_BINOMIAL_PATTERN, name);
    if (m.find()) {
      pn.setGenus(m.group(1));
      pn.setSpecificEpithet(m.group(2));
      pn.setType(NameType.OTU);
      pn.setRank(Rank.SPECIES);
      pn.setState(ParsedName.State.COMPLETE);
      return true;
    }
    m = matcherInterruptable(BOLD_PLACEHOLDERS, name);
    if (m.find()) {
      pn.setUninomial(m.group(1));
      pn.setPhrase(m.group(2));
      pn.setState(ParsedName.State.COMPLETE);
      checkBlacklist(); 
      pn.setType(NameType.PLACEHOLDER);
      determineCode();
      determineRank();
      return true;
    }
    m = matcherInterruptable(UNPARSABLE_GROUP, name);
    if (m.find()) {
      if (m.group(2) != null) {
        pn.setGenus(m.group(1));
        pn.setSpecificEpithet(m.group(2).trim());
        pn.setState(ParsedName.State.COMPLETE);
        pn.setRank(Rank.SPECIES_AGGREGATE);
        pn.setType(NameType.SCIENTIFIC);
        checkBlacklist(); 
        determineCode();
        return true;
      } else {
        unparsable(NameType.PLACEHOLDER);
      }
    }
    return false;
  }
private boolean specialCases ( ) throws UnparsableNameException , InterruptedException { ParsedName over = configs . forName ( name ) ; if ( over != null ) { pn . copy ( over ) ; LOG . debug ( "Manual override found for name: {}" , name ) ; return true ; } Matcher m = matcherInterruptable ( OTU_PATTERN , name ) ; if ( m . find ( ) ) { pn . setUninomial ( m . group ( 1 ) . toUpperCase ( ) ) ; pn . setType ( NameType . OTU ) ; pn . setRank ( Rank . UNRANKED ) ; pn . setState ( ParsedName . State . COMPLETE ) ; return true ; } m = matcherInterruptable ( GTDB_MONOMIAL_PATTERN , name ) ; if ( m . find ( ) ) { pn . setUninomial ( m . group ( ) ) ; pn . setType ( NameType . OTU ) ; pn . setRank ( Rank . UNRANKED ) ; pn . setState ( ParsedName . State . COMPLETE ) ; return true ; } m = matcherInterruptable ( GTDB_BINOMIAL_PATTERN , name ) ; if ( m . find ( ) ) { pn . setGenus ( m . group ( 1 ) ) ; pn . setSpecificEpithet ( m . group ( 2 ) ) ; pn . setType ( NameType . OTU ) ; pn . setRank ( Rank . SPECIES ) ; pn . setState ( ParsedName . State . COMPLETE ) ; return true ; } m = matcherInterruptable ( BOLD_PLACEHOLDERS , name ) ; if ( m . find ( ) ) { pn . setUninomial ( m . group ( 1 ) ) ; pn . setPhrase ( m . group ( 2 ) ) ; pn . setState ( ParsedName . State . COMPLETE ) ; checkBlacklist ( ) ; pn . setType ( NameType . PLACEHOLDER ) ; determineCode ( ) ; determineRank ( ) ; return true ; } m = matcherInterruptable ( UNPARSABLE_GROUP , name ) ; if ( m . find ( ) ) { if ( m . group ( 2 ) != null ) { pn . setGenus ( m . group ( 1 ) ) ; pn . setSpecificEpithet ( m . group ( 2 ) . trim ( ) ) ; pn . setState ( ParsedName . State . COMPLETE ) ; pn . setRank ( Rank . SPECIES_AGGREGATE ) ; pn . setType ( NameType . SCIENTIFIC ) ; checkBlacklist ( ) ; determineCode ( ) ; return true ; } else { unparsable ( NameType . PLACEHOLDER ) ; } } return false ; }
Parse very special cases and return true if the parsing succeeded and has thereby ended completely!
Parse very special cases and return true if the parsing succeeded and has thereby ended completely!
// override exists? // BOLD/UNITE OTU names // GTDB OTU names // https://github.com/gbif/name-parser/issues/74 // BOLD style placeholders // https://github.com/gbif/name-parser/issues/45 // check blacklist // unparsable BOLD style placeholder: Iteaphila-group // can we parse out a species group? // check blacklist