Class: StanfordParser::LexicalizedParser

Inherits:
Rjb::JavaObjectWrapper show all
Defined in:
lib/stanfordparser.rb

Overview

Lexicalized probabalistic parser.

This is an wrapper for the edu.stanford.nlp.parser.lexparser.LexicalizedParser object.

Direct Known Subclasses

DefaultParser

Instance Attribute Summary collapse

Attributes inherited from Rjb::JavaObjectWrapper

#java_object

Instance Method Summary collapse

Methods inherited from Rjb::JavaObjectWrapper

#each, #inspect, #method_missing

Constructor Details

#initialize(grammar = ENGLISH_PCFG_MODEL, options = []) ⇒ LexicalizedParser

Create the parser given a grammar and options. The grammar argument is a path to a grammar file. This path may contain the string $(ROOT), which will be replaced with the root directory of the Stanford Parser. By default, an English PCFG grammar is loaded.

The options argument is a list of string arguments as they would appear on a command line. See the documentaion of edu.stanford.nlp.parser.lexparser.Options.setOptions for more details.



132
133
134
135
136
# File 'lib/stanfordparser.rb', line 132

def initialize(grammar = ENGLISH_PCFG_MODEL, options = [])
  @grammar = Pathname.new(grammar.gsub(/\$\(ROOT\)/, ROOT))
  super("edu.stanford.nlp.parser.lexparser.LexicalizedParser", @grammar.to_s)
  @java_object.setOptionFlags(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rjb::JavaObjectWrapper

Instance Attribute Details

#grammarObject (readonly)

The grammar used by the parser



121
122
123
# File 'lib/stanfordparser.rb', line 121

def grammar
  @grammar
end

Instance Method Details

#to_sObject



138
139
140
# File 'lib/stanfordparser.rb', line 138

def to_s
  "LexicalizedParser(#{grammar.basename})"
end