| Trees | Indices | Help |
|
|---|
|
|
object --+
|
Grammar
Represents a grammar read in from an XML grammar file. Initialised with the location of the XML file. Can be consulted to retrieve lexical entries in the grammar.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
|
|||
formalism = NoneFormalism definition (jazzparser.formalisms.FormalismBase) for the formalism used by the grammar instance. |
|||
grammar_file = NonePath to the grammar.xml file from which the grammar definition was loaded. |
|||
literal_functions = NoneDictionary of builtin semantic literal functions. |
|||
families = NoneDictionary of lexical entry families (each a list of lexical signs), keyed by POS. |
|||
inactive_families = NoneLike families. |
|||
morphs = NoneList of morph entries (MorphItem). |
|||
morph_items = NoneSame as morphs, but a dictionary indexed by the word attribute (identifier of word or word class) for easy lookup. |
|||
modality_tree = NoneInstance of jazzparser.formalisms.base.modalities.ModalityTree representing the hierarchical structure of modalities used in this grammar. |
|||
rules = NoneList of all the rules used by the grammar. |
|||
unary_rules = NoneList of unary rules. |
|||
binary_rules = NoneList of binary rules. |
|||
rules_by_name = NoneDictionary of rules, containing same entries as rules, keyed by the internal_name attribute. |
|||
lexical_rules = NoneList of special unary rules that are applied to lexical families when the grammar is instantiated to expand the lexicon. |
|||
chord_classes = NoneDict of ChordClass objects, indexed by name. |
|||
|
|||
|
entries_by_tag Gets all the tags recognised by the grammar. |
|||
|
pos_tags Convenience function to get the full list of POS tags allowed by the grammar. |
|||
|
tags_by_function Returns a dictionary mapping chord functions to POS tags (i.e. |
|||
|
Inherited from |
|||
|
|||
Creates a new grammar by reading from an XML grammar file. Words (morph items) are stored in morph_items. Families (lexical families) are stored in families. Instantiate this directly only if you want, for some reason, to be sure of getting a new instance of Grammar. Most of the time, you can load a named grammar using get_grammar, which will cache already loaded grammars and return the same instance again if you ask for the same name.
|
Given a word string, returns a list of the possible signs (as CCGSigns) that the grammar can assign to it. word may also be a Chord object. For now, this assumes that the input is a single chord in roman numeral notation and that spelling issues have already been resolved (e.g. that 6s have been removed). If tags is given it should be a list of strings. Signs will be restricted to those whose entry's tag name/POS is in the list. If you need to get an instantiated category from a lexical entry, use the methods on EntriesItem directly, or get_signs_for_tag. |
Returns a sign that can be assigned to the given word and that has the given tag. If the word cannot have that tag, returns None. |
Gets all the tags recognised by the grammar. The tags are returned as indices in a dict to the entry they represent. Note that these tags are unique identifiers of lexical items, not pos tags. If you want entries indexed by POS tags, just use grammar.families. |
Given a POS tag (roughly denoting a category), returns the function of the chord that is implicit in this interpretation. If the tag is not in the grammar or a function is not given for this tag in the lexicon, returns None. |
Returns a dictionary mapping chord functions to POS tags (i.e. category family names). |
|
|||
formalismFormalism definition (jazzparser.formalisms.FormalismBase) for the formalism used by the grammar instance. Always set.
|
grammar_filePath to the grammar.xml file from which the grammar definition was loaded. Always set.
|
literal_functionsDictionary of builtin semantic literal functions. May be None. Deprecated: Only used in very early versions of the grammar. Left here for backwards compatibility. May be removed altogether soon.
|
inactive_familiesLike families. Dictionary of families defined in the XML but marked as inactive in their definition. Always a list. May be empty.
|
morphsList of morph entries (MorphItem). Mapping from word classes to families. You probably don't want to access this directly usually, but to use Grammar's methods like get_signs_for_word.
|
rulesList of all the rules used by the grammar. These are instances of the rule classes, instantiated with the correct parameters and ready to apply to signs. Does not include lexical rules: see lexical_rules.
|
unary_rulesList of unary rules. Subset of rules. May be empty, but should always be a list.
|
binary_rulesList of binary rules. Subset of rules. May be empty, but should always be a list.
|
rules_by_nameDictionary of rules, containing same entries as rules, keyed by the internal_name attribute. There should not be more than one rule instance with the same internal name. If multiple are created when the grammar is instantiated, a GrammarReadError will be raised.
|
lexical_rulesList of special unary rules that are applied to lexical families when the grammar is instantiated to expand the lexicon. The lexicon will then include all the original lexical entries, plus any results of applying these rules to them. Empty list if no lexical rules are given.
|
|
|||
entries_by_tagGets all the tags recognised by the grammar. The tags are returned as indices in a dict to the entry they represent. Note that these tags are unique identifiers of lexical items, not pos tags. If you want entries indexed by POS tags, just use grammar.families.
|
pos_tagsConvenience function to get the full list of POS tags allowed by the grammar.
|
tags_by_functionReturns a dictionary mapping chord functions to POS tags (i.e. category family names).
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Nov 26 16:04:57 2012 | http://epydoc.sourceforge.net |