Exemplo n.º 1
0
netral = negatif = positif = 0

persen_hasil = {
    'negatif': 0,
    'netral': 0,
    'positif': 0
}

#minta id sama username
args = sys.argv
idorang = args[1]
username = args[2]

#masukin text yang mau diuji ke file testfile.dat
corpus_text = helper.get_text_from_corpus_v2("tweets/" + username + ".dat")

for text in corpus_text:
    result = classifier.classify(helper.extract_features(text.split()))
    
    #####
    if result == '0':
    	netral += 1
    elif result == '1':
    	negatif += 1
    else:
    	positif += 1

cursor.execute ("UPDATE kandidat SET jumlah_sentimen_net=%d, jumlah_sentimen_neg=%d, jumlah_sentimen_pos=%d WHERE id_kandidat='%s'" % (netral, negatif, positif, idorang))
# to load to database
cnx.commit()