Ejemplo n.º 1
0
def analyse_sentence(sentence):
    '''Takes a tweet and performs sentiment analysis on the given
    tweet, then gives the weight that was returned from the sentiment
    analysis

    TODO: Is this function neccesary? HALF-DEPRECATED'''
    
    sentiment = analyse_sentiment(sentence)
    keywordtuples = extract_keywords(sentence)
    return [(keyword,sentiment*weight) for (keyword,weight) in keywordtuples]
Ejemplo n.º 2
0
def main(address_list):
    polarities = []
    subjectivities = []

    for addr in address_list:
        loc = get_location_from_addr(addr)
        text = '\n'.join(query_lgbt_tweets(loc[0], loc[1]))
        [p, m, s] = analyse_sentiment(text)
        polarities.append(str(p))
        subjectivities.append(str(s))

    print(','.join(polarities))
    print(','.join(subjectivities))
Ejemplo n.º 3
0
def analyse_sentences_var_1(sentences):
    '''Does analysis of all sentences and returns a compilation of all results in the form of two
    lists in the magical and fantastical format we all know and love.

    ...'''

    hatekeywords = {}
    lovekeywords = {}
    for sentence in sentences:
        sentiment = analyse_sentiment(sentence)
        for (keyword, weight) in extract_keywords(sentence):
            a = lovekeywords if sentiment > 0.0 else hatekeywords  # choose where to put keyword
            a[keyword] = a.get(keyword, 0.0) + weight*abs(sentiment) # only positive weights in end result

    return (lovekeywords.items(), hatekeywords.items())
Ejemplo n.º 4
0
#!/usr/bin/python2.7

from sentiment import analyse_sentiment

a = True
while a:
    a = raw_input()
    print analyse_sentiment(a)