import unicodedata


def is_latin(text):
    """
    Function to evaluate whether a piece of text is all Latin characters, numbers or punctuation.

    Can be used to test whether a search phrase is suitable for parsing as a fulltext query, or whether it
    should be treated as an "icontains" or similarly language independent query filter.
    """
    return all(
        [
            (
                "LATIN" in unicodedata.name(x)
                or unicodedata.category(x).startswith("P")
                or unicodedata.category(x).startswith("N")
                or unicodedata.category(x).startswith("Z")
            )
            for x in text
        ]
    )