Skip to content

Commit 7e04484

Browse files
committed
Fixes nltk#3046: corrected ResolutionProver.find_answers such that incorrect clauses no longer are added as answers
1 parent 1642942 commit 7e04484

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

nltk/inference/resolution.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ def find_answers(self, verbose=False):
141141
answers = set()
142142
answer_ex = VariableExpression(Variable(ResolutionProver.ANSWER_KEY))
143143
for clause in self._clauses:
144-
for term in clause:
145-
if (
146-
isinstance(term, ApplicationExpression)
147-
and term.function == answer_ex
148-
and not isinstance(term.argument, IndividualVariableExpression)
149-
):
150-
answers.add(term.argument)
144+
if (
145+
len(clause) == 1
146+
and isinstance(clause[0], ApplicationExpression)
147+
and clause[0].function == answer_ex
148+
and not isinstance(clause[0].argument, IndividualVariableExpression)
149+
):
150+
answers.add(clause[0].argument)
151151
return answers
152152

153153
@staticmethod

0 commit comments

Comments
 (0)