Skip to content

Instantly share code, notes, and snippets.

@Najaf
Created February 17, 2014 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Najaf/9053155 to your computer and use it in GitHub Desktop.
Save Najaf/9053155 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'csv'
tweet = "Chocolate makes me happy, it makes my life wonderful"
tweetsplit = tweet.downcase.split(/\W+/)
valences = []
tweetsplit.each 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