【发布时间】:2016-09-03 16:02:33
【问题描述】:
我有以下main.py。
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:
import nltk
import string
import sys
for token in nltk.word_tokenize(''.join(sys.stdin.readlines())):
#print token
if len(token) == 1 and not token in string.punctuation or len(token) > 1:
print token
输出如下。
./main.py <<< 'EGR1(-/-) mouse embryonic fibroblasts'
EGR1
-/-
mouse
embryonic
fibroblasts
我想稍微更改标记器,以便它将EGR1(-/-) 识别为一个标记(无需任何其他更改)。有谁知道是否有一种方法可以稍微修改标记器?谢谢。
【问题讨论】:
标签: python regex nlp nltk tokenize