Spaces:
Build error
Build error
Update app/tapas.py
Browse files- app/tapas.py +5 -7
app/tapas.py
CHANGED
|
@@ -84,7 +84,7 @@ def show_answers(queries, answers, aggregation_predictions_string):
|
|
| 84 |
Visualize the postprocessed answers.
|
| 85 |
"""
|
| 86 |
agg = {"NONE": lambda x: x, "SUM" : lambda x: sum(x), "AVERAGE": lambda x: (sum(x) / len(x)), "COUNT": lambda x: len(x)}
|
| 87 |
-
|
| 88 |
for query, answer, predicted_agg in zip(queries, answers, aggregation_predictions_string):
|
| 89 |
print(query)
|
| 90 |
if predicted_agg == "NONE":
|
|
@@ -92,15 +92,13 @@ def show_answers(queries, answers, aggregation_predictions_string):
|
|
| 92 |
else:
|
| 93 |
if all([not p.match(val) == None for val in answer.split(', ')]):
|
| 94 |
# print("Predicted answer: " + predicted_agg + "(" + answer + ") = " + str(agg[predicted_agg](list(map(float, answer.split(','))))))
|
| 95 |
-
|
| 96 |
elif predicted_agg == "COUNT":
|
| 97 |
# print("Predicted answer: " + predicted_agg + "(" + answer + ") = " + str(agg[predicted_agg](answer.split(','))))
|
| 98 |
-
|
| 99 |
else:
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
|
| 105 |
def execute_query(query, table):
|
| 106 |
|
|
|
|
| 84 |
Visualize the postprocessed answers.
|
| 85 |
"""
|
| 86 |
agg = {"NONE": lambda x: x, "SUM" : lambda x: sum(x), "AVERAGE": lambda x: (sum(x) / len(x)), "COUNT": lambda x: len(x)}
|
| 87 |
+
result = ''
|
| 88 |
for query, answer, predicted_agg in zip(queries, answers, aggregation_predictions_string):
|
| 89 |
print(query)
|
| 90 |
if predicted_agg == "NONE":
|
|
|
|
| 92 |
else:
|
| 93 |
if all([not p.match(val) == None for val in answer.split(', ')]):
|
| 94 |
# print("Predicted answer: " + predicted_agg + "(" + answer + ") = " + str(agg[predicted_agg](list(map(float, answer.split(','))))))
|
| 95 |
+
result = "Predicted answer: " + str(agg[predicted_agg](list(map(float, answer.split(',')))))
|
| 96 |
elif predicted_agg == "COUNT":
|
| 97 |
# print("Predicted answer: " + predicted_agg + "(" + answer + ") = " + str(agg[predicted_agg](answer.split(','))))
|
| 98 |
+
result = "Predicted answer: " + str(agg[predicted_agg](answer.split(',')))
|
| 99 |
else:
|
| 100 |
+
result = "Predicted answer: " + predicted_agg + " > " + answer
|
| 101 |
+
return result
|
|
|
|
|
|
|
| 102 |
|
| 103 |
def execute_query(query, table):
|
| 104 |
|