| | import math |
| | import re |
| |
|
| |
|
| | def calculate_score_fullscale(docs, results): |
| | reference = eval(docs["reference_answer_fullscale"]) |
| | user = dict(re.findall(r"(\w+):\s+(\d+)", results[0])) |
| | |
| | if len(user.items()) != 4: |
| | |
| | |
| | return {"eqbench": 0, "percent_parseable": 0} |
| | emotions_dict = {} |
| | for emotion, user_emotion_score in user.items(): |
| | for i in range(1, 5): |
| | if emotion == reference[f"emotion{i}"]: |
| | emotions_dict[emotion] = True |
| | if len(emotions_dict) != 4: |
| | print("! Error: emotions did not match reference") |
| | print(user) |
| | return {"eqbench": 0, "percent_parseable": 0} |
| |
|
| | difference_tally = ( |
| | 0 |
| | ) |
| |
|
| | |
| | for emotion, user_emotion_score in user.items(): |
| | |
| | for i in range(1, 5): |
| | if emotion == reference[f"emotion{i}"]: |
| | d = abs( |
| | float(user_emotion_score) - float(reference[f"emotion{i}_score"]) |
| | ) |
| | |
| | if d == 0: |
| | scaled_difference = 0 |
| | elif d <= 5: |
| | |
| | |
| | |
| | scaled_difference = 6.5 * (1 / (1 + math.e ** (-1.2 * (d - 4)))) |
| |
|
| | else: |
| | scaled_difference = d |
| | difference_tally += scaled_difference |
| |
|
| | |
| | |
| | adjust_const = 0.7477 |
| | final_score = 10 - (difference_tally * adjust_const) |
| | final_score_percent = final_score * 10 |
| |
|
| | return {"eqbench": final_score_percent, "percent_parseable": 100} |
| |
|