File: __init__.py

package info (click to toggle)
python-fingerprints 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 920 kB
  • sloc: python: 1,290; makefile: 17
file content (21 lines) | stat: -rw-r--r-- 698 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from normality import squash_spaces

from fingerprints.cleanup import clean_name_ascii
from fingerprints.types.replacer import get_replacer, NormFunc


def replace_types(text: str) -> str:
    """Chomp down company types to a more convention form."""
    return get_replacer()(text)


def remove_types(text: str, clean: NormFunc = clean_name_ascii) -> str:
    """Remove company type names from a piece of text.

    WARNING: This converts to ASCII by default, pass in a different
    `clean` function if you need a different behaviour."""
    cleaned = clean(text)
    if cleaned is None:
        return ""
    removed = get_replacer(clean, remove=True)(cleaned)
    return squash_spaces(removed)