Upload processors.py with huggingface_hub
Browse files74 unmodified lines757677787980818283848586878889904 unmodified lines95969798991001011021031041052 unmodified lines10810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314474 unmodified lines return splitted[0].strip()
class ConvertToBoolean(BaseFieldOperator): def process(self, instance): clean_instance = str(instance).strip().lower() if any(w in clean_instance for w in ["no", "not", "wrong", "false"]): return "FALSE" if any(w in clean_instance for w in ["yes", "right", "correct", "true"]): return "TRUE" return "OTHER"
class LowerCaseTillPunc(BaseFieldOperator): def process(self, instance): non_empty_line = instance.lower()4 unmodified lines return non_empty_line
class LowerCase(BaseFieldOperator): def process(self, instance): return instance.lower()
class FirstCharacter(BaseFieldOperator): def process(self, instance): match = re.search(r"\s*(\w)", instance)2 unmodified lines return ""
class TakeFirstWord(BaseFieldOperator): def process(self, instance): match = re.search(r"[\w]+", instance) if match: return instance[match.start() : match.end()] return ""
class YesNoToInt(BaseFieldOperator): def process(self, instance): if instance == "yes": return "1" return "0"
class ToYesOrNone(BaseFieldOperator): def process(self, instance): if instance == "yes": return "yes" return "none"
class StanceToProCon(BaseFieldOperator): def process(self, instance): if instance == "positive": return "PRO" if instance in ["negative", "suggestion"]: return "CON" return "none"
class StringOrNotString(BaseFieldOperator): string: str
processors.py+46