Class: OpenNLP::Parser
Instance Method Summary collapse
Methods inherited from Base
#has_default_model?, #initialize, #last_name, #method_missing, #requires_model?
Constructor Details
This class inherits a constructor from OpenNLP::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OpenNLP::Base
Instance Method Details
#parse(text) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/open-nlp/classes.rb', line 46 def parse(text) tokenizer = OpenNLP::TokenizerME.new full_span = OpenNLP::Bindings::Span.new(0, text.size) parse_obj = OpenNLP::Bindings::Parse.new( text, full_span, "INC", 1, 0) tokens = tokenizer.tokenize_pos(text) tokens.each_with_index do |tok,i| start, stop = tok.get_start, tok.get_end token = text[start..stop-1] span = OpenNLP::Bindings::Span.new(start, stop) parse = OpenNLP::Bindings::Parse.new(text, span, "TK", 0, i) parse_obj.insert(parse) end @proxy_inst.parse(parse_obj) end |