Class: NlpToolz::Sentences

Inherits:
Object
  • Object
show all
Defined in:
lib/nlp_toolz/sentences.rb

Constant Summary collapse

FileInputStream =

load java classes

Rjb::import('java.io.FileInputStream')
SentenceDetectorME =
Rjb::import('opennlp.tools.sentdetect.SentenceDetectorME')
SentenceModel =
Rjb::import('opennlp.tools.sentdetect.SentenceModel')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, lang = nil) ⇒ Sentences

Returns a new instance of Sentences.



20
21
22
23
24
25
# 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

Instance Attribute Details

#inputObject

Returns the value of attribute input.



18
19
20
# File 'lib/nlp_toolz/sentences.rb', line 18

def input
  @input
end

#langObject

Returns the value of attribute lang.



18
19
20
# File 'lib/nlp_toolz/sentences.rb', line 18

def lang
  @lang
end

#modelObject

Returns the value of attribute model.



18
19
20
# File 'lib/nlp_toolz/sentences.rb', line 18

def model
  @model
end

#model_nameObject

Returns the value of attribute model_name.



18
19
20
# File 'lib/nlp_toolz/sentences.rb', line 18

def model_name
  @model_name
end

#sentencesObject

Returns the value of attribute sentences.



18
19
20
# File 'lib/nlp_toolz/sentences.rb', line 18

def sentences
  @sentences
end

Instance Method Details

#has_model?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/nlp_toolz/sentences.rb', line 31

def has_model?
  @model
end

#split_into_sentencesObject



27
28
29
# File 'lib/nlp_toolz/sentences.rb', line 27

def split_into_sentences
  @sentences = @sentence_detector.sentDetect(@input).to_a
end