text =%q{
Ruby is a great programming language.It is object oriented and has many groovy features.Some people don't like it, but that's not our problem! It's easy to learn. It's great. To learn more about Ruby,visit the official Ruby Web site today.
}
sentences =text.gsub(/\s+/, '').strip.split(/\.|\?|\!/)
sentences_sorted =sentences.sort_by{|sentence|sentence.length}
one_third =sentences_sorted.length /3
ideal_sentences =sentences_sorted.slice(one_third,one_third +1)
ideal_sentences =ideal_sentences.select {|sentence|sentence =-/is|are/}
puts ideal_sentences.join(".")
错误提示:
summarize.rb:9: syntax error, unexpected '}'
就是找不出来!因为初学者,看书上是这样写的,不过书本的版本为 1.8,所以不知道是不是版本问题!
还望大大指教!谢谢...