diff options
| author | Houyhnhnm <hykusb@bitmai.la> | 2018-06-07 14:16:34 +0200 |
|---|---|---|
| committer | Houyhnhnm <hykusb@bitmai.la> | 2018-06-07 14:16:34 +0200 |
| commit | 789e7c10bc8765d498ba9f1e4c3eac35b64b41e7 (patch) | |
| tree | 0872e3b8b3c26753579392743789c160d0def095 /lexicon.py | |
| parent | 2be56d2f3541cedd0c4e872aeb5b7da110d9b260 (diff) | |
render rhythms to score
Diffstat (limited to 'lexicon.py')
| -rw-r--r-- | lexicon.py | 40 |
1 files changed, 18 insertions, 22 deletions
@@ -39,9 +39,8 @@ class Lexicon(object): return nextLabel def print(self): + print('Lexicon') for i, lex in enumerate(self.categories): - print('Lexeme', str(i)) - print('--------') lex.print() print() @@ -51,24 +50,22 @@ class Lexeme(object): def __init__(self, cadence, anticipation=None, prolongation=None): self.cadence = cadence - # projections - self.anticipation = anticipation - self.prolongation = prolongation - - # dependents - self.antecedents = [] - self.consequents = [] + self.government = { + # projected features + 'anticipation': anticipation, + 'prolongation': prolongation, + # dependents + 'antecedents': [], + 'consequents': [], + } + self.realization = {} self.label = 'unlabeled' - def print(self): - print("\n"+str(self.label)) + print("\nlexeme "+str(self.label)) self.cadence.print() - print("anticipation:", self.anticipation) - print("prolongation:", self.prolongation) - print("antecedents:", self.antecedents) - print("consequents:", self.consequents) + pprint(self.government) def addAntecedent(self, category): self.antecedents.append(category) @@ -79,11 +76,11 @@ class Lexeme(object): return self def addAnticipation(self, projection): - self.anticipations.append(projection) + self.government['anticipation'].append(projection) return self def addProlongation(self, projection): - self.prolongations.append(projection) + self.government['prolongation'].append(projection) return self @@ -101,14 +98,13 @@ class Lexeme(object): def selectAnticipation(self): anticipation = None - if len(self.anticipations>0): - anticipation = choice(self.anticipations) + if len(self.government['anticipation']>0): + anticipation = choice(self.government['anticipation']) return anticipation def selectProlongation(self): prolongation = None - if len(self.prolongations>0): - prolongation = choice(self.prolongations) + if len(self.government['prolongation']>0): + prolongation = choice(self.government['prolongation']) return prolongation - |