From 13d968ac6f17c7f6471d9dac957f947c11ab4ef5 Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Wed, 19 Aug 2020 18:43:24 -0600 Subject: [PATCH] start augmenting the function signatures to do the tree-building on the fly --- CFGBoltzmann.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CFGBoltzmann.py b/CFGBoltzmann.py index b05fef5..abe35e2 100644 --- a/CFGBoltzmann.py +++ b/CFGBoltzmann.py @@ -360,9 +360,12 @@ class CFGBoltzmann: def Gzero_shimmed(self, nonterminal, requested_length): nonterminal_index = self.nonterminals_ordered.index(nonterminal) - return self.Gzero(nonterminal_index, requested_length, 0) - def Gzero(self, nonterminal_index, requested_length, depth): + root_of_tree = TreeNode("START",[]) + operation_site = [0] + return (self.Gzero(nonterminal_index, requested_length, 0, root_of_tree, operation_site), root_of_tree) + + def Gzero(self, nonterminal_index, requested_length, depth, root_of_tree, operation_site): possibilities = self.Fzero(nonterminal_index, requested_length) chosen_production = self.normalized_choice(possibilities) print(" "* depth +"Gzero entering, with nonterminal", nonterminal_index, "and production rule number", chosen_production) -- GitLab