Download circle_location/utils.py from aggr8/Percept-V: direct link, hf CLI and curl.
- Browser
- Download file 871 Bytes
-
https://huggingface.co/datasets/aggr8/Percept-V/resolve/main/circle_location/utils.py
- Command line
-
hf download hf://datasets/aggr8/Percept-V/circle_location/utils.py
-
curl -L -o utils.py https://huggingface.co/datasets/aggr8/Percept-V/resolve/main/circle_location/utils.py
871 Bytes
| import re | |
| def output_from_text(response): | |
| try: | |
| pattern1 = r"QUADRANT:\s*(\d+)" | |
| pattern2 = r"COUNT:\s*(\d+)" | |
| # Extract the number of nodes and edges using regex | |
| match1 = re.search(pattern1, response) | |
| match2 = re.search(pattern2, response) | |
| if match1 and match2: | |
| quad = match1.group(1).strip() | |
| count = match2.group(1).strip() | |
| return { | |
| "OUTPUT": { | |
| "Quadrant": int(quad), | |
| "Count": int(count) | |
| }, | |
| "ERROR": None | |
| } | |
| else: | |
| return { | |
| "OUTPUT": None, | |
| "ERROR": "No match found" | |
| } | |
| except Exception as e: | |
| return { | |
| "OUTPUT": None, | |
| "ERROR": f"Unexpected error while parsing {str(e)}\n" | |
| } |