Package jazzparser :: Package parsers :: Package pcfg :: Module chart :: Class PcfgChart
[hide private]
[frames] | no frames]

Class PcfgChart

source code

     object --+    
              |    
cky.chart.Chart --+
                  |
                 PcfgChart

Overrides the CKY chart to add probabilistic stuff.

Signs in the input should have an attribute 'probability'. The results of rule application will also have such an attribute.

Nested Classes [hide private]
  HASH_SET_IMPL
For this chart's internal data structure, we use a modified implementation of the HashSet which adds handling of probabilities.
Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_get_ranked_parses(self)
Full parses ranked by probability.
source code
 
apply_unary_rule(self, rule, start, end, beam=True)
Applies a given unary rule to particular arcs and adds the results to the chart.
source code
 
_binary_expansion_probability(self, sign_pair, result)
Used by _apply_binary_rule and _apply_binary_rule_semantics to compute the expansion probabilitiy.
source code
 
_apply_binary_rule(self, rule, sign_pair)
Internal method to apply a given binary rule to a given pair of signs.
source code
 
_apply_binary_rule_semantics(self, rule, sign_pair, category)
Like _apply_binary_rule, but uses the apply_rule_semantics() of the rule instead of apply_rule() and returns a list of signs built by copying the category and combining it in a sign with the semantics of the result.
source code
 
apply_binary_rules(self, start, middle, end, beam=True)
Add to the chart all signs resulting from possible applications of binary rules to pairs of signs between node pairs (start,middle) and (middle,end), producing entries in (start,end).
source code
 
apply_binary_rule(self, rule, start, middle, end, beam=True)
Apply a given binary rule to particular arcs in the chart.
source code
 
apply_beam(self, arc=None)
Applies a beam to every arc in the chart.
source code
 
_sign_string(self, sign) source code
 
launch_inspector(self, input=None, block=False)
Starts up a graphical chart inspector to inspect this chart.
source code

Inherited from cky.chart.Chart: __len__, __str__, add_word_signs, apply_unary_rules, get_grouped_sign_pairs, get_grouped_signs, get_sign, get_sign_pairs, get_signs, kill_inspector, to_string

Inherited from cky.chart.Chart (private): _get_parses, _get_summary

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  ranked_parses
Full parses ranked by probability.

Inherited from cky.chart.Chart: parses, size, summary

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

_get_ranked_parses(self)

source code 

Full parses ranked by probability. Returns a list.

apply_unary_rule(self, rule, start, end, beam=True)

source code 

Applies a given unary rule to particular arcs and adds the results to the chart.

Parameters:
  • result_modifier - function to be applied to each result, taking the result sign as the first argument and the input sign as the second.
Overrides: cky.chart.Chart.apply_unary_rule
(inherited documentation)

_binary_expansion_probability(self, sign_pair, result)

source code 

Used by _apply_binary_rule and _apply_binary_rule_semantics to compute the expansion probabilitiy.

This is a separate function because both of the above do the same to compute the probabilities, so I don't want to repeat the code.

Returns a tuple of the probability and the inside probability.

_apply_binary_rule(self, rule, sign_pair)

source code 

Internal method to apply a given binary rule to a given pair of signs. Note that the supported interface method is apply_binary_rule(), which applies a single rule to all sign pairs between given nodes.

This is used internally by apply_binary_rule and apply_binary_rules.

Overrides: cky.chart.Chart._apply_binary_rule
(inherited documentation)

_apply_binary_rule_semantics(self, rule, sign_pair, category)

source code 

Like _apply_binary_rule, but uses the apply_rule_semantics() of the rule instead of apply_rule() and returns a list of signs built by copying the category and combining it in a sign with the semantics of the result.

Overrides: cky.chart.Chart._apply_binary_rule_semantics
(inherited documentation)

apply_binary_rules(self, start, middle, end, beam=True)

source code 

Add to the chart all signs resulting from possible applications of binary rules to pairs of signs between node pairs (start,middle) and (middle,end), producing entries in (start,end).

Returns:
True if signs were added as a result of rule application, False otherwise
Overrides: cky.chart.Chart.apply_binary_rules
(inherited documentation)

apply_binary_rule(self, rule, start, middle, end, beam=True)

source code 

Apply a given binary rule to particular arcs in the chart.

Note that this method is not used by apply_binary_rules for efficiency reasons, but apply_binary_rules simply does the same thing for all possible binary rules.

Overrides: cky.chart.Chart.apply_binary_rule
(inherited documentation)

apply_beam(self, arc=None)

source code 

Applies a beam to every arc in the chart. If arc is given, it should be a tuple of (start,end): applies a beam only to the arc starting at start and ending at end.

_sign_string(self, sign)

source code 
Overrides: cky.chart.Chart._sign_string

launch_inspector(self, input=None, block=False)

source code 

Starts up a graphical chart inspector to inspect this chart. The inspector will run in a separate thread. Subclasses of Chart should override this if they have their own version of the chart inspector and instantiate that instead.

Parameters:
  • input - a string representation of the input to pass to the inspector so it can display it.
Overrides: cky.chart.Chart.launch_inspector
(inherited documentation)

Property Details [hide private]

ranked_parses

Full parses ranked by probability. Returns a list.

Get Method:
_get_ranked_parses(self) - Full parses ranked by probability.