Download circle_boxes/utils.py from aggr8/Percept-V: direct link, hf CLI and curl.
- Browser
- Download file 735 Bytes
-
https://huggingface.co/datasets/aggr8/Percept-V/resolve/main/circle_boxes/utils.py
- Command line
-
hf download hf://datasets/aggr8/Percept-V/circle_boxes/utils.py
-
curl -L -o utils.py https://huggingface.co/datasets/aggr8/Percept-V/resolve/main/circle_boxes/utils.py
735 Bytes
| import re | |
| def output_from_text(text): | |
| #extract the number in the last line of text | |
| try: | |
| lines = text.strip().split("\n") | |
| lines = list(filter(None, lines)) | |
| pattern = r'^[^a-zA-Z0-9\s]+$' | |
| lines = [s for s in lines if not re.fullmatch(pattern, s)] | |
| answer = -1 | |
| answer = int(re.findall(r"\b\d+\b", lines[-1])[0]) | |
| if answer != -1: | |
| return { | |
| "OUTPUT": answer, | |
| "ERROR": None | |
| } | |
| else: | |
| return{ | |
| "OUTPUT": None, | |
| "ERROR": 'Does not give correct format' | |
| } | |
| except Exception as e: | |
| return { | |
| "OUTPUT": None, | |
| "ERROR": str(e) | |
| } |