Package jazzparser :: Package data :: Module trees
[hide private]
[frames] | no frames]

Module trees

source code

Building derivation trees from annotated chord sequences.

Trees are minimally represented in the database. Each chord may define certain pieces of additional tree information which influence the way its tree structure is built.

A default tree structure is defined by a left-to-right parsing algorithm, which applies rules as it may in a particular order. The algorithm does not parse properly, but uses only the slash direction information to decide what rule to apply. Essentially this results in trees in which slash categories are always composed as soon as possible and then applied. Consecutive atomic categories must unambiguously be combined by continuation. Coordination will never be used by the default trees. A minimal amount of information (the end of each coordinated constituent) can be specified on the chords to prompt the tree to use coordination. The first constituent is always as long as possible (which is a reasonable arbitrary canonical tree).

Note that this should not operate directly on sequences read from the database, but on their mirrors (see, since this allows it potentially to be used independently of the database.

Author: Mark Granroth-Wilding <>

Classes [hide private]
Partially represents a CCG category in a simple way.
The categories of some chords are unknown and not specified in the annotation.
Special type to place markers among the categories in the stack.
Marks the end of the first part of a coordination.
Superclass of nodes in syntactic trees.
An internal node in a syntactic tree.
A terminal node (leaf) in a syntactic tree.
The root of a syntactic tree.
Functions [hide private]
attach_tree(cat, inputs, rule)
Attach a non-terminal tree to a category on the basis of the inputs from which it was built.
source code
_comp(dir, stack)
Generic composition (use compf or compb).
source code
Forward composition
source code
Backward composition
source code
Forward application
source code
Backward application
source code
Tonic continuation
source code
Cadence coordination
source code
generalize_category(category, formalism)
Builds a simple GeneralizedCategory from a real grammatical category as represented in the parser (see the Music Keyspan formalism).
source code
build_tree_for_sequence(sequence, debug_stack=False, grammar=None, logger=None)
Run through the motions of parsing the sequence in order to build its tree structure.
source code
Given a syntactic tree using the SyntacticTreeNode classes, produces an NLTK tree.
source code
Variables [hide private]
  __package__ = ''
Function Details [hide private]

build_tree_for_sequence(sequence, debug_stack=False, grammar=None, logger=None)

source code 

Run through the motions of parsing the sequence in order to build its tree structure. Most of the structure is implicit in the lexical categories. Additional information is given in the TreeInfo model, associated with chords.


source code 

Given a syntactic tree using the SyntacticTreeNode classes, produces an NLTK tree. This is useful, for example, to display a tree: tree.draw(). You need NLTK installed to be able to do this.