Class: OpenNlp::SentenceDetector
- Defined in:
- lib/open_nlp/sentence_detector.rb
Instance Attribute Summary
Attributes inherited from Tool
Instance Method Summary collapse
-
#detect(str) ⇒ Array<String>
Detects sentences in a string.
-
#pos_detect(str) ⇒ Array<OpenNlp::Util::Span>
Detects sentences in a string and returns array of spans.
Methods inherited from Tool
Methods included from JavaClass
Constructor Details
This class inherits a constructor from OpenNlp::Tool
Instance Method Details
#detect(str) ⇒ Array<String>
Detects sentences in a string
9 10 11 12 |
# File 'lib/open_nlp/sentence_detector.rb', line 9 def detect(str) fail ArgumentError, 'str must be a String' unless str.is_a?(String) j_instance.sentDetect(str).to_ary end |
#pos_detect(str) ⇒ Array<OpenNlp::Util::Span>
Detects sentences in a string and returns array of spans
18 19 20 21 22 23 |
# File 'lib/open_nlp/sentence_detector.rb', line 18 def pos_detect(str) fail ArgumentError, 'str must be a String' unless str.is_a?(String) j_instance.sentPosDetect(str).map do |span| OpenNlp::Util::Span.new(span.getStart, span.getEnd) end end |