Skip to content

Instantly share code, notes, and snippets.

@anthonybishopric
Created June 17, 2011 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonybishopric/1030734 to your computer and use it in GitHub Desktop.
Save anthonybishopric/1030734 to your computer and use it in GitHub Desktop.
A view helper to go along with SlyShy's TactfulTokenizer
module SegmenterHelper
def sentences(num_sentences, text)
@tactful_tokenizer ||= TactfulTokenizer::Model.new
result = @tactful_tokenizer.tokenize_text text
output = ""
0.upto([num_sentences, result.length].min - 1) do |i|
output << "#{result[i]} "
end
output
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment