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>
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
__package__ = 'jazzparser.data'
|
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.
|
|
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.
|