Created
February 17, 2014 15:50
-
-
Save Rosa-Fox/9053056 to your computer and use it in GitHub Desktop.
tweetsplit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'csv' | |
tweet = "Chocolate makes me happy, it makes my life wonderful" | |
tweetsplit = tweet.downcase.split(/\W+/) | |
valences! = [] | |
for tweetsplit do |i| | |
#Look through each row in the CSV file to see if any words in the tweet match the words in the 2nd element of the csv array(the word) | |
CSV.foreach("./ratings.csv") do |row| | |
#For each line if the word matches words in the tweet then create a new array and put the valence mean value (3rd array element) in it. | |
#puts [row[1], row[2]].inspect | |
if row[1]==(i) | |
valences! << row[2] | |
puts valences! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment