(token: Token)
Return True if ``token`` is a proper noun or acronym; otherwise, False.

    Raises:
        ValueError: If parent document has not been POS-tagged.
Return True if ``token`` is a proper noun or acronym; otherwise, False.
Return True if token is a proper noun or acronym ; otherwise False .
def preserve_case(token: Token) -> bool:
    """
    Return True if ``token`` is a proper noun or acronym; otherwise, False.

    Raises:
        ValueError: If parent document has not been POS-tagged.
    """
    if token.doc.has_annotation("TAG") is False:
        raise ValueError(f"parent doc of token '{token}' has not been POS-tagged")
    # is_acronym() got moved into a subpkg with heavier dependencies that we don't
    # want imported at the top-level package; this is the only outside place
    # that uses that function, so let's hide the required import in this function
    # using a try/except for performance
    # not the prettiest solution, but should be alright
    try:
        acros.is_acronym
    except NameError:
        from textacy.extract import acros
    if token.pos == PROPN or acros.is_acronym(token.text):
        return True
    else:
        return False
def preserve_case ( token : Token ) -> bool : if token . doc . has_annotation ( "TAG" ) is False : raise ValueError ( f"parent doc of token '{token}' has not been POS-tagged" ) # is_acronym() got moved into a subpkg with heavier dependencies that we don't # want imported at the top-level package; this is the only outside place # that uses that function, so let's hide the required import in this function # using a try/except for performance # not the prettiest solution, but should be alright try : acros . is_acronym except NameError : from textacy . extract import acros if token . pos == PROPN or acros . is_acronym ( token . text ) : return True else : return False