From 5312c7a6bd9d5013ddbaf0226b1185e0b14184bd Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Mon, 17 Aug 2020 13:23:41 -0600 Subject: [PATCH] bigger memoization table size --- cfg_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cfg_utils.py b/cfg_utils.py index f2b0296..8eb1795 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 -- GitLab