Add spaces between words and punctuation
Use this twice, and then apply another regex to make this work properly:
import re
line = 'your text here'
line = re.sub(r'([a-zA-z0-9 ])([?,.!:\'\"])([a-zA-z0-9 ]|$)', r'\1 \2 \3', line)
line = re.sub(r'([a-zA-z0-9 ])([?,.!:\'\"])([a-zA-z0-9 ]|$)', r'\1 \2 \3', line)
line = re.sub(r'[ ]+', ' ', lin...
Submitted by toiletsandpaper - 2 years ago