コード例 #1
0
ファイル: __init__.py プロジェクト: phslfo/TGSAT
    This client has some hard coded (but real) tweets which are passed to the
    API.

    You need to add your Developer Keys found on the Mashape Dashboard.
    If you are going to use the paid for API you must subscibe to a plan on 
    the Mashape API page (http://www.mashape.com/apis/Sentiment+Analysis/pricing)
"""
from SentimentAnalysisFree import SentimentAnalysisFree

#add your keys below
public_key = "PUBaxIIThb7R7A%ZePGtuLDl-olsIsXZ"
private_key = "PRIBfWPexYV6YyqR3AmwIK%QpNIil7-0"

#build the Free API object with your keys
chatterboxapi = SentimentAnalysisFree(public_key, private_key)

f = open('../test set.txt', 'r')
total = 0
count = 0
for line in f:
    total += 1
    
    tweet = line.split(' .:. ')
    sentiment = tweet[0]
    result = chatterboxapi.classifytext("en", tweet)
    
    sentiment_label = result['sent']
    if sentiment_label == 1:
        sentiment_label = 'pos'
    elif sentiment_label == -1:
コード例 #2
0
	for short social texts.

	This client has some hard coded (but real) tweets which are passed to the
	API.

	You need to add your keys found on the Mashape Dashboard.

"""
from SentimentAnalysisFree import SentimentAnalysisFree

#add your keys below
public_key = ""
private_key = ""

#build the Free API object with your keys
chatterboxapi = SentimentAnalysisFree(public_key, private_key)

#Our hard coded sample tweets.  Your application will figure out 
#what it needs...
sampletexts = ["@getflockler must have a great designer cause it looks hot!! :-)",
	"I've started exploring Evernote... this may change my life.. I'm not sure yet, but it may.",
	"Well, Saudi Airlines have really messed up our holiday. Pretty pissed off they can get away with it.",
	"How did someone make it to our site using the keywords: \"different types of birth control\"? #odd",
	"Apple Mail, why do you crash so? #grrrr",
	"If you ever wonder 'how bad can a coffee from burger king be, really?' the answer is bad, very bad. #badcoffeebadmorning",
	"Great meeting with TK from the Queen Mary student paper - really interesting questions!"]

highestnumber = 0
highesttext = False

try:
コード例 #3
0
	for short social texts.

	This client has some hard coded (but real) tweets which are passed to the
	API.

	You need to add your keys found on the Mashape Dashboard.

"""
from SentimentAnalysisFree import SentimentAnalysisFree

#add your keys below
public_key = ""
private_key = ""

#build the Free API object with your keys
chatterboxapi = SentimentAnalysisFree(public_key, private_key)

#Our hard coded sample tweets.  Your application will figure out
#what it needs...
sampletexts = [
    "@getflockler must have a great designer cause it looks hot!! :-)",
    "I've started exploring Evernote... this may change my life.. I'm not sure yet, but it may.",
    "Well, Saudi Airlines have really messed up our holiday. Pretty pissed off they can get away with it.",
    "How did someone make it to our site using the keywords: \"different types of birth control\"? #odd",
    "Apple Mail, why do you crash so? #grrrr",
    "If you ever wonder 'how bad can a coffee from burger king be, really?' the answer is bad, very bad. #badcoffeebadmorning",
    "Great meeting with TK from the Queen Mary student paper - really interesting questions!"
]

highestnumber = 0
highesttext = False