Upload processors.py with huggingface_hub
Browse files- processors.py +8 -0
processors.py
CHANGED
@@ -46,6 +46,14 @@ class RegexParser(FieldOperator):
|
|
46 |
return re.findall(self.regex, text)
|
47 |
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
class LoadJson(FieldOperator):
|
50 |
def process_value(self, text: Any) -> Any:
|
51 |
try:
|
|
|
46 |
return re.findall(self.regex, text)
|
47 |
|
48 |
|
49 |
+
class ExtractWithRegex(RegexParser):
|
50 |
+
def process_value(self, text: Any) -> Any:
|
51 |
+
matches = super().process_value(text)
|
52 |
+
if matches:
|
53 |
+
return matches[0]
|
54 |
+
return ""
|
55 |
+
|
56 |
+
|
57 |
class LoadJson(FieldOperator):
|
58 |
def process_value(self, text: Any) -> Any:
|
59 |
try:
|