Ryan Mckenzie wrote in post #1011820:
> You're right. I'm still a beginner to Ruby, however I have still tried
> researching what I'm looking for and come up with no results. I tried
> manipulating the starting code but did not return any related results so
> I asked a question... surely thats what these forums are for! (I'm sure
> you would have done something like this - learning by example when you
> first started too!)
>
> Although I don't appreciate your tone and communication skills (perhaps
> you need a lesson) thank you for your technical help.

Ryan, since you brought up communication skills: from your original
posting it is not entirely clear to me what you want to do.  Do you want
to count word occurrences?  Do you want to generate permutations of all
subsets of words found in a document?  Or do you want to generate all
sub sequences of each phrase (line) in the document?

A few remarks: the usual counting idiom is this

counters = Hash.new 0
...
counters[key] += 1

If you need to append to Array per key, you can do

lists = Hash.new {|h, k| h[k] = []]
...
lists[key] << item

You open the file but do not close it (better use block form of
File.open or use File.foreach for even simpler code).

Maybe this does what you want - maybe not

ARGF.each do |line|
  phrase = line.scan /\w+/
  limit = phrase.length - 1

  0.upto limit do |start|
    start.upto limit do |stop|
      puts phrase[start..stop].join ' '
    end
  end
end

Kind regards

robert

-- 
Posted via http://www.ruby-forum.com/.