diff options
| author | Houyhnhnm <hykusb@bitmai.la> | 2018-06-03 19:34:34 +0200 |
|---|---|---|
| committer | Houyhnhnm <hykusb@bitmai.la> | 2018-06-03 19:34:34 +0200 |
| commit | 6f14ded166e35879e0522f2e62347a3a709518e4 (patch) | |
| tree | a191d9f3b020a94b4769293772939c8fbf15f2f4 | |
| parent | 01071c8123e6b30eeff88272bf4fc7325d62dd5a (diff) | |
feature unification, spellout
| -rw-r--r-- | lexicon.py | 3 | ||||
| -rw-r--r-- | main.py | 6 | ||||
| -rw-r--r-- | passage.py | 6 | ||||
| -rw-r--r-- | spec.py | 19 |
4 files changed, 26 insertions, 8 deletions
@@ -35,7 +35,7 @@ class Lexicon(object): def nextLabel(self): nextLabel = 0 if len(self.categories) > 0: - lexeme = self.categories[-1].label + 1 + nextLabel = self.categories[-1].label + 1 return nextLabel def print(self): @@ -62,6 +62,7 @@ class Lexeme(object): self.label = 'unlabeled' def print(self): + print("\n"+str(self.label)) self.cadence.print() print("anticipation:", self.anticipation) print("prolongation:", self.prolongation) @@ -30,14 +30,14 @@ lexicon.populate(g, 4) lexicon.print() passage = Passage(size=12) -passage.printSyntax() realization = passage.spellout(lexicon) - -pprint(realization) +passage.printSyntax() for lex in realization: lex.print() +# next: go through spellout, create musical data, append to music21 score +# then: add good lexemes, dependency of good lexeme pairs to lexicon pre-population, iteratively... @@ -16,15 +16,16 @@ class Passage(object): for i, node in enumerate(self.tree.levelorder): node.value = i node.unify = {} + self.unified = [] def printSyntax(self): print(self.tree) def spellout(self, lexicon): - # prolonged features trickle down to leaves for node in self.tree.levelorder: node.lexeme = lexicon.selectLexeme() + node.value = node.lexeme.label if node.left: node.left.unify = copy(node.unify) @@ -49,7 +50,7 @@ class Passage(object): spellout = [] # now read out nodes into list, with prolonged features replacing lexical features - for node in self.tree.levelorder: + for node in self.tree.inorder: next_lexeme = deepcopy(node.lexeme) for feat in node.unify.keys(): if feat == 'footprint': @@ -59,6 +60,7 @@ class Passage(object): if feat in ['range','figure','tilt']: next_lexeme.cadence.path[feat] = node.unify[feat] spellout.append(next_lexeme) + self.unified = spellout return spellout @@ -3,16 +3,26 @@ from grammar import * footprintRules = [ [{ 'span': [2], - 'gait': ['double','triple'], + 'gait': ['double'], 'foot': [[-1/2, 0, 1/2]], 'step': [[0, 1/2], [0, 1/2], [0, 1/2]], }], + [{ + 'span': [4], + 'gait': ['triple'], + 'foot': [[-1/2, 0, 1/2]], + 'step': [[0], [1/2], [0]], + }], ] functionRules = [ { 'address': ['A1','B1'], - 'transposition': [-1,0,1], + 'transposition': [-1], + }, + { + 'address': ['C1','D1'], + 'transposition': [0], }, ] @@ -22,6 +32,11 @@ pathRules = [ 'figure': ['rampUp', 'rampDown'], 'tilt': ['float', 'dive'], }, + { + 'range': [5,6,7], + 'figure': ['stepUp', 'stepDown'], + 'tilt': ['rise', 'fall'], + }, ] anticipationRules = [ |