metric / processors.py
Elron's picture
Upload processors.py with huggingface_hub
2746bef
raw
history blame
No virus
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')