Download utils/preprocessing.py from danhtran2mind/En-Vi-Translation-Transformer-TensorFlow: direct link, hf CLI and curl.
- Browser
- Download file 543 Bytes
-
https://huggingface.co/spaces/danhtran2mind/En-Vi-Translation-Transformer-TensorFlow/resolve/main/utils/preprocessing.py
- Command line
-
hf download hf://spaces/danhtran2mind/En-Vi-Translation-Transformer-TensorFlow/utils/preprocessing.py
-
curl -L -o preprocessing.py https://huggingface.co/spaces/danhtran2mind/En-Vi-Translation-Transformer-TensorFlow/resolve/main/utils/preprocessing.py
543 Bytes
| import string | |
| def input_processing(in_string): | |
| punct_marks = string.punctuation | |
| for mark in punct_marks: | |
| if mark in in_string: | |
| in_string = in_string.replace(mark, " " + mark) | |
| in_string = in_string.replace("scholl", "school") | |
| in_string = in_string.strip() | |
| return in_string | |
| def output_processing(in_string): | |
| in_string = in_string.replace("_", " ").replace('<sos>', '').replace('<eos>', '').strip() | |
| in_string = in_string[0].upper() + in_string[1:] | |
| return in_string | |