Fix grading parse.

This commit is contained in:
Cristiano Ferreira
2023-08-31 09:55:04 +01:00
parent ca6094c3e7
commit a31489d850
3 changed files with 1228 additions and 7 deletions

2
app.py
View File

@@ -29,7 +29,7 @@ GRADING_TEMPERATURE = 0.1
GEN_QUESTION_TEMPERATURE = 0.9
GPT_3_5_TURBO = "gpt-3.5-turbo"
GPT_3_5_TURBO_16K = "gpt-3.5-turbo-16k"
GRADING_FIELDS = ['overall', 'comment', 'task_response']
GRADING_FIELDS = ['comment', 'overall', 'task_response']
GEN_FIELDS = ['question']
LISTENING_GEN_FIELDS = ['transcript', 'exercise']

View File

@@ -23,7 +23,7 @@ def process_response(input_string, quotation_check_field):
index = input_string.index('{')
# Extract everything after the first '{' (inclusive)
result = input_string[index:]
if re.search(r"'" + quotation_check_field + "':\s*'(.*?)'", result):
if re.search(r"'" + quotation_check_field + "':\s*'(.*?)'", result, re.DOTALL | re.MULTILINE):
parsed_string = result.replace("\"", "\\\"")
pattern = r"(?<!\w)'|'(?!\w)"
parsed_string = re.sub(pattern, '"', parsed_string)
@@ -35,8 +35,8 @@ def process_response(input_string, quotation_check_field):
else:
json_obj = json.loads(result)
return json_obj
except json.JSONDecodeError:
print("Invalid JSON string!")
except Exception as e:
print(f"Invalid JSON string! Exception: {e}")
else:
return input_string

1227
testing.py

File diff suppressed because it is too large Load Diff