Difference between revisions of "NLTK: Sentiment Strength Detection in Bahasa Indonesia"

From OnnoWiki
Jump to navigation Jump to search
Line 27: Line 27:
  
  
=Ubah Source Code==
+
==Source Code Asli==
 +
 
 +
import pymongo, requests, json, urllib, re, collections
 +
from pymongo import MongoClient
 +
 +
client = MongoClient('mongodb://localhost:27017/')
 +
#mongodb database and collection
 +
db = client.dataset_agnezmo
 +
dbPre = db.preprocessing
 +
 +
def main():
 +
    ss = sentiStrength()
 +
    sc = spellCheck()
 +
    tweets = dbPre.find().skip(0).limit(100)
 +
    for t in tweets:
 +
        print ss.main(t['text'])
 +
    print "====================="       
 +
    print ss.getSentimenScore()
 +
   
 +
main()
 +
 
 +
 
 +
 
 +
==Ubah Source Code==
  
 
  import argparse
 
  import argparse

Revision as of 10:40, 25 February 2017

SentiStrengthID

Sentiment Strength Detection in Bahasa Indonesia. This is unsupervised version of SentiStrength (http://sentistrength.wlv.ac.uk/) in Bahasa Indonesia. Core Feature:

  • Sentiment Lookup
  • Negation Word Lookup
  • Booster Word Lookup
  • Emoticon Lookup
  • Idiom Lookup
  • Question Word Lookup
  • Slang Word Lookup
  • Spelling Correction (optional) using Pater Norvig (http://norvig.com/spell-correct.html)
  • Negative emotion ignored in question
  • Exclamation marks count as +2
  • Repeated Punctuation boosts sentiment

Ignored Rule:

   repeated letters more than 2 boosts sentiment score. This rule do not applied due to my own pre-processing rule which removing word's extra character
   score +2, -2 in word "miss". Do not apply in Bahasa Indonesia.

Warning!

This is work in progress. Experimental for my Master Thesis


Source Code Asli

import pymongo, requests, json, urllib, re, collections
from pymongo import MongoClient

client = MongoClient('mongodb://localhost:27017/')
#mongodb database and collection
db = client.dataset_agnezmo
dbPre = db.preprocessing

def main():
    ss = sentiStrength()
    sc = spellCheck()
    tweets = dbPre.find().skip(0).limit(100)
    for t in tweets:
        print ss.main(t['text'])
    print "====================="        
    print ss.getSentimenScore()
    
main()


Ubah Source Code

import argparse

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-i', '--infile', default=, help='input filename')
    return parser.parse_args() 

def main():
    args = parse_args()
    infile = args.infile

    filename = open(infile,'r')
    fcontent=filename.read()
    filename.close()

    ss = sentiStrength()
    sc = spellCheck()
    for t in fcontent:
        print ss.main(t)
    print "====================="        
    print ss.getSentimenScore()
    
main()


Referensi