Package nltk_lite :: Package parse :: Module category :: Class GrammarCategory
[hide private]
[frames] | no frames]

Class GrammarCategory

source code

                       object --+        
                                |        
featurestructure.FeatureStructure --+    
                                    |    
                       object --+   |    
                                |   |    
                  cfg.Nonterminal --+    
                                    |    
                             Category --+
                                        |
                                       GrammarCategory

A class of Category for use in parsing.

The name of the head feature in a GrammarCategory is pos (for "part of speech"). There is one required feature, /, which is intended to indicate a type of phrase that is missing from the grammatical structure.

In addition, GrammarCategories are displayed and parse differently, to be consistent with NLP teaching materials: the value of the / feature can be written with a slash after the right bracket, so that the string representation looks like: head[...]/value.

An example of a GrammarCategory is VP[+fin]/NP, for a verb phrase that is finite and has an omitted noun phrase inside it.

Nested Classes [hide private]
Instance Methods [hide private]
 
_repr(self, reentrances, reentrance_ids)
Returns: A string representation of this feature structure.
source code

Inherited from Category: __cmp__, __div__, __eq__, __hash__, __init__, __ne__, __repr__, __setitem__, deepcopy, feature_names, freeze, frozen, get_feature, has_feature, head, reentrances, remove_unbound_vars, required_features, symbol

Inherited from featurestructure.FeatureStructure: __getitem__, __str__, apply_bindings, equal_values, rename_variables, subsumes, unify

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Methods [hide private]
 
_parse(cls, s, position=0, reentrances=None)
Helper function that parses a Category.
source code

Inherited from Category: parse_rules

Inherited from Category (private): _parseval

Inherited from featurestructure.FeatureStructure: parse

Class Variables [hide private]
  headname = 'pos'
  requiredFeatures = ['/']
  _PARSE_RE = {'application': re.compile(r'<(app)\((\?[a-z][a-z]...
  k = 'name'
  v = re.compile(r'\s*([^\s\(\)"\'-=\[\]]+)\s*')
Instance Variables [hide private]

Inherited from cfg.Nonterminal (private): _symbol

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_repr(self, reentrances, reentrance_ids)

source code 
Returns:
A string representation of this feature structure.
Overrides: Category._repr

_parse(cls, s, position=0, reentrances=None)
Class Method

source code 

Helper function that parses a Category.

Returns:
A tuple (val, pos) of the feature structure created by parsing and the position where the parsed feature structure ends.
Overrides: Category._parse
(inherited documentation)

Class Variable Details [hide private]

_PARSE_RE

Value:
{'application': re.compile(r'<(app)\((\?[a-z][a-z]*)\s*,\s*(\?[a-z][a-\
z]*)\)>'),
 'arrow': re.compile(r'\s*->\s*'),
 'assign': re.compile(r'\s*=\s*'),
 'bool': re.compile(r'\s*([-\+])'),
 'bracket': re.compile(r'\s*\]\s*'),
 'categorystart': re.compile(r'\s*([^\s\(\)"\'-=,\[\]/]*)\s*([\[/])'),
 'comma': re.compile(r'\s*,\s*'),
...