summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHouyhnhnm <hykusb@bitmai.la>2018-06-03 19:34:34 +0200
committerHouyhnhnm <hykusb@bitmai.la>2018-06-03 19:34:34 +0200
commit6f14ded166e35879e0522f2e62347a3a709518e4 (patch)
treea191d9f3b020a94b4769293772939c8fbf15f2f4
parent01071c8123e6b30eeff88272bf4fc7325d62dd5a (diff)
feature unification, spellout
-rw-r--r--lexicon.py3
-rw-r--r--main.py6
-rw-r--r--passage.py6
-rw-r--r--spec.py19
4 files changed, 26 insertions, 8 deletions
diff --git a/lexicon.py b/lexicon.py
index c7eef6a..cd6d90a 100644
--- a/lexicon.py
+++ b/lexicon.py
@@ -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)
diff --git a/main.py b/main.py
index 7cf66a2..478c535 100644
--- a/main.py
+++ b/main.py
@@ -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...
diff --git a/passage.py b/passage.py
index e88926e..b95ad2c 100644
--- a/passage.py
+++ b/passage.py
@@ -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
diff --git a/spec.py b/spec.py
index 4125d97..65e6ec8 100644
--- a/spec.py
+++ b/spec.py
@@ -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 = [