示例#1
0
文件: views.py 项目: oaws/traces
def twsent(request):
    new = open("C:\\Users\\osiddiqui\\Documents\\venv\\djosid\\owais\\tweets.txt")
    res1 = "\n"
    for line in new:
        vs = vaderSentiment(line)
        res1 += str(vs)
    return HttpResponse(res1)
示例#2
0
def saddest(listofstrings):
    sentiment = 1
    sadsent = "test"
    for sentence in listofstrings:
        vs = vaderSentiment(sentence)["compound"]
        if vs < sentiment:
            sadsent = sentence
            sentiment = vs
    return sadsent
示例#3
0
def happiest(listofstrings):
    sentiment = -1
    happysent = "test"
    for sentence in listofstrings:
        vs = vaderSentiment(sentence)["compound"]
        if vs > sentiment:
            happysent = sentence
            sentiment = vs

    return happysent
示例#4
0
文件: sent.py 项目: oaws/traces
from vaderSentiment import sentiment as vaderSentiment 
#note: depending on how you installed (e.g., using source code download versus pip install), you may need to import like this: 
#from vaderSentiment.vaderSentiment import sentiment as vaderSentiment 

# --- example sentences ------- 
sentences = [ 
"I am not happy", # positive sentence example 
"VADER is smart, handsome, and funny.", # positive sentence example 
"VADER is smart, handsome, and funny!", # punctuation emphasis handled correctly (sentiment intensity adjusted) 
"VADER is very smart, handsome, and funny.", # booster words handled correctly (sentiment intensity adjusted) 
"VADER is VERY SMART, handsome, and FUNNY.", # emphasis for ALLCAPS handled 
"VADER is VERY SMART, handsome, and FUNNY!!!",# combination of signals - VADER appropriately adjusts intensity 
"VADER is VERY SMART, really handsome, and INCREDIBLY FUNNY!!!",# booster words & punctuation make this close to ceiling for score 
"The book was good.", # positive sentence 
"The book was kind of good.", # qualified positive sentence is handled correctly (intensity adjusted) 
"The plot was good, but the characters are uncompelling and the dialog is not great.", # mixed negation sentence 
"A really bad, horrible book.", # negative sentence with booster words 
"At least it isn't a horrible book.", # negated negative sentence with contraction 
":) and :D", # emoticons handled 
"", # an empty string is correctly handled 
"Today sux", # negative slang handled 
"Today sux!", # negative slang with punctuation emphasis handled 
"Today SUX!", # negative slang with capitalization emphasis 
"Today kinda sux! But I'll get by, lol" # mixed sentiment example with slang and constrastive conjunction "but" 
]
for sentence in open('content.txt'): 
    print sentence, 
    vs = vaderSentiment(sentence) 
    print "\n\t" + str(vs) 
'''
Created on Nov 1, 2016
2017 Update, new vaderSentiment can be found at: https://github.com/cjhutto/vaderSentiment
'''

from vaderSentiment import sentiment as vaderSentiment

sentences = [
              """Most sentiment tools are shit.""",
              """NLTK sentiment analysis is also shit...""",
              """When the system down, they lost all the money""",
              """I hate Microsoft products! I hate working on Windows! I hate being managed by people!""",
              """I hate days when I cannot be happy, and have to work in the office. God, please end this internship soon.... I hate working here. I hate I cannot be happy all the time. Why, today I'm feeling so sad. God, and today I'm so many things to do. I simply want to get more sleep, I'm so tired""",
              """Heartbreaking!""",
              """time kills everything""",
              """I should learn Scala sson, always write Python has some limited ability...""",
              """I like seeing people reply my emails early when I get here early, I hate scilence! But when I am working, I am very quiet too...""",
              """The saddest thing is, long long long time ago, you satrted to like this person because you felt the similarity, but when time passed by, when that person is becoming mroe and more indifference, you gradually realized you may be living in 2 different worlds and you are pusuing different career, but this is not the most painful part. The most painful part is, when you are well prepared to embrace this difference (since if you really like each other, you can grow together and help each other thrive), but that person does not think so at all. Gradually, you have realized, there must be another woman there in his life, but sadly, you simply lie to yourself all the time and do not want to admit, do not want to let him go.... Meanwhile, you cannot tell anyone such as parents or friends, they will all blame you, for not let go in such a long time"""
             ]
for sentence in sentences:
    print(sentence)
    vs = vaderSentiment(sentence)
    print str(vs)
示例#6
0
文件: views.py 项目: oaws/traces
def sentiment(request):
    res1 = "\n"
    for sentence in open("C:\\Users\\osiddiqui\\Documents\\venv\\djosid\\owais\content.txt"):
        vs = vaderSentiment(sentence)
        res1 += str(vs)
    return HttpResponse(res1)