Class | NextwordController |
In: |
app/controllers/nextword_controller.rb
|
Parent: | ApplicationController |
file_choices? true if choices are static
# File app/controllers/nextword_controller.rb, line 26 26: def filechoices? 27: false 28: end
first_time contains initialization code
# File app/controllers/nextword_controller.rb, line 3 3: def first_time 4: session[:choices]=nil 5: redirect_to :action=>"index" 6: end
start_choices must return an array of strings
# File app/controllers/nextword_controller.rb, line 8 8: def start_choices 9: @text=get_text.strip 10: lw=last_word(@text) 11: if lw.empty? 12: # suggestions for first word 13: nw=Giver.new.get_starting_words(SentencesDir) 14: else 15: rx=Regexp.new(lw,Regexp::IGNORECASE) 16: g=Giver.new 17: ac=g.get_matching_sentences(SentencesDir,rx) 18: nw=ac.grep(%r{\b#{lw} (\w+)}) do 19: $1 20: end 21: end 22: logger.info "suggested #{nw}" 23: nw 24: end