Upload string_operators.py with huggingface_hub
Browse files- string_operators.py +17 -0
string_operators.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List
|
2 |
+
|
3 |
+
from .operators import FieldOperator
|
4 |
+
|
5 |
+
|
6 |
+
class Split(FieldOperator):
|
7 |
+
by: str
|
8 |
+
|
9 |
+
def process_value(self, value: str) -> List[str]:
|
10 |
+
return value.split(self.by)
|
11 |
+
|
12 |
+
|
13 |
+
class Join(FieldOperator):
|
14 |
+
by: str
|
15 |
+
|
16 |
+
def process_value(self, value: List[str]) -> str:
|
17 |
+
return self.by.join(value)
|