Skip to content

fix(MedCalc_Bench): guard calid-69 ground_truth regex match (AttributeError)#2523

Open
WatchTree-19 wants to merge 1 commit into
open-compass:mainfrom
WatchTree-19:fix-medcalc-groundtruth-guard
Open

fix(MedCalc_Bench): guard calid-69 ground_truth regex match (AttributeError)#2523
WatchTree-19 wants to merge 1 commit into
open-compass:mainfrom
WatchTree-19:fix-medcalc-groundtruth-guard

Conversation

@WatchTree-19

Copy link
Copy Markdown

problem

in MedCalc_Bench.check_correctness, the calid == 69 (date-difference) branch matches the ground_truth with a regex and immediately calls .group() unguarded:

match = re.search(r"...(\d+)...(\d+)...", ground_truth)
ground_truth = f'({match.group(1)}, {match.group(3)})'   # AttributeError if match is None

the identical regex applied to the model answer two lines down is guarded (if match:), so the asymmetry is clearly unintentional. a calid-69 reference that doesn't fit the (N weeks, M days) pattern makes re.search return None, and None.group(1) raises AttributeError, crashing scoring for the run.

re.search(r"...(\d+)...", "no duration here").group(1)  # AttributeError

fix

guard the ground_truth match the same way as the answer match: only build the normalized tuple when both match, otherwise score the item as incorrect (can't be compared).

test

added tests/dataset/test_medcalc_check_correctness.py: an unparseable calid-69 ground_truth now scores 0 instead of raising; a well-formed one still scores correctly.

…ibuteError)

check_correctness used re.search(...).group() on ground_truth unguarded, while
the identical regex on the model answer two lines below is guarded with 'if
match'. A calid-69 reference that doesn't fit the (N weeks, M days) pattern
raised AttributeError, crashing scoring. Guard both symmetrically. +test.

Signed-off-by: WatchTree-19 <119982314+WatchTree-19@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants