Spaces:
Runtime error
Runtime error
Download utils.py from ahdsoft/Persian-Topic-Modeling: direct link, hf CLI and curl.
- Browser
- Download file 818 Bytes
-
https://huggingface.co/spaces/ahdsoft/Persian-Topic-Modeling/resolve/main/utils.py
- Command line
-
hf download hf://spaces/ahdsoft/Persian-Topic-Modeling/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/ahdsoft/Persian-Topic-Modeling/resolve/main/utils.py
818 Bytes
| from parsinorm import General_normalization | |
| #normalize | |
| def normalize(txt): | |
| general_normalization = General_normalization() | |
| txt = general_normalization.alphabet_correction(txt) | |
| txt = general_normalization.semi_space_correction(txt) | |
| txt = general_normalization.english_correction(txt) | |
| txt = general_normalization.html_correction(txt) | |
| txt = general_normalization.arabic_correction(txt) | |
| txt = general_normalization.punctuation_correction(txt) | |
| txt = general_normalization.specials_chars(txt) | |
| txt = general_normalization.remove_emojis(txt) | |
| txt = general_normalization.number_correction(txt) | |
| txt = general_normalization.remove_not_desired_chars(txt) | |
| txt = general_normalization.remove_repeated_punctuation(txt) | |
| return ' '.join(txt.replace('\n', ' ').replace('\t', ' ').replace('\r', ' ').split()) | |