Class: NlpToolz::Sentences
- Inherits:
-
Object
- Object
- NlpToolz::Sentences
- 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
-
#input ⇒ Object
Returns the value of attribute input.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#model ⇒ Object
Returns the value of attribute model.
-
#model_name ⇒ Object
Returns the value of attribute model_name.
-
#sentences ⇒ Object
Returns the value of attribute sentences.
Instance Method Summary collapse
- #has_model? ⇒ Boolean
-
#initialize(input, lang = nil) ⇒ Sentences
constructor
A new instance of Sentences.
- #split_into_sentences ⇒ Object
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
#input ⇒ Object
Returns the value of attribute input.
18 19 20 |
# File 'lib/nlp_toolz/sentences.rb', line 18 def input @input end |
#lang ⇒ Object
Returns the value of attribute lang.
18 19 20 |
# File 'lib/nlp_toolz/sentences.rb', line 18 def lang @lang end |
#model ⇒ Object
Returns the value of attribute model.
18 19 20 |
# File 'lib/nlp_toolz/sentences.rb', line 18 def model @model end |
#model_name ⇒ Object
Returns the value of attribute model_name.
18 19 20 |
# File 'lib/nlp_toolz/sentences.rb', line 18 def model_name @model_name end |
#sentences ⇒ Object
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
31 32 33 |
# File 'lib/nlp_toolz/sentences.rb', line 31 def has_model? @model end |
#split_into_sentences ⇒ Object
27 28 29 |
# File 'lib/nlp_toolz/sentences.rb', line 27 def split_into_sentences @sentences = @sentence_detector.sentDetect(@input).to_a end |