Upload processors.py with huggingface_hub
Browse files14 unmodified lines1516171818192021222023242526272829303132333487 unmodified lines1221231241141251261271283 unmodified lines13213313413512413613713813914014 unmodified lines return str(text).strip()
class ToListByComma(FieldOperator):class Split(FieldOperator): delimiter: str = " " strip_every_element: bool = False
def process_value(self, text: Any) -> Any: return [x.strip() for x in text.split(",")] return [ x.strip() if self.strip_every_element else x for x in text.split(self.delimiter) ]
class ToListByComma(Split): delimiter = "," strip_every_element = True
class RegexParser(FieldOperator):87 unmodified lines
class TakeFirstWord(FieldOperator): def process_value(self, text: Any) -> Any: match = re.search(r"[\w]+", text) match = re.search(r"([-]*[0-9]+(\.([0-9]+))*)|([\w]+)", text) if match: return text[match.start() : match.end()] return ""3 unmodified lines def process_value(self, text: Any) -> Any: if text == "yes": return "1" if text == "no": return "0" return "0" return text
class ToYesOrNone(FieldOperator):processors.py+17-4