0
だから私はそうのような(POSタグ付けは正確には)、リスト内の単語の束をタグ付けしようとしていた:NLTKでpos_tagを使用するには?
lw
は単語のリストである(それは本当に長いですか、私はそれを掲載しているでしょう
pos = [nltk.pos_tag(i,tagset='universal') for i in lw]
が、それは、(各リストは1つの単語を含むリストのリスト別名)[['hello'],['world']]
のようだが、私は試してみて、それを実行したときに私が取得:
Traceback (most recent call last):
File "<pyshell#183>", line 1, in <module>
pos = [nltk.pos_tag(i,tagset='universal') for i in lw]
File "<pyshell#183>", line 1, in <listcomp>
pos = [nltk.pos_tag(i,tagset='universal') for i in lw]
File "C:\Users\my system\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\tag\__init__.py", line 134, in pos_tag
return _pos_tag(tokens, tagset, tagger)
File "C:\Users\my system\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\tag\__init__.py", line 102, in _pos_tag
tagged_tokens = tagger.tag(tokens)
File "C:\Users\my system\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\tag\perceptron.py", line 152, in tag
context = self.START + [self.normalize(w) for w in tokens] + self.END
File "C:\Users\my system\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\tag\perceptron.py", line 152, in <listcomp>
context = self.START + [self.normalize(w) for w in tokens] + self.END
File "C:\Users\my system\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\tag\perceptron.py", line 240, in normalize
elif word[0].isdigit():
IndexError: string index out of range
誰かがなぜ、どのように私はこのエラーを取得し、どのようにそれを修正する教えてもらえますか?多くのありがとう。
おかげで、それは動作しますが、ここではただ問題は、これが起こっていた_why_私はまた思っていたということです。それにもかかわらず、私はあなたの答えに感謝します。 – EighteenthVariable