From ed996122a4ea45f2b529803448af165c6af4c3ee Mon Sep 17 00:00:00 2001 From: Jeff Yates Date: Wed, 15 Jul 2020 13:41:06 -0400 Subject: [PATCH] updated sorter to accept csv input instead of json --- sorter.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sorter.rb b/sorter.rb index ffc9c6d..f2f6eb0 100755 --- a/sorter.rb +++ b/sorter.rb @@ -19,12 +19,17 @@ ############################################################################ require 'json' require 'pp' +require 'csv' -json = File.read('./bins.json') +#json = File.read('./bins.json') +csv = CSV.read('./bins.csv') text = File.read('tester.txt') -bins = JSON.parse(json) #Turn bins.json into a hash +#bins = JSON.parse(json) #Turn bins.json into a hash output = Hash.new #Creating the output storage object +bins = Hash.new +csv.each { |bin| bins[bin[0].to_sym] = bin[1..].compact } + #bin_counter expects: # bin - a hash with strings to search for # test - the document text to search through