Example #1
0
def strip_off_scientific_names(text_list: List[str],
                               taxonomy: Taxonomy) -> List[str]:
    # The CAMP-2020 checklist has <Common Name> <Scientific Name>
    # Assume all scientific names are two words and drop
    stripped_text_list = []
    for line in text_list:
        line = line.strip()
        # e.g. line = 'California Quail Callipepla californica'
        words = line.split(' ')
        if len(words) > 2:
            sci_name = ' '.join(words[-2:]).lower()
            row = taxonomy.find_scientific_name_row(sci_name)
            if row is not None:
                line = ' '.join(words[:-2])  #.lower()
        stripped_text_list.append(line)

    return stripped_text_list