使用python NLTK的Stanford NER失败,字符串包含多个“!!”是吗?

2024-05-03 16:08:02 发布

您现在位置:Python中文网/ 问答频道 /正文

假设这是我的filecontent

When they are over 45 years old!! It would definitely help Michael Jordan.

下面是我标记集合的代码。在

st = NERTagger('stanford-ner/classifiers/english.all.3class.distsim.crf.ser.gz', 'stanford-ner/stanford-ner.jar')
tokenized_sents = [word_tokenize(sent) for sent in sent_tokenize(filecontent)]  
taggedsents = st.tag_sents(tokenized_sents)

我希望tokenized_sents和{}包含相同数量的句子。在

但以下是它们包含的内容:

^{pr2}$

这是因为有双重性“!”在第一句话的结尾。我必须删除双“!”在使用st.tag_sents()之前

我该如何解决这个问题?在


Tags: tagoldaresentoverwhensttokenize