CoolFace
Apppublic

wfr2/species-synonym-api

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
normalize_query_string.py21 linesDownload Raw Back to utils
1def normalize_query_string(name: str) -> str:2    """Normalize a scientific name string.3 4    Steps: strip leading/trailing whitespace, collapse internal whitespace5    (including tabs), lowercase everything, then capitalize the first letter.6 7    Args:8        name: Two word string representing a species name, with the first word representing the Genus and the second word representing the Species.9 10    Returns:11        Normalized species name string in the format "Genus species".12 13    Examples:14        >>> normalize_scientific_name("amanita muscaria")15        'Amanita muscaria'16        >>> normalize_scientific_name(" AMANITA  MUSCARIA")17        'Amanita muscaria'18    """19    normalized = " ".join(name.split())20    return normalized.lower().capitalize()21