Skip to content

Commit 7137405

Browse files
authored
Merge pull request nltk#3066 from asishm/bugfix-lambda-closure-leak
lambda loop variable closure fix
2 parents 369cb9f + 056ea9c commit 7137405

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nltk/sem/boxer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,15 @@ def _handle_time_expression(self, arg):
530530
else:
531531
return None
532532
self.assertToken(self.token(), ")")
533+
534+
def func_gen(x):
535+
return lambda sent_index, word_indices: x
536+
533537
return [
534538
lambda sent_index, word_indices: BoxerPred(
535539
self.discourse_id, sent_index, word_indices, arg, tok, "n", 0
536540
)
537-
] + [lambda sent_index, word_indices: cond for cond in conds]
541+
] + [func_gen(cond) for cond in conds]
538542

539543
def _handle_date(self, arg):
540544
# []: (+), []:'XXXX', [1004]:'04', []:'XX'

0 commit comments

Comments
 (0)