From 452fec5fcebc256a4387c9a17fc450a87e2222fb Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Mon, 11 Jun 2018 15:47:19 +0200 Subject: log each rendering to text file with lexicon, tree, spellout --- lexicon.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'lexicon.py') diff --git a/lexicon.py b/lexicon.py index a2da32e..da7b6b1 100644 --- a/lexicon.py +++ b/lexicon.py @@ -4,8 +4,21 @@ from copy import deepcopy class Lexicon(object): - def __init__(self): + def __init__(self, minimumMetricUnit=0.5): self.categories = [] + self.minimumMetricUnit = minimumMetricUnit + + def __str__(self): + lexicon = [] + for i, lex in enumerate(self.categories): + lexicon.append(str(lex)) + return "\n".join(lexicon) + + def print(self): + print('Lexicon') + for i, lex in enumerate(self.categories): + lex.print() + print() def populate(self, grammar, number_categories=0): for x in range(number_categories): @@ -39,12 +52,6 @@ class Lexicon(object): nextLabel = self.categories[-1].label + 1 return nextLabel - def print(self): - print('Lexicon') - for i, lex in enumerate(self.categories): - lex.print() - print() - class Lexeme(object): """the specification of an dependant and its agreement""" @@ -63,6 +70,15 @@ class Lexeme(object): self.realization = {} self.label = 'unlabeled' + def __str__(self): + rep = str(self.label) + "\t" + str(self.cadence.ligature)+"\n" + rep += "\t" + str(self.cadence.function)+"\n" + rep += "\t" + str(self.cadence.path)+"\n" + if len(self.realization) > 0: + rep += "\t" + str(self.realization)+"\n" + return rep + + def print(self): print("\nlexeme "+str(self.label)) self.cadence.print() -- cgit v1.2.3