Class: StanfordParser::LexicalizedParser
- Inherits:
-
Rjb::JavaObjectWrapper
- Object
- Rjb::JavaObjectWrapper
- StanfordParser::LexicalizedParser
- 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
Instance Attribute Summary collapse
-
#grammar ⇒ Object
readonly
The grammar used by the parser.
Attributes inherited from Rjb::JavaObjectWrapper
Instance Method Summary collapse
-
#initialize(grammar = ENGLISH_PCFG_MODEL, options = []) ⇒ LexicalizedParser
constructor
Create the parser given a grammar and options.
- #to_s ⇒ Object
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, = []) @grammar = Pathname.new(grammar.gsub(/\$\(ROOT\)/, ROOT)) super("edu.stanford.nlp.parser.lexparser.LexicalizedParser", @grammar.to_s) @java_object.setOptionFlags() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rjb::JavaObjectWrapper
Instance Attribute Details
#grammar ⇒ Object (readonly)
The grammar used by the parser
121 122 123 |
# File 'lib/stanfordparser.rb', line 121 def grammar @grammar end |
Instance Method Details
#to_s ⇒ Object
138 139 140 |
# File 'lib/stanfordparser.rb', line 138 def to_s "LexicalizedParser(#{grammar.basename})" end |