Upload processors.py with huggingface_hub
Browse files14 unmodified lines15161718192021222387 unmodified lines1111121131141151161173 unmodified lines12112212312412512612714 unmodified linesreturn str(text).strip()class ToListByComma(FieldOperator):def process_value(self, text: Any) -> Any:return [x.strip() for x in text.split(",")]class RegexParser(FieldOperator):87 unmodified linesclass TakeFirstWord(FieldOperator):def process_value(self, text: Any) -> Any:match = re.search(r"[\w]+", text)if match:return text[match.start() : match.end()]return ""3 unmodified linesdef process_value(self, text: Any) -> Any:if text == "yes":return "1"return "0"class ToYesOrNone(FieldOperator):14 unmodified lines151617181920212223242526272829303132333487 unmodified lines1221231241251261271283 unmodified lines13213313413513613713813914014 unmodified linesreturn str(text).strip()class Split(FieldOperator):delimiter: str = " "strip_every_element: bool = Falsedef process_value(self, text: Any) -> Any:return [x.strip() if self.strip_every_element else xfor x in text.split(self.delimiter)]class ToListByComma(Split):delimiter = ","strip_every_element = Trueclass RegexParser(FieldOperator):87 unmodified linesclass TakeFirstWord(FieldOperator):def process_value(self, text: Any) -> Any:match = re.search(r"([-]*[0-9]+(\.([0-9]+))*)|([\w]+)", text)if match:return text[match.start() : match.end()]return ""3 unmodified linesdef process_value(self, text: Any) -> Any:if text == "yes":return "1"if text == "no":return "0"return textclass ToYesOrNone(FieldOperator):
processors.py+17-4