I am quite a beginner; it is not clean clode but works

number_of_words = 10
sentence = sentence.split(/\n/m).join(" ")
sentence.gsub!("  "," ")
r = /.*?[.!?](?:\s|$)/
sentences = sentence.scan(r)
sentences.map! {|e| e.split}
v = []
sentences.each do |e|
  while !e.empty?
    vv = []
    number_of_words.times {vv << (e.shift.to_s + " ")}
    v << vv
  end
end

v.each {|e| e.delete_if {|x| x == " "}}

v.map! {|e| e.join}

v.each {|e| p e}
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to