Python NLTK Brill Tagger does not have SymmetricProximateTokensTemplate, ProximateTokensTemplate, ProximateTagsRule, ProximateWordsRule

这一生的挚爱 提交于 2019-12-11 09:54:16

问题


When i try importing,

from nltk.tag.brill import SymmetricProximateTokensTemplate, ProximateTokensTemplate from nltk.tag.brill import ProximateTagsRule, ProximateWordsRule

Python Throws Import Error,

ImportError: cannot import name 'SymmetricProximateTokensTemplate'

What's the problem?

but this works

from nltk.tag import brill


回答1:


The Brill part of NLTK has been redesigned in NLTK 3. So all those classes you try to import do not exist any more.
See https://github.com/nltk/nltk/pull/549

I'm looking for an example how to use the Brill Tagger but till now, I didn't find anything.




回答2:


I'm using the templates from nltk.tag.brill.
There are four methods

  • nltkdemo18()
  • nltkdemo18plus()
  • fntbl37()
  • brill24()

which return sets of templates. From my evaluation fntbl37() is the best.

Here is some code:

Template._cleartemplates()
templates = fntbl37()
self._tagger = UnigramTagger(tagged_sents)
self._tagger = BrillTaggerTrainer(self._tagger, templates, trace=3)
self._tagger = self._tagger.train(tagged_sents, max_rules=250)

I hope it helps.



来源:https://stackoverflow.com/questions/30323409/python-nltk-brill-tagger-does-not-have-symmetricproximatetokenstemplate-proxima

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!