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 jazzparser.data.db_mirrors), since this allows it potentially to be used independently of the database.


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

Classes [hide private]
  GeneralizedCategory
Partially represents a CCG category in a simple way.
  SlashCategory
  AtomicCategory
  UnknownCategory
The categories of some chords are unknown and not specified in the annotation.
  StackMarker
Special type to place markers among the categories in the stack.
  CoordinationMiddleMarker
Marks the end of the first part of a coordination.
  SyntacticTreeNode
Superclass of nodes in syntactic trees.
  SyntacticNonTerminal
An internal node in a syntactic tree.
  SyntacticTerminal
A terminal node (leaf) in a syntactic tree.
  SyntacticTreeRoot
The root of a syntactic tree.
  TreeBuildError
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
 
compf(stack)
Forward composition
source code
 
compb(stack)
Backward composition
source code
 
appf(stack)
Forward application
source code
 
appb(stack)
Backward application
source code
 
cont(stack)
Tonic continuation
source code
 
coord(stack)
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
 
tree_to_nltk(intree)
Given a syntactic tree using the SyntacticTreeNode classes, produces an NLTK tree.
source code
Variables [hide private]
  __package__ = 'jazzparser.data'
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.

tree_to_nltk(intree)

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.