0

誰かがnltkのコーパスにタグを付けるhunposの構文を手伝ってもらえますか?

  1. hunpos.HunPosTaggerモジュールに何をインポートしますか?

  2. コーパスにHunPosTagを付けるにはどうすればよいですか?以下のコードを参照してください。


import nltk 
from nltk.corpus import PlaintextCorpusReader  
from nltk.corpus.util import LazyCorpusLoader  

corpus_root = './'  
reader = PlaintextCorpusReader (corpus_root, '.*')  

ntuen = LazyCorpusLoader ('ntumultien', PlaintextCorpusReader, reader)  
ntuen.fileids()  
isinstance (ntuen, PlaintextCorpusReader)  


# So how do I hunpos tag `ntuen`? I can't get the following code to work.
# please help me to correct my python syntax errors, I'm new to python 
# but i really need this to work. sorry
##from nltk.tag import hunpos.HunPosTagger
ht = HunPosTagger('english.model')
for sentence in ntu.sent() ##looping through the no. of sentence
     ht.tag(ntusent()[i])
4

1 に答える 1

5
import nltk 
from nltk.tag.hunpos import HunposTagger
from nltk.tokenize import word_tokenize

corpus = "so how do i hunpos tag my ntuen ? i can't get the following code to work."
#please help me to correct my python syntax errors, i'm new to python 
#but i really need this to work. sorry
##from nltk.tag import hunpos.HunPosTagger
ht = HunposTagger('en_wsj.model')
print ht.tag(word_tokenize(corpus))

問題は単語をトークン化していないことだと思いますが、コードが機能しない理由は他にもあります(HunPosTaggerではなくHunposTaggerです)。私はあなたの質問からこの単純化された例を作りました。他にご不明な点がございましたら、コメントを投稿してください。

私はここからすべてを手に入れました:http ://code.google.com/p/hunpos/

python hunpos.py

[('so'、'RB')、('how'、'WRB')、('do'、'VBP')、('i'、'FW')、('hunpos'、'NN') 、('tag'、'NN')、('my'、'PRP $')、('ntuen'、'NN')、('?'、'。')、('i'、'FW' )、('ca'、'MD')、( "n't"、'RB')、('get'、'VB')、('the'、'DT')、('following'、 ' JJ')、(' code'、' NN')、(' to'、' TO')、(' work'、' VB')、('。'、'。')]

于 2011-02-23T22:16:01.473 に答える