Fixed a visual bug in the tokenizer's print_token_list function. Updated the user interface in the main program demo.
This commit is contained in:
@@ -11,6 +11,7 @@ base_list = [1, 2, 4, 6, 12]
|
||||
tolerance = .05
|
||||
|
||||
variables = {}
|
||||
var_types = {}
|
||||
|
||||
def print_vars(vars):
|
||||
i = 0
|
||||
@@ -75,6 +76,13 @@ def modify_variable(var, vars):
|
||||
|
||||
exp_str = input("Enter the expression the student will use: ")
|
||||
wrong_response = input("Enter the wrong response for the expression: ")
|
||||
interest = input("Enter the default starting point for Interest variables: ")
|
||||
time = input("Enter the default starting point for Time variables: ")
|
||||
installment = input("Enter the default starting point for the Installment variables: ")
|
||||
|
||||
var_types["Interest"] = float(interest)
|
||||
var_types["Time"] = float(time)
|
||||
var_types["Installment"] = float(installment)
|
||||
|
||||
try:
|
||||
wrong_response = float(wrong_response)
|
||||
@@ -92,11 +100,11 @@ except ValueError:
|
||||
|
||||
tokens = tokenizer.get_tokens_from_expression_string(exp_str)
|
||||
rev_tokens = copy.deepcopy(tokens)
|
||||
#rev_tokens.reverse()
|
||||
|
||||
for t in rev_tokens:
|
||||
if t.type == token.TokenType.variable:
|
||||
variables[t.value] = expression.Variable(t.value, expression.Variable.get_variable_type(t.value[0]))
|
||||
variables[t.value].starting_point = var_types[expression.Variable.get_variable_type(t.value[0])]
|
||||
|
||||
selected_variable = None
|
||||
|
||||
@@ -173,6 +181,7 @@ for r in res:
|
||||
# tokenizer.print_token_list(answers[k])
|
||||
|
||||
with open("results.txt", "w") as f:
|
||||
print("Answers Found: %d" %(len(answers)))
|
||||
for k in answers:
|
||||
f.write("Result: %s for expression: " %(format(k, ".6f")))
|
||||
f.write(tokenizer.stringify_token_list(answers[k]))
|
||||
|
||||
@@ -123,6 +123,8 @@ def print_token_list(tokens):
|
||||
if tk.type == token.TokenType.variable:
|
||||
if tk.is_negative_variable:
|
||||
print("-%s " %(tk.value), end = "")
|
||||
else:
|
||||
print("%s " %(tk.value), end ="")
|
||||
else:
|
||||
print("%s " %(tk.value), end = "")
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user