Esempio n. 1
0
def saveComment(data_save):
    content = data_save['text_comment']
    id_apps = data_save['id_apps']
    time = data_save['date']
    sosmed = data_save['sosmed']
    user = data_save['name']
    id_url = data_save['id_url']
    keyword = preprocessing.do(content)
    dataProcess = impress.play(keyword, id_apps)
    sentiment = dataProcess['sentiment']
    # for view counting rule impressi
    recordCounting = preprocessing.recordCounting(dataProcess)
    arr_word = recordCounting['arr_word']
    arr_counted = recordCounting['arr_counted']
    arr_score = recordCounting['arr_score']
    role_group = recordCounting['role_group']

    if (checkExists(id_apps, id_url, time)):
        print content
        print "::" + str(sentiment)
        print "==============================="
        try:
            sql = '''INSERT INTO apps_opinion(id_apps, sentiment, content, time, sosmed, user, arr_word, arr_counted, arr_score, role_group, id_url) 
									VALUES ('%d',   '%s',      '%s',    '%s', '%d',  '%s',   '%s',      '%s',        '%s',       '%s',    '%s')''' \
              % (id_apps, sentiment, str(content), time, sosmed, user, arr_word, arr_counted, arr_score, role_group, id_url)
            db_mysql.executeSql(sql)
            db_mysql.commit()
            pass
        except Exception as e:
            pass
Esempio n. 2
0
def main(argv):
    inputfile = ''
    outputfile = ''

    params = sys.argv
    kalimat = params[1]
    keyword = preprocessing.do(kalimat)
    hasil = impress.play(keyword, 'eval')

    recordCounting = preprocessing.recordCounting(hasil)
    print json.dumps(recordCounting)
Esempio n. 3
0
def analyzeSentiment():
    sql = '''SELECT * 
				FROM data_test'''

    db_mysql.executeSql(sql)
    result = db_mysql.fetch('all')

    for data in result:
        kalimat = data[2]
        keyword = preprocessing.do(kalimat)
        sentiment = impress.play(keyword)['sentiment']
        print "==========================\n\nID: " + str(
            data[0]) + "\n" + kalimat + "\n--Sentiment: " + str(
                sentiment) + "\n"

        sql = '''UPDATE data_test SET sentiment=%d 
						WHERE id=%d ''' % (sentiment, data[0])
        db_mysql.executeSql(sql)
        db_mysql.commit()
Esempio n. 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import needed.db_mysql as db_mysql
import helper.preprocessing as preprocessing
import analyzer.impress as impress

# q = '"@jokowi"';
# since = '2017-01-09';
# until = '2017-08-01';
# twitter.play(q,since,until);

kalimat = "Kalau sampai permohonan tsb. dikabulkan MA. negera/pemerintah akan digoyang trus oleh mereka sampai keinginan syahwatnya tersalurkan seperti pada pilkada DKI 2017 behasil dan sukses dengan bantuan logo islam. Target berikutnya adalah pilpres 2019 mereka akan mainkan pertama PION SARA. kedua PION kesenjangan sosial. ketiga PION HAM. dan terakhir pion adu domba. Jika hal tsb tdk diantisipasi oleh pemerintah dan jajarannya maka hilanglah kepercayaan rakyat. yg terjadi kemudian adalah.pemodal dan para konglomerat pindah ke LN. yg warga negara asli indonesia tidak ada pilihan ngungsi ke gunung. Penegak HUKUM harus perpihak kepada kepentingan bangsa dan negara secara keseluruhan. Kalau ini dikabulkan MK apa yg terjadi adalah NKRI pasti secara perlahan lahan àkan PECAH. Yang ingin negara hilafah. yg ingin neg. islam. yg nasrani. yg. budha. yg. hindu. yg. kepercayaan juga mendirikan negaranya sendiri. Pemerintah harus WASPADA. Kpd. Bpk. JOKOWI Presiden RI rakyat bersama anda berjuang dibelakangMu. Semoga Alloh SWT memberikan kesehatan dan kekuatan bathin melawan manusia2 serakah yg tdk pernah puas. Yaaa Alloh berikanlah kekuatan kpd Bpk. Presiden untuk melindungi rakyatnya dari kehancuran. Yaaa Alloh engkau Maha Mengetahui tunjukkanlah bahwa yg bathil adalah bathil. yg baik tunjukkanlah baik. Hanya KepadaMu yaaa Alloh tempat memohon dan mengadu. kabulkan doa kami. semoga Bp. Jokowi dalam perlindunganNya. Amiin YRA."
keyword = preprocessing.do(kalimat)
hasil = impress.play(keyword, 11)

print "Kalimat      : \n" + kalimat
print "Preprocessing: "
print len(keyword)
print keyword
print "Klasifikasi kata: "
print len(hasil['counted'])
print hasil['counted']
print hasil['score']
print "Hasil Sentimen : " + str(hasil['sentiment'])

i = 0
j = 0
for x in hasil['counted']:
    if (x == 'lxx'):
        print keyword[i]
        print hasil['roleGroup'][j]
Esempio n. 5
0
def mainProcess(text, idApps):
    keyword = preprocessing.do(text)
    result = impress.play(keyword, idApps)
    return result
#  	# print text;
#  	# print result['words'];
#  	# print result['sentiment'];
#  	desc = {'text':text,'arr_word':result['words'],'sentiment':result['sentiment'],'recordRuleWork':result['recordRuleWork']};
#  	descTheRule.append(desc);

# with open('testing/jsonDescTheRule.txt', 'w') as outfile:
#     json.dump(descTheRule, outfile)

with open('testing/desc_rule/1RuleCombination.json') as json_data:
    rule_combination = json.load(json_data)

for sub_part in rule_combination:
    for list_combination in rule_combination[sub_part]:
        desc_rule = []
        name_file = list_combination.replace(' ', '')

        for example_text in rule_combination[sub_part][list_combination]:
            keyword = preprocessing.do(example_text)
            result = impress.play(keyword, 'eval')
            desc = {
                'text': example_text,
                'arr_word': result['words'],
                'sentiment': result['sentiment'],
                'recordRuleWork': result['recordRuleWork']
            }
            desc_rule.append(desc)

        with open('testing/desc_rule/' + name_file + '.json', 'w') as outfile:
            json.dump(desc_rule, outfile)