38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import re
|
|
import string
|
|
|
|
|
|
def normalize_answer(s):
|
|
|
|
def remove_articles(text):
|
|
return re.sub(r'\b(a|an|the)\b', ' ', text)
|
|
|
|
def white_space_fix(text):
|
|
return ' '.join(text.split())
|
|
|
|
def remove_punc(text):
|
|
exclude = set(string.punctuation)
|
|
return ''.join(ch for ch in text if ch not in exclude)
|
|
|
|
def lower(text):
|
|
return text.lower()
|
|
|
|
return white_space_fix(remove_articles(remove_punc(lower(s))))
|
|
|
|
|
|
GENERAL_ORM_PROMPT = """You are an expert in verifying if two answers are the same.
|
|
Your input is a problem and two answers, Answer 1 and Answer 2. You need to check if they are equivalent.
|
|
Your task is to determine if two answers are equivalent, without attempting to solve the original problem.
|
|
Compare the answers to verify they represent identical values or meaning, even when written in different forms or notations.
|
|
|
|
Your output must follow the following format:
|
|
1) Provide an explanation for why the answers are equivalent or not.
|
|
2) Then provide your final answer in the form of: [[YES]] or [[NO]]
|
|
""" # noqa: E501
|
|
|
|
ORM_USER_TEMPLATE = """
|
|
Problem: {problem}
|
|
Answer 1: {answer_1}
|
|
Answer 2: {answer_2}
|
|
"""
|