Class: StanfordParser::Tree

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

Overview

This is a wrapper for edu.stanford.nlp.trees.Tree objects. It customizes stringification.

Instance Attribute Summary

Attributes inherited from Rjb::JavaObjectWrapper

#java_object

Instance Method Summary collapse

Methods inherited from Rjb::JavaObjectWrapper

#each, #method_missing

Constructor Details

#initialize(obj = "edu.stanford.nlp.trees.Tree") ⇒ Tree

Returns a new instance of Tree.



155
156
157
# File 'lib/stanfordparser.rb', line 155

def initialize(obj = "edu.stanford.nlp.trees.Tree")
  super(obj)
end

Dynamic Method Handling

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

Instance Method Details

#inspectObject

Return the label along with the score if there is one.



160
161
162
163
# File 'lib/stanfordparser.rb', line 160

def inspect
  s = "#{label}" + (score.nan? ? "" : " [#{sprintf '%.2f', score}]")
  "(#{s})"
end

#to_sObject

The Penn treebank representation. This prints with indenting instead of putting everything on one line.



167
168
169
# File 'lib/stanfordparser.rb', line 167

def to_s
  "#{pennString}"
end