Class StanfordParser::StandoffSentence
In: lib/stanfordparser.rb
Parent: Array

A sentence is an array of StandoffToken objects.

Methods

inspect   new   to_s  

Public Class methods

Construct an array of StandoffToken objects from a Java list sentence object returned by the preprocessor.

[Source]

# 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

Public Instance methods

Return the original string verbatim.

[Source]

# File lib/stanfordparser.rb, line 314
    def inspect
      to_s
    end

Return the original string verbatim.

[Source]

# File lib/stanfordparser.rb, line 309
    def to_s
      self[0..-2].inject(""){|s, word| s + word.current + word.after} + last.current
    end

[Validate]