Skip to content

Instantly share code, notes, and snippets.

@nokados
Last active June 15, 2018 06:46
Show Gist options
  • Save nokados/9fc0cf8734c3ec78f0bef2ca7a3b1553 to your computer and use it in GitHub Desktop.
Save nokados/9fc0cf8734c3ec78f0bef2ca7a3b1553 to your computer and use it in GitHub Desktop.
Clear punctuation for Russian texts, except ?
import string
translator = str.maketrans('', '', re.sub(r'[\?-]', '', string.punctuation+'«»”“', flags=re.MULTILINE))
def clear_punctuation(sentence):
return sentence.translate(translator)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment