Download code/frame_choice_syntax_projection.py from dfdu233/MeningiomaBench: direct link, hf CLI and curl.
- Browser
- Download file 899 Bytes
-
https://huggingface.co/datasets/dfdu233/MeningiomaBench/resolve/main/code/frame_choice_syntax_projection.py
- Command line
-
hf download hf://datasets/dfdu233/MeningiomaBench/code/frame_choice_syntax_projection.py
-
curl -L -o frame_choice_syntax_projection.py https://huggingface.co/datasets/dfdu233/MeningiomaBench/resolve/main/code/frame_choice_syntax_projection.py
899 Bytes
| """Post-hoc narrow frame-ID syntax projection; no prose interpretation or gold.""" | |
| import json | |
| import re | |
| def project(raw, allowed): | |
| try:parsed=json.loads(raw) | |
| except (ValueError,TypeError):parsed=None | |
| state=None;choice=None | |
| if isinstance(parsed,dict) and set(parsed)=={'frame_id'} and isinstance(parsed['frame_id'],str): | |
| choice=parsed['frame_id'];state='strict_object' | |
| elif isinstance(parsed,str):choice=parsed;state='json_string' | |
| elif isinstance(raw,str): | |
| match=re.fullmatch(r'\s*"frame_id"\s*:\s*"(F[1-9]\d*)"\s*',raw) | |
| if match:choice=match[1];state='single_field_fragment' | |
| elif re.fullmatch(r'\s*F[1-9]\d*\s*',raw):choice=raw.strip();state='bare_frame_id' | |
| if choice not in allowed:return {'frame_id':None,'state':'unknown_or_invalid_syntax','strict':False} | |
| return {'frame_id':choice,'state':state,'strict':state=='strict_object'} | |