我想从第二个令牌中删除\t
。
正在尝试使用循环,但没有成功。需要帮忙吗?你知道吗
import re
regex = re.compile(r'[\t]')
for sent in train_sents:
for tuples in sent:
print tuples[1]
[('O', 'Identification\t'),
('O', 'of\t'),
('O', 'APC2,\t'),
('O', 'a\t'),
('O', 'homologue\t'),
('O', 'of\t'),
('O', 'the\t'),
('B-DISEASE', 'adenomatous\t'),
('I-DISEASE', 'polyposis\t'),
('I-DISEASE', 'coli\t'),
('I-DISEASE', 'tumour\t'),
('O', 'suppressor\t'),
('O', '.\t')],
[('O', 'The\t'),
('B-DISEASE', 'adenomatous\t'),
('I-DISEASE', 'polyposis\t'),
('I-DISEASE', 'coli\t'),
('I-DISEASE', '(\t'),
('I-DISEASE', 'APC\t'),
('I-DISEASE', ')\t'),
('I-DISEASE', 'tumour\t'),
('O', '-suppressor\t'),
('O', 'protein\t'),
('O', 'controls\t'),
('O', 'the\t'),
('O', 'Wnt\t'),
('O', 'signalling\t'),
('O', 'pathway\t'),
('O', 'by\t'),
('O', 'forming\t'),
('O', 'a\t'),
('O', 'complex\t'),
('O', 'with\t'),
('O', 'glycogen\t'),
('O', 'synthase\t'),
('O', 'kinase\t'),
('O', '3beta\t'),
('O', '(\t'),
('O', 'GSK-3beta\t'),
('O', ')\t'),
('O', ',\t'),
('O', 'axin\t'),
('O', '/\t'),
('O', 'conductin\t'),
('O', 'and\t'),
('O', 'betacatenin\t'),
('O', '.\t')]
replace()
应该是有用的给,看到了吗下图:输出:
相关问题 更多 >
编程相关推荐