Spaces:
Sleeping
Sleeping
Download processDoubles.py from cdactvm/Punjabi_ASR_Demo: direct link, hf CLI and curl.
- Browser
- Download file 827 Bytes
-
https://huggingface.co/spaces/cdactvm/Punjabi_ASR_Demo/resolve/main/processDoubles.py
- Command line
-
hf download hf://spaces/cdactvm/Punjabi_ASR_Demo/processDoubles.py
-
curl -L -o processDoubles.py https://huggingface.co/spaces/cdactvm/Punjabi_ASR_Demo/resolve/main/processDoubles.py
827 Bytes
| import re | |
| def process_doubles(sentence): | |
| # Use regex to split 'डबल' followed by numbers/words without space (e.g., "डबलवन" -> "डबल वन") | |
| sentence = re.sub(r'(ਡਬਲ)(\S+)', r'\1 \2', sentence) | |
| tokens = sentence.split() | |
| result = [] | |
| i = 0 | |
| while i < len(tokens): | |
| if tokens[i] == "ਡਬਲ": | |
| if i + 1 < len(tokens): | |
| result.append(tokens[i + 1]) # Append the next word/number | |
| result.append(tokens[i + 1]) # Append the next word/number again to duplicate | |
| i += 2 # Skip over the next word since it's already processed | |
| else: | |
| result.append(tokens[i]) | |
| i += 1 | |
| else: | |
| result.append(tokens[i]) | |
| i += 1 | |
| return ' '.join(result) | |