Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:acm-uiuc/twitter-sentiment

  • Loading branch information...
commit c2258222bc534fd8c95882f2be86562d2f50bc8e 2 parents c293d78 + 7992daa
Jake McGinty authored
View
3  Gemfile
@@ -8,5 +8,4 @@ gem "twitter"
gem "face"
gem "paint"
gem "progressbar"
-gem "linguistics"
-
+gem "linguistics"
View
8 Gemfile.lock
@@ -14,7 +14,7 @@ GEM
term-ansicolor (>= 1.0.6)
daemons (1.1.8)
diff-lcs (1.1.3)
- eventmachine (0.12.10)
+ eventmachine (1.0.0.beta.4.1-x86-mingw32)
face (0.0.4)
json (>= 1.4.6)
rest-client (>= 1.6.1)
@@ -24,7 +24,9 @@ GEM
rack (~> 1.1)
gherkin (2.9.0)
json (>= 1.4.6)
- http_parser.rb (0.5.3)
+ gherkin (2.9.0-x86-mingw32)
+ json (>= 1.4.6)
+ http_parser.rb (0.5.3-x86-mingw32)
i18n (0.6.0)
json (1.6.5)
linguistics (1.0.9)
@@ -53,10 +55,12 @@ GEM
http_parser.rb (~> 0.5.1)
simple_oauth (~> 0.1.4)
yajl-ruby (1.1.0)
+ yajl-ruby (1.1.0-x86-mingw32)
yard (0.7.5)
PLATFORMS
ruby
+ x86-mingw32
DEPENDENCIES
cucumber
View
10 app.rb
@@ -13,6 +13,7 @@ class TwitterBeats
@@score_bounds = [-10,10]
attr_reader :parsers
+ # @return [int] Capped and rounded score
def limit_score score
return 0 if score.nil?
score = score > @@score_bounds[1] ? @@score_bounds[1] : score
@@ -20,8 +21,7 @@ def limit_score score
return score.round
end
- def happiness
-
+ def happiness
return limit_score(@parsers[:text_mood][:result][:score]*0.7+@parsers[:user_image][:result][:score]*0.2+@parsers[:user_stats][:result][:description_score]*0.1) \
unless @parsers[:text_mood][:result][:score].nil? \
or @parsers[:user_image][:result][:score].nil? \
@@ -40,7 +40,7 @@ def happiness
return 0
end
-
+
def paint_score num
return Paint["nil", :italic, :yellow] if num.nil?
return Paint[num.to_s, :bold, :red] if num < 0
@@ -92,8 +92,8 @@ def initialize
out.send_gen weights, status, parsers
},
})
- end
-end
+ end #initialize
+end #class
if __FILE__ == $0
begin
View
6 lib/twitter-sentiment/output/send.rb
@@ -13,7 +13,6 @@ def initialize
end
# Sends data to the music generator
- # @param [Array] Data in pre-defined form (not in JSON)
# @return [nil]
def send_gen weights, status, parsers
data = {
@@ -36,7 +35,7 @@ def send_gen weights, status, parsers
:negative_score => nil #fix this
},
:tweet => {
- :hash_obnoxiousess => status.entities.hashtags.length, #fix this
+ :hash_obnoxiousess => status.entities.hashtags.length,
:retweet => status.retweeted
},
:face => {
@@ -46,7 +45,8 @@ def send_gen weights, status, parsers
} #sentiment
} #data
payload = Yajl::Encoder.encode(data)
- streamSock = TCPSocket.new( "127.0.0.1", 9133 )
+ prefs = TwitterSentiment::Prefs::Defaults.socket
+ streamSock = TCPSocket.new(prefs[:host], prefs[:port])
streamSock.write(payload)
streamSock.close
rescue Exception
View
7 lib/twitter-sentiment/prefs/defaults.rb
@@ -33,6 +33,13 @@ def self.twitter
:search_phrase => "#sxsw",
}
end
+
+ def self.socket
+ {
+ :host => 'localhost',
+ :port => 9133,
+ }
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.