22import logging
33from typing import Optional
44from functools import lru_cache
5- from normality import collapse_spaces , ascii_text , category_replace
5+ from normality import squash_spaces , ascii_text , category_replace
66
77from fingerprints .constants import WS , BRACKETED
88
@@ -68,23 +68,23 @@ def clean_name_ascii(text: Optional[str]) -> Optional[str]:
6868 It transliterates the text to ASCII, removes punctuation and symbols, converts the
6969 text to lowercase, replaces certain character categories, and collapses consecutive
7070 spaces.
71-
71+
7272 Args:
7373 text (Optional[str]): The input text to be cleaned.
74-
74+
7575 Returns:
7676 Optional[str]: The cleaned text, or None if the cleaned text is empty or too short.
7777 """
7878 # transliterate to ascii
79- text = ascii_text (text )
8079 if text is None :
8180 return None
81+ text = ascii_text (text )
8282 # replace punctuation and symbols
8383 text = CHARACTERS_REMOVE_RE .sub ("" , text )
8484 text = text .lower ()
8585 cleaned = category_replace (text )
86- cleaned = collapse_spaces (cleaned )
87- if cleaned is None or len (cleaned ) < 2 :
86+ cleaned = squash_spaces (cleaned )
87+ if len (cleaned ) < 2 :
8888 return None
8989 return cleaned
9090
@@ -96,7 +96,7 @@ def clean_name_light(text: str) -> Optional[str]:
9696 text = CHARACTERS_REMOVE_RE .sub ("" , text )
9797 text = text .lower ()
9898 cleaned = category_replace (text )
99- cleaned = collapse_spaces (cleaned )
100- if cleaned is None or len (cleaned ) < 2 :
99+ cleaned = squash_spaces (cleaned )
100+ if len (cleaned ) < 2 :
101101 return None
102102 return cleaned
0 commit comments