Brill Taggerを使用するとこのエラーが発生します。 sequential.pyでPython 3.4で '_sre.SRE_Pattern'オブジェクトが反復できません
TypeError: '_sre.SRE_Pattern' object is not iterable
WARNING:root:2016-04-05 00:05:37.503718 is when this event was logged.
ERROR:root:'_sre.SRE_Pattern' object is not iterable
Traceback (most recent call last):
File "D:\Dropbox\VCL\MyWrapper.py", line 137, in run_alg
CLC_POS.tag_file(input_utf8, path_out + '.pos', file_encoding, CLC_POS.load_tagger('pos_tbl_86943.model'), '')
File "D:\Dropbox\VCL\CLC_POS.py", line 277, in tag_file
token_tag = tagger.tag(word_list)
File "C:\Python34\lib\site-packages\nltk\tag\brill.py", line 264, in tag
tagged_tokens = self._initial_tagger.tag(tokens)
File "C:\Python34\lib\site-packages\nltk\tag\sequential.py", line 61, in tag
tags.append(self.tag_one(tokens, i, tags))
File "C:\Python34\lib\site-packages\nltk\tag\sequential.py", line 81, in tag_one
tag = tagger.choose_tag(tokens, index, history)
File "C:\Python34\lib\site-packages\nltk\tag\sequential.py", line 546, in choose_tag
for regexp, tag in self._regexs:
TypeError: '_sre.SRE_Pattern' object is not iterable
それは forループに来るとき、私はエラーを取得します。
def choose_tag(self, tokens, index, history):
for regexp, tag in self._regexs:
if re.match(regexp, tokens[index]):
return tag
return None
1ヶ月前に同じコードを実行してもエラーはありませんでした。 sequential.pyはnltkファイルに属します。
どうしたのですか?可能であれば修正を提供してください。
'self._regexs'はリストではありません。 ** ** ** **正規表現オブジェクトです。 –
'tagger'を作成し、それ以外のものとやりとりするコードがなければ、そのリストを単一の正規表現オブジェクトに置き換えることができるかもしれないので、修正できません。 –