オランダ語のつぶやきのリストについて感情分析が必要で、同じものにはconll2002
が使用されています。ここで私が使用しているコードは次のとおりです。NLTKコーパスを使用したオランダのつぶやきの感情分析conll2002
import nltk.classify.util
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import conll2002
import time
t=time.time()
def word_feats(words):
return dict([(word, True) for word in words])
#negids = conll2002.fileids('neg')
def train():
#negids = conll2002.fileids('neg')
#posids = conll2002.fileids('pos')
negids = conll2002.fileids()
posids = conll2002.fileids()
negfeats = [(word_feats(conll2002.words(fileids=[f])), 'neg') for f in negids]
posfeats = [(word_feats(conll2002.words(fileids=[f])), 'pos') for f in posids]
negcutoff = len(negfeats)*3/4
poscutoff = len(posfeats)*3/4
trainfeats = negfeats[:negcutoff] + posfeats[:poscutoff]
testfeats = negfeats[negcutoff:] + posfeats[poscutoff:]
print 'train on %d instances, test on %d instances' % (len(trainfeats), len(testfeats))
classifier = NaiveBayesClassifier.train(trainfeats)
print 'accuracy:', nltk.classify.util.accuracy(classifier, testfeats)
classifier.show_most_informative_features()
x=train()
print x
print time.time()-t
上記のコードは、次のような出力ではなく動作します:
train on 8 instances, test on 4 instances
accuracy: 0.5
Most Informative Features
poderlas = True pos : neg = 1.0 : 1.0
voert = True pos : neg = 1.0 : 1.0
contundencia = True pos : neg = 1.0 : 1.0
encuestocracia = None pos : neg = 1.0 : 1.0
alivien = None pos : neg = 1.0 : 1.0
Bogotá = True pos : neg = 1.0 : 1.0
Especialidades = True pos : neg = 1.0 : 1.0
hoofdredacteurs = True pos : neg = 1.0 : 1.0
quisieron = True pos : neg = 1.0 : 1.0
asciendan = None pos : neg = 1.0 : 1.0
None
9.21083234
をposは:すべてのケースのために1:NEG比は1であることを出てきます。どうすれば修正できますか?私はこの問題は、私は現在のコードでコメントアウトしている次のステートメントであるかもしれない考え出し:
negids = conll2002.fileids('neg')
posids = conll2002.fileids('pos')
私は上記の二つの文をコメントアウトしていない場合、私が得るエラーは次のとおりです。
Traceback (most recent call last):
File "naive1.py", line 31, in <module>
x=train()
File "naive1.py", line 13, in train
negids = conll2002.fileids('neg')
TypeError: fileids() takes exactly 1 argument (2 given)
私はこの問題を解決するために自己を使ってみましたが、それでも動作しません。誰かが私を正しい方向に向けることができますか?前もって感謝します。
これを指摘してくれてありがとう。オランダ語のつぶやきについて感情分析を行う他の方法を提案できますか?正直なつぶやきと否定的なつぶやきのリストを「良い」と「悪い」と分類し、それに基づいてモデルを訓練することによって、ニューラルネットワークを試してみるべきですか?代替案を提案してください。 –
私はあなたの質問を理解していません。あなたがオランダ語の感情コーパスを持っているなら(あなたが言っているように)、それを使って本に示されているように 'NaiveBayesClassifier'を鍛えることができます。あなたが感情コーパスを持っていない場合、別の_supervised_アルゴリズムはどのようにあなたを助けるでしょうか? – alexis
今、私はオランダ語の500文章のリストとその感情に基づく対応スコアを持っています。たとえば、ポジティブなツイートの年齢は90歳前後、ネガティブなツイートの年齢は50歳前後です。これを私のArtificial Neural Networkモデルのトレーニングデータセットとして使用し、他のつぶやきの感情スコアを予測するためにトレーニングすることはできますか?あなたの助けに感謝します。 –