fix lm-eval task
Browse files- lm-eval-task/utils.py +2 -1
lm-eval-task/utils.py
CHANGED
|
@@ -49,12 +49,13 @@ def extract_longest_def_solve_code_block(text: str) -> dict | None:
|
|
| 49 |
# Matches ```language followed by content until ```
|
| 50 |
pattern = r'```([a-zA-Z0-9]+)\s*(.*?)\s*```'
|
| 51 |
matches = re.findall(pattern, text, re.DOTALL)
|
| 52 |
-
|
| 53 |
if not matches:
|
| 54 |
return None
|
| 55 |
|
| 56 |
# Filter only those including the solve definition
|
| 57 |
matches = [(lang, content) for lang, content in matches if 'def solve' in content]
|
|
|
|
|
|
|
| 58 |
|
| 59 |
# Select longest by content length
|
| 60 |
longest = max(matches, key=lambda x: len(x[1].strip()))
|
|
|
|
| 49 |
# Matches ```language followed by content until ```
|
| 50 |
pattern = r'```([a-zA-Z0-9]+)\s*(.*?)\s*```'
|
| 51 |
matches = re.findall(pattern, text, re.DOTALL)
|
|
|
|
| 52 |
if not matches:
|
| 53 |
return None
|
| 54 |
|
| 55 |
# Filter only those including the solve definition
|
| 56 |
matches = [(lang, content) for lang, content in matches if 'def solve' in content]
|
| 57 |
+
if len(matches) == 0:
|
| 58 |
+
return None
|
| 59 |
|
| 60 |
# Select longest by content length
|
| 61 |
longest = max(matches, key=lambda x: len(x[1].strip()))
|