Spaces:
Runtime error
Runtime error
Download utils/text_utils.py from Ysfxjo/arabic-complaint-classification: direct link, hf CLI and curl.
- Browser
- Download file 576 Bytes
-
https://huggingface.co/spaces/Ysfxjo/arabic-complaint-classification/resolve/main/utils/text_utils.py
- Command line
-
hf download hf://spaces/Ysfxjo/arabic-complaint-classification/utils/text_utils.py
-
curl -L -o text_utils.py https://huggingface.co/spaces/Ysfxjo/arabic-complaint-classification/resolve/main/utils/text_utils.py
576 Bytes
| import re | |
| from pydantic import BaseModel, field_validator | |
| class ArabicInput(BaseModel): | |
| text: str | |
| def normalize_arabic(cls, value: str) -> str: | |
| if not isinstance(value, str): | |
| return value | |
| value = re.sub(r'[\u064B-\u0652\u0670\u0640]', '', value) | |
| value = re.sub(r'[أإآٱ]', 'ا', value) | |
| value = value.replace('ة', 'ه').replace('ى', 'ي') | |
| value = re.sub(r'\s+', ' ', value).strip() | |
| return value |