Eureka / src /eureka /math_agent /tools /problem_key.py
manxis-contact's picture
Add files using upload-large-folder tool
a30d31a verified
Raw
History Blame Contribute Delete
508 Bytes
from __future__ import annotations
import re
LEADS=(r'^\s*prove\s+or\s+disprove\s+',r'^\s*prove\s+',r'^\s*disprove\s+',r'^\s*resolve\s+',r'^\s*investigate\s+',r'^\s*study\s+')
def search_subject(problem,max_words=12):
s=problem.strip().split(';',1)[0].split('\n',1)[0].strip()
for pat in LEADS:
ns=re.sub(pat,'',s,flags=re.I)
if ns!=s:s=ns;break
s=re.sub(r'^the\s+','',s,flags=re.I).strip(' .:');w=s.split();return ' '.join(w[:max_words]) if w else problem.strip()[:120]