Permalink
Browse files

added objects sent back from TextMood score to support parsed text ou…

…tput in JSON for transparency's sake.
  • Loading branch information...
1 parent a6690ad commit 03c48c4a67c60e450828790f9a77c63d651b48d7 Jake McGinty committed Mar 9, 2012
Showing with 5 additions and 4 deletions.
  1. +4 −3 app.rb
  2. +1 −1 lib/twitter-sentiment/parser/text_mood.rb
View
7 app.rb
@@ -20,7 +20,8 @@ def initialize
weight, mood = {}, {}
# text weight
pp :seperator
- weight[:text] = textmood.score(status.text)
+ text_score = textmood.score(status.text)
+ weight[:text] = text_score[:score]
mood[:text] = :bhargav
mood[:text] = :happy if weight[:text] > 0
mood[:text] = :sad if weight[:text] < 0
@@ -30,7 +31,7 @@ def initialize
info = userinfo.gather(status.user)
pp :info, "Boring images: #{info[0]}"
pp :info, "Followers per tweet: #{info[1]}"
- weight[:description] = info[3]
+ weight[:description] = info[3][:score]
weight[:img] = info[2]
mood[:description] = :bhargav
mood[:description] = :happy if weight[:description] > 0
@@ -70,7 +71,7 @@ def initialize
"url" => "https://twitter.com/#!/" + status.user.screen_name + "/status/" + status.id_str + "/",
"userimgurl" => status.user.profile_image_url.gsub(/_normal/, ''),
"raw_input" => status.text,
- "text" => nil, #fix this
+ "text" => text_score[:stripped_text],
"metadata" => nil #fix this
}, #input
"weights" => {
@@ -123,7 +123,7 @@ def score sentence
words.each do |word|
score += @dict[symbolize(word)] if @dict.member? symbolize(word)
end
- return score
+ return {:score => score, :stripped_text => words.join(" ")}
end
end # TextMood

0 comments on commit 03c48c4

Please sign in to comment.