ruby_lab.rb
# function to process each line of a file and extract the song titles
function to process each line of a file and extract the song titles
function to process each line of a file and extract the song titles
def process_file(file_name)
	puts "Processing File.... "
		IO.foreach(file_name) do |line|
			clean_title = cleanup_title(line)
			if not clean_title.nil?
				title_words = clean_title.split(' ')
				for i in 0..title_words.length-2
					if $bigrams[title_words[i]].nil?
						$bigrams[title_words[i]] = Hash.new(0)
					end
					$bigrams[title_words[i]][title_words[i+1]] += 1
				end
			end
		end
		puts "Finished. Bigram model built.\n"
end
def process_file ( file_name ) puts "Processing File.... " IO . foreach ( file_name ) do | line | clean_title = cleanup_title ( line ) if not clean_title . nil? title_words = clean_title . split ( ' ' ) for i in 0 .. title_words . length - 2 if $bigrams [ title_words [ i ] ] . nil? $bigrams [ title_words [ i ] ] = Hash . new ( 0 ) end $bigrams [ title_words [ i ] ] [ title_words [ i + 1 ] ] += 1 end end end puts "Finished. Bigram model built.\n" end
function to process each line of a file and extract the song titles
function to process each line of a file and extract the song titles
#begin # parse out the title from the raw data file # check if the title was rejected #puts clean_title # space delimited split to get individual words # If there isn't a hashmap for occurrences of the current word, create one # Increment the value in the hashmap for the subsequent word #rescue #	STDERR.puts "Could not open file" #	exit 4 #end
file_name
<not_specific>