diff --git a/cfg_utils.py b/cfg_utils.py index fc8e271678cca245e7614836cea5e5ffcf910e87..0d5ebc2de82d2cc2dcc47e8e56905b6a33ee3b86 100644 --- a/cfg_utils.py +++ b/cfg_utils.py @@ -361,10 +361,8 @@ if __name__ == '__main__': class CFGBoltzmann: def __init__(self, rules, nonterminals, terminals): self.unitary_rules = rules - print("nonterminal list is", nonterminals) self.nonterminals = nonterminals self.terminals = terminals - print("terminal list is", terminals) def preprocessor(self): unitary_rules = self.unitary_rules @@ -380,8 +378,12 @@ class CFGBoltzmann: rulepack_list = [] + list_of_terminals_in_sync_with_rulepack = [] for x in factorized_rulepack: rulepack_list.append((x, factorized_rulepack[x])) + list_of_terminals_in_sync_with_rulepack.append(x) + self.nonterminals_ordered = list_of_terminals_in_sync_with_rulepack + print("ORDERED nonterminal list is", self.nonterminals_ordered) self.processed_rulepack = rulepack_list @@ -447,6 +449,14 @@ class CFGBoltzmann: assert (xijk in self.nonterminals) print("xijk", xijk, "is a NONterminal!") print("lenghts of RHS In question is", len(RHS_in_question)) + if (how_far_into_the_RHS == (len(RHS_in_question) - 1)): + # CASE C + # we now calculate the index of nonterminal at index K + + new_nonterminal_index = self.nonterminals_ordered.index(xijk) + print("NEW NONTERMINAL INDDEX IS", new_nonterminal_index) + #reduct = self.Fzero() + return 0