Skip to content

Commit ebc30e4

Browse files
committed
fixed check only 1 param selected logic
1 parent 38f31f3 commit ebc30e4

1 file changed

Lines changed: 9 additions & 105 deletions

File tree

evaluation_function/evaluation.py

Lines changed: 9 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -7,102 +7,6 @@
77
from evaluation_function.parsing.tree_builder import *
88

99

10-
# def parse_response(response: str) -> tuple[bool, Formula | str]:
11-
12-
# response = response.strip()
13-
14-
# # binaryOperators = ["↔","→","∨","∧"]
15-
# # TODO: keep this mapping somewhere else for maintainability
16-
# binaryOperators = {
17-
# "↔" : Biconditional,
18-
# "→" : Implication,
19-
# "∨" : Disjunction,
20-
# "∧" : Conjunction
21-
# }
22-
23-
# for binaryOperator in binaryOperators.keys():
24-
25-
# if binaryOperator in response:
26-
# split_index = response.rindex(binaryOperator)
27-
28-
# left = response[:split_index]
29-
# right = response[split_index+1:]
30-
31-
# # check left and right not empty strings
32-
# if not left:
33-
# return (False, f"missing text on left of {binaryOperator}")
34-
# elif not right:
35-
# return (False, f"missing text on right of {binaryOperator}")
36-
37-
# parse_left = parse_response(left)
38-
# parse_right = parse_response(right)
39-
40-
# error = False
41-
# err_msgs = []
42-
43-
# if not parse_left[0]:
44-
# error = True
45-
# err_msgs.append(parse_left[1])
46-
47-
# if not parse_right[0]:
48-
# error = True
49-
# err_msgs.append(parse_right[1])
50-
51-
# if error:
52-
# return (False, err_msgs.join("\n"))
53-
54-
# # both sides are find and valid
55-
# result = binaryOperators[binaryOperator](parse_left[1], parse_right[1])
56-
# return (True, result)
57-
58-
59-
# # TODO: keep this mapping somewhere else for maintainability
60-
# unaryOperators = {
61-
# "¬" : Negation
62-
# }
63-
64-
# for unaryOperator in unaryOperators.keys():
65-
66-
# #unary operator must syntactically be at the start of the string
67-
# if response[0] == unaryOperator:
68-
69-
# right = response[1:]
70-
# #check not empty
71-
# if not right:
72-
# return (False, f"missing text on right of {unaryOperator}")
73-
74-
# parse_right = parse_response(right)
75-
# if not parse_right[0]:
76-
# return parse_right
77-
78-
# result = unaryOperators[unaryOperator](parse_right[1])
79-
# return (True, result)
80-
81-
# # check if the formual is just True or Falsity
82-
83-
# singletons = { # not sure what the official term for these symbols is
84-
# "⊤" : Truth,
85-
# "⊥" : Falsity
86-
# }
87-
88-
# for singleton in singletons:
89-
90-
# if len(response) > 1 and singleton in response:
91-
# return (False, f"not allowed to use {singleton} in the atom identifier")
92-
93-
# elif response == singleton:
94-
# result = singletons[singleton]()
95-
# return (True, result)
96-
97-
# # response is likely an atom identifier
98-
99-
# return (True, Atom(response))
100-
101-
102-
103-
104-
105-
10610
def evaluation_function(
10711
response: Any,
10812
answer: Any,
@@ -149,22 +53,22 @@ def evaluation_function(
14953
tautology = params.get("tautology", False)
15054
satisfiability = params.get("satisfiability", False)
15155

56+
15257
#check that 1 and only 1 param is selected
153-
if not (equivalence ^ tautology ^ satisfiability):
58+
num_selected = sum([equivalence, tautology, satisfiability])
15459

155-
if not (equivalence or tautology or satisfiability):
156-
#no params selected
157-
return Result(
158-
is_correct=False,
159-
feedback_items=[("invalid param", "please select a param")]
160-
)
161-
162-
# more than one param selected
60+
if num_selected == 0:
61+
return Result(
62+
is_correct=False,
63+
feedback_items=[("invalid param", "please select a param")]
64+
)
65+
elif num_selected > 1:
16366
return Result(
16467
is_correct=False,
16568
feedback_items=[("invalid param", "please only select 1 param")]
16669
)
16770

71+
16872

16973
feedback = None
17074
is_correct = False

0 commit comments

Comments
 (0)