Created
February 22, 2019 06:41
-
-
Save applenob/5d916e299bbdac57e25237cc52edcc8c to your computer and use it in GitHub Desktop.
A simple english tokenizer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Refer to https://www.kaggle.com/jhoward/nb-svm-strong-linear-baseline | |
import re, string | |
re_tok = re.compile(f'([{string.punctuation}“”¨«»®´·º½¾¿¡§£₤‘’])') | |
def tokenize(s): | |
return re_tok.sub(r' \1 ', s).split() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment