我们如何在NLTK的RegexpTagger中使用上下文?

时间:2019-09-16 21:20:12

标签: python nltk part-of-speech

我正在尝试使用NLTK的RegexpTagger制作自己的POS Tagger:

import nltk
patterns = [
    (r'in$', 'PREP'),
    # (...) Rest of patterns go here
    ]
tagger = nltk.RegexpTagger(patterns)
print(tagger.tag(nltk.word_tokenize('The cat is in the box. Cats are in right now.')))

到目前为止,我还找不到解决词汇歧义的方法。上面是单词“ in”的示例。我认为这是通过使用上下文解决的(例如,在这种情况下,如果“ in”在确定词/名词之前,则应该是介词),但是有没有办法使用NLTK的RegexpTagger?

谢谢!

0 个答案:

没有答案