c-checker-test / c_tokenize.py
Phuc Long Nguyen
Init test space
cae1888
Raw
History Blame Contribute Delete
342 Bytes
import jieba
import re
STOPWORDS = {
"的", "了", "在", "是", "和", "也"
}
def clean_text(text):
return re.sub(r"[^\u4e00-\u9fff]", "", text)
def c_tokenize(text):
text = clean_text(text)
words = jieba.lcut(text)
return [
w.strip()
for w in words
if w.strip() and w not in STOPWORDS
]