| 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.
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.
# File lib/stanfordparser.rb, line 331 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