How to use the normality.cleaning.collapse_spaces function in normality

To help you get started, we’ve selected a few normality examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alephdata / followthemoney / followthemoney / types / name.py View on Github external
def clean_text(self, name, **kwargs):
        """Basic clean-up."""
        name = strip_quotes(name)
        return collapse_spaces(name)
github pudo / normality / normality / __init__.py View on Github external
elif latinize:
        # Perform unicode-based transliteration, e.g. of cyricllic
        # or CJK scripts into latin.
        text = latinize_text(text)

    if text is None:
        return

    # Perform unicode category-based character replacement. This is
    # used to filter out whole classes of characters, such as symbols,
    # punctuation, or whitespace-like characters.
    text = category_replace(text, replace_categories)

    if collapse:
        # Remove consecutive whitespace.
        text = collapse_spaces(text)
    return text
github pudo / normality / normality / paths.py View on Github external
def _safe_name(file_name, sep):
    """Convert the file name to ASCII and normalize the string."""
    file_name = stringify(file_name)
    if file_name is None:
        return
    file_name = ascii_text(file_name)
    file_name = category_replace(file_name, UNICODE_CATEGORIES)
    file_name = collapse_spaces(file_name)
    if file_name is None or not len(file_name):
        return
    return file_name.replace(WS, sep)
github alephdata / followthemoney / followthemoney / types / address.py View on Github external
def clean_text(self, address, **kwargs):
        """Basic clean-up."""
        address = self.LINE_BREAKS.sub(", ", address)
        address = self.COMMATA.sub(", ", address)
        address = collapse_spaces(address)
        if len(address):
            return address