Download scripts/preprocess.py from krislette/salinlahi: direct link, hf CLI and curl.
- Browser
- Download file 735 Bytes
-
https://huggingface.co/spaces/krislette/salinlahi/resolve/main/scripts/preprocess.py
- Command line
-
hf download hf://spaces/krislette/salinlahi/scripts/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/spaces/krislette/salinlahi/resolve/main/scripts/preprocess.py
735 Bytes
| """ | |
| Rules that we have set for preprocessing Tagalog and Waray: | |
| [1] Remove from dataset: | |
| . (period) | |
| , (comma) | |
| ! (exclamation) | |
| ? (question) | |
| ; (semicolon) | |
| : (colon) | |
| " (double quote) | |
| β (en dash) | |
| β (em dash) | |
| ( ) [ ] { } (paranthesis, brackets, curly braces) | |
| [2] Keep on the dataset: | |
| ' (single quote) | |
| β (apostrophe) | |
| - (hyphen) | |
| """ | |
| import re | |
| def preprocess_text(text: str) -> str: | |
| """ | |
| Preprocess text to match training data rules. | |
| Remove: . , ! ? ; : " β β ( ) [ ] { } | |
| Keep: ' (apostrophe) - (hyphen) | |
| """ | |
| # Characters to remove | |
| chars_to_remove = r"[\.\,\!\?\;\:\"\β\β\(\)\[\]\{\}]" | |
| # Remove the specified characters | |
| text = re.sub(chars_to_remove, "", text) | |
| return text.strip() | |