Spaces:
Runtime error
Runtime error
Download split.py from whiteSteelRain/translate: direct link, hf CLI and curl.
- Browser
- Download file 741 Bytes
-
https://huggingface.co/spaces/whiteSteelRain/translate/resolve/main/split.py
- Command line
-
hf download hf://spaces/whiteSteelRain/translate/split.py
-
curl -L -o split.py https://huggingface.co/spaces/whiteSteelRain/translate/resolve/main/split.py
741 Bytes
| def split_string(tokens): | |
| result = [] | |
| done = 1 | |
| while(len(tokens) > 10 and done): | |
| done = 0 | |
| for i in range(10, len(tokens), 1): | |
| if i > 30 : | |
| if tokens[i] in [".", "。", "!", "!", "?", "?", ",", ",", "……"]: | |
| result.append(tokens[:i+1]) | |
| tokens = tokens[i+1:] | |
| done = 1 | |
| break | |
| else : | |
| if tokens[i] in [".", "。", "!", "!", "?","?"] : | |
| result.append(tokens[:i+1]) | |
| tokens = tokens[i+1:] | |
| done = 1 | |
| break | |
| if len(tokens) > 0 : | |
| result.append(tokens) | |
| return result |