koustuvs's picture
Initial commit
5f0fbb6
raw
history blame contribute delete
525 Bytes
import re
def extract_single_option(video_llm_output) -> Union[str, bool]:
video_llm_output = video_llm_output.lower()
pattern = r"(Answer|Assistant)?:?\s*([AB])\b"
matches = re.findall(pattern, video_llm_output, re.IGNORECASE)
if matches:
actual_answer = matches[1] if len(matches) > 1 else matches[0]
answer = actual_answer[1].lower()
return answer
elif len(video_llm_output) == 1:
answer = video_llm_output.lower()
return answer
else:
return False