def normalize(text, lowercase=True, collapse=True, latinize=False, ascii=False,<EOL>encoding_default='<STR_LIT:utf-8>', encoding=None,<EOL>replace_categories=UNICODE_CATEGORIES):
text = stringify(text, encoding_default=encoding_default,<EOL>encoding=encoding)<EOL>if text is None:<EOL><INDENT>return<EOL><DEDENT>if lowercase:<EOL><INDENT>text = text.lower()<EOL><DEDENT>if ascii:<EOL><INDENT>text = ascii_text(text)<EOL><DEDENT>elif latinize:<EOL><INDENT>text = latinize_text(text)<EOL><DEDENT>if text is None:<EOL><INDENT>return<EOL><DEDENT>text = category_replace(text, replace_categories)<EOL>if collapse:<EOL><INDENT>text = collapse_spaces(text)<EOL><DEDENT>return text<EOL>
The main normalization function for text.

    This will take a string and apply a set of transformations to it so
    that it can be processed more easily afterwards. Arguments:

    * ``lowercase``: not very mysterious.
    * ``collapse``: replace multiple whitespace-like characters with a
      single whitespace. This is especially useful with category replacement
      which can lead to a lot of whitespace.
    * ``decompose``: apply a unicode normalization (NFKD) to separate
      simple characters and their diacritics.
    * ``replace_categories``: This will perform a replacement of whole
      classes of unicode characters (e.g. symbols, marks, numbers) with a
      given character. It is used to replace any non-text elements of the
      input string.