Package jazzparser :: Module grammar
[hide private]
[frames] | no frames]

Module grammar

source code

Grammar processing for the Jazz Parser.

This module is used to read the XML grammar files for the parser. They are stored in the OpenCCG grammar format (roughly). This provides the interface to the grammar and the formalism for the parser and tagger.


Author: Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>

Classes [hide private]
  Grammar
Represents a grammar read in from an XML grammar file.
  Family
A lexical family.
  MorphItem
A morphological item - a word.
  MacroItem
Not yet implemented.
  EntriesItem
  ChordClass
Representation of a chord class.
  EquivalenceMap
A mapping from some of the morph entries to others via a root change.
  EquivalenceEntry
Like a MorphItem.
  GrammarReadError
Thrown if there's a problem while reading the grammar description from the XML file.
  GrammarLookupError
Raised if there are problems consulting the grammar.
Functions [hide private]
 
get_grammar_names()
Returns a list of all valid grammar names.
source code
 
get_grammar(name=None)
Returns an instance of Grammar for the named grammar.
source code
Variables [hide private]
  logger = logging.getLogger("main_logger")
  _loaded_grammars = {}
  __package__ = 'jazzparser'
Function Details [hide private]

get_grammar(name=None)

source code 

Returns an instance of Grammar for the named grammar.

This is like instantiating Grammar with the grammar with the name as an argument, but caches loaded grammars. If the named grammar has been previously loaded, the same instance will be returned again.

If you want to force a new instance, use Grammar(name). However, most of the time there's no need, since Grammar is essentially a read-only data structure.