diff --git a/cfg_utils.py b/cfg_utils.py index f2b02961b8b6cc31a7c64a4f40e2340289803150..8eb1795eb86b2fecab3c461f85ac009af5c7f49f 100644 --- a/cfg_utils.py +++ b/cfg_utils.py @@ -393,7 +393,7 @@ class CFGBoltzmann: # Fzero(i, N) = [sum(Fprim(i, j, 1, N)) for all possible j (j = [1, number of rules for nonterminal i])] - @functools.lru_cache + @functools.lru_cache(maxsize=8192) def Fzero(self, nonterminal_index, exact_length_total): # First find the nonterminal in the rulepack @@ -412,7 +412,8 @@ class CFGBoltzmann: # Fprim is where the complicated case analysis lives. - @functools.lru_cache + + @functools.lru_cache(maxsize=8192) def Fprim(self, nonterminal_index, which_RHS, how_far_into_the_RHS, exact_length_total): #print("arguments are", nonterminal_index, which_RHS, how_far_into_the_RHS, exact_length_total) @@ -509,7 +510,7 @@ z = CFGBoltzmann(rules, list_of_nonterminals, list_of_terminals) rulepack_cooked = z.preprocessor() -print("XXXXXXXXXXXXXXXX", z.Fzero(0, 21)) +print("XXXXXXXXXXXXXXXX", z.Fzero(0, 101)) # Furthermore, we also note that the description of a context-free grammar is *itself* context-free