Download processors.py from unitxt/data: direct link, hf CLI and curl.
- Browser
- Download file 452 Bytes
-
https://huggingface.co/datasets/unitxt/data/resolve/1f747a809c4fce0bfebb1080a44977bdcdab950f/processors.py
- Command line
-
hf download hf://datasets/unitxt/data@1f747a809c4fce0bfebb1080a44977bdcdab950f/processors.py
-
curl -L -o processors.py https://huggingface.co/datasets/unitxt/data/resolve/1f747a809c4fce0bfebb1080a44977bdcdab950f/processors.py
452 Bytes
| import re | |
| from .operator import BaseFieldOperator | |
| class ToString(BaseFieldOperator): | |
| def process(self, instance): | |
| return str(instance) | |
| class RegexParser(BaseFieldOperator): | |
| """ | |
| A processor that uses regex in order to parse a string. | |
| """ | |
| regex: str | |
| def process(self, text): | |
| matches = re.findall(self.regex, text) | |
| return matches | |
| # add_to_catalog(ToString('prediction'), 'processors', 'to_string') | |