Skip to content

Instantly share code, notes, and snippets.

View loisgh's full-sized avatar

Lois loisgh

View GitHub Profile
#The output is as follows:
# word followed by "total: " with the total amount next to it
# 2:1 The sentence that the word appears in and the number of times it appears.
# 2:1 means that the word appears in the second sentence one time.
class Concordance
shash = Array.new
total_hash = Hash.new
@myArray = [1,3,5,[7,9,11],12,[15,16,[17,18,19],[20,21,22],[23,24],[25,26]]]
@outArray = Array.new
def flatten(inArray)
inArray.each do |a|
if a.is_a?(Array)
flatten(a)
else
@outArray.push(a)
end