I have 5 files file1.txt file2.txt....file5.txt
then I have list of 3 words red white blue
I am trying to find out how many times and in what files red white blue
occur.
Finally the format should be:
red = file1.txt, file3.txt, 2
white = file2.txt, 1
blue = file1.txt, file2.txt, file3.txt, 3
This is what I have so far:
files.each do |i|
curfile = File.new("#{i}","r")
while (line = curfile.gets)
mywords.each do |j|
if (line ~= /\b#{j}\b/)
##what kind of data structure should I put the results in??
end
end
end
end
What kind of data structure should I put the results in?