summaryrefslogtreecommitdiff
path: root/Qwen2.5-Eval/evaluation/latex2sympy/sandbox/sandbox_equality.py
diff options
context:
space:
mode:
authorzitian-gao <zitian.gao@outlook.com>2025-05-27 16:45:31 +0800
committerzitian-gao <zitian.gao@outlook.com>2025-05-27 16:45:31 +0800
commit7c792461c8e4e4f1f8734fed143630c74e76b27f (patch)
treecf6341ff9f2727424751da7a11a3bea6c39015bb /Qwen2.5-Eval/evaluation/latex2sympy/sandbox/sandbox_equality.py
parent16815c8c5ec263c4bd1a0af60030c1c0efa1421e (diff)
init eval
Diffstat (limited to 'Qwen2.5-Eval/evaluation/latex2sympy/sandbox/sandbox_equality.py')
-rwxr-xr-xQwen2.5-Eval/evaluation/latex2sympy/sandbox/sandbox_equality.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/Qwen2.5-Eval/evaluation/latex2sympy/sandbox/sandbox_equality.py b/Qwen2.5-Eval/evaluation/latex2sympy/sandbox/sandbox_equality.py
new file mode 100755
index 0000000..5e3f444
--- /dev/null
+++ b/Qwen2.5-Eval/evaluation/latex2sympy/sandbox/sandbox_equality.py
@@ -0,0 +1,75 @@
+from sympy import *
+from latex2sympy import process_sympy
+
+
+#
+# Equality Testing
+#
+
+answer_sets = [
+ {
+ 'correct_answer': '(x-y)(x+2y)',
+ 'student_answers': [
+ 'x^2+xy-2y^2',
+ '(x-y)(x+2y)',
+ '(x+2y)(x-y)',
+ '(2\\times y+x)(-y+x)',
+ '(y\\cdot 2+x)(-y+x)'
+ ]
+ },
+ {
+ 'correct_answer': '2\\pi \\variable{r}^2',
+ 'student_answers': [
+ '2\\pi \\variable{r}^2',
+ '\\pi 2\\variable{r}^2',
+ '2\\times \\pi \\times \\variable{r}^2',
+ '2\\pi \\variable{r} \\times \\variable{r}'
+ ]
+ },
+ {
+ 'correct_answer': '2x - 3y',
+ 'student_answers': [
+ '-3y + 2x'
+ ]
+ },
+ {
+ 'correct_answer': 'x\\times x',
+ 'student_answers': [
+ 'x\\times x',
+ 'x\\cdot x',
+ 'x^2',
+ '(\\sqrt{x})^{4}'
+ ]
+ },
+ {
+ 'correct_answer': '23e^{-1\\times \\sqrt{t^2}}',
+ 'student_answers': [
+ '23e^{-t}'
+ ]
+ },
+ {
+ 'correct_answer': 'a=x^2+1',
+ 'student_answers': [
+ 'x^2+1=a'
+ ]
+ }
+]
+
+for answer_set in answer_sets:
+ correct_answer = answer_set['correct_answer']
+ correct_answer_parsed = process_sympy(answer_set['correct_answer'])
+ for student_answer in answer_set['student_answers']:
+ student_answer_parsed = process_sympy(student_answer)
+ print('correct_answer (c): ', correct_answer, correct_answer_parsed)
+ print('student_answer (a): ', student_answer, student_answer_parsed)
+ print('')
+ print('Expression Tree (srepr(c) == srepr(a)) =>', srepr(correct_answer_parsed) == srepr(student_answer_parsed))
+ print('srepr(c) =>', srepr(correct_answer_parsed))
+ print('srepr(a) =>', srepr(student_answer_parsed))
+ print('')
+ # print('Structural (c == a) =>', correct_answer_parsed == student_answer_parsed)
+ print('Symbolic (simplify(c - s) == 0) =>', simplify(correct_answer_parsed - student_answer_parsed) == 0)
+ print('simplified =>', simplify(correct_answer_parsed - student_answer_parsed))
+ print('')
+ print('Numeric Substitution (c.equals(s)) =>', correct_answer_parsed.equals(student_answer_parsed))
+ print('-----------------------------------------------------')