| Class | StanfordParser::StandoffSentence |
| In: |
lib/stanfordparser.rb
|
| Parent: | Array |
A sentence is an array of StandoffToken objects.
Construct an array of StandoffToken objects from a Java list sentence object returned by the preprocessor.
# File lib/stanfordparser.rb, line 291 def initialize(stanford_parser_sentence) # Convert FeatureStructure wrappers to StandoffToken objects. s = stanford_parser_sentence.to_a.collect do |fs| current = fs.current word = fs.word before = fs.before after = fs.after # The to_s.to_i is necessary because the get function returns # java.lang.Integer objects instead of Ruby integers. begin_position = fs.get(fs.BEGIN_POSITION_KEY).to_s.to_i end_position = fs.get(fs.END_POSITION_KEY).to_s.to_i StandoffToken.new(current, word, before, after, begin_position, end_position) end super(s) end