Last active
March 28, 2021 06:45
-
-
Save kanekomasahiro/4712ed7b78e0b1fa3b8a4d16493adc39 to your computer and use it in GitHub Desktop.
正規表現を使った英語の単語分割
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
import regex as re | |
def split_sentence_to_words(sent): | |
pat = re.compile(r"'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+") | |
return re.findall(pat, sent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment