class NlpToolz::Sentences
Constants
- FileInputStream
load java classes
- SentenceDetectorME
- SentenceModel
Attributes
input[RW]
lang[RW]
model[RW]
model_name[RW]
sentences[RW]
Public Class Methods
new(input,lang = nil)
click to toggle source
# File lib/nlp_toolz/sentences.rb, line 20 def initialize(input,lang = nil) @input = input @lang = lang || NlpToolz::Language.get_language(input) @model_name = "#{@lang}-sent.bin" get_model end
Public Instance Methods
has_model?()
click to toggle source
# File lib/nlp_toolz/sentences.rb, line 31 def has_model? @model end
split_into_sentences()
click to toggle source
# File lib/nlp_toolz/sentences.rb, line 27 def split_into_sentences @sentences = @sentence_detector.sentDetect(@input).to_a end
Private Instance Methods
get_model()
click to toggle source
# File lib/nlp_toolz/sentences.rb, line 37 def get_model model_file = "#{MODELS}/sent/#{@model_name}" if File.exists?(model_file) @model = SentenceModel.new(FileInputStream.new(model_file)) @sentence_detector = SentenceDetectorME.new(@model) else @model = false # raise 'file not found' end end