Sha256: 33c4699e46c1115d98475fe8292dfabd5a5b257197125f59d5d38e1802a4d346
Contents?: true
Size: 833 Bytes
Versions: 2
Compression:
Stored size: 833 Bytes
Contents
module OpenNlp class SentenceDetector < Tool self.java_class = Java::opennlp.tools.sentdetect.SentenceDetectorME # Detects sentences in a string # # @param [String] string string to detect sentences in # @return [Array<String>] array of detected sentences def detect(str) fail ArgumentError, 'str must be a String' unless str.is_a?(String) j_instance.sentDetect(str).to_ary end # Detects sentences in a string and returns array of spans # # @param [String] str # @return [Array<OpenNlp::Util::Span>] array of spans for detected sentences 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
open_nlp-0.2.0-java | lib/open_nlp/sentence_detector.rb |
open_nlp-0.1.0-java | lib/open_nlp/sentence_detector.rb |