네덜란드어 트윗 목록에 대한 정서 분석이 필요하며 같은 언어로 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 %의 나이를 가지고 있습니다. 이것을 인공 신경망 모델의 학습 데이터 세트로 사용하고 다른 트윗의 정서 점수를 예측하도록 훈련시킬 수 있습니까? 귀하의 도움을 주시면 감사하겠습니다. –