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

Standoff syntactic annotation of natural language text which may contain multiple sentences.

This is an Array of StandoffNode objects, one for each sentence in the text.

Methods

inspect   new   to_s  

Public Class methods

Parse the text and create the standoff annotation.

The default parser is a singleton instance of the English language Stanford Natural Langugage parser. There may be a delay of a few seconds for it to load the first time it is created.

[Source]

# File lib/stanfordparser.rb, line 340
    def initialize(text, nodetype = StandoffNode,
                   tokenizer = EN_PENN_TREEBANK_TOKENIZER,
                   parser = DefaultParser.instance)
      preprocessor = StandoffDocumentPreprocessor.new(tokenizer)
      # Segment the text into sentences.  Parse each sentence, writing
      # standoff annotation information into the terminal nodes.
      preprocessor.getSentencesFromString(text).map do |sentence|
        parse = parser.apply(sentence.to_s)
        push(nodetype.new(parse, sentence))
      end
    end

Public Instance methods

Print class name and number of sentences.

[Source]

# File lib/stanfordparser.rb, line 353
    def inspect
      "<#{self.class.name}, #{length} sentences>"
    end

Print parses.

[Source]

# File lib/stanfordparser.rb, line 358
    def to_s
      flatten.join(" ")
    end

[Validate]