Upload struct_data_operators.py with huggingface_hub
Browse files- struct_data_operators.py +6 -8
struct_data_operators.py
CHANGED
@@ -250,16 +250,15 @@ class TruncateTableCells(StreamInstanceOperator):
|
|
250 |
max_length: int = 15
|
251 |
table: str = None
|
252 |
text_output: Optional[str] = None
|
253 |
-
use_query: bool = False
|
254 |
|
255 |
def process(
|
256 |
self, instance: Dict[str, Any], stream_name: Optional[str] = None
|
257 |
) -> Dict[str, Any]:
|
258 |
-
table = dict_get(instance, self.table
|
259 |
|
260 |
answers = []
|
261 |
if self.text_output is not None:
|
262 |
-
answers = dict_get(instance, self.text_output
|
263 |
|
264 |
self.truncate_table(table_content=table, answers=answers)
|
265 |
|
@@ -337,7 +336,7 @@ class SerializeTableRowAsText(StreamInstanceOperator):
|
|
337 |
) -> Dict[str, Any]:
|
338 |
linearized_str = ""
|
339 |
for field in self.fields:
|
340 |
-
value = dict_get(instance, field
|
341 |
if self.max_cell_length is not None:
|
342 |
truncated_value = truncate_cell(value, self.max_cell_length)
|
343 |
if truncated_value is not None:
|
@@ -367,7 +366,7 @@ class SerializeTableRowAsList(StreamInstanceOperator):
|
|
367 |
) -> Dict[str, Any]:
|
368 |
linearized_str = ""
|
369 |
for field in self.fields:
|
370 |
-
value = dict_get(instance, field
|
371 |
if self.max_cell_length is not None:
|
372 |
truncated_value = truncate_cell(value, self.max_cell_length)
|
373 |
if truncated_value is not None:
|
@@ -427,13 +426,12 @@ class ListToKeyValPairs(StreamInstanceOperator):
|
|
427 |
|
428 |
fields: List[str]
|
429 |
to_field: str
|
430 |
-
use_query: bool = False
|
431 |
|
432 |
def process(
|
433 |
self, instance: Dict[str, Any], stream_name: Optional[str] = None
|
434 |
) -> Dict[str, Any]:
|
435 |
-
keylist = dict_get(instance, self.fields[0]
|
436 |
-
valuelist = dict_get(instance, self.fields[1]
|
437 |
|
438 |
output_dict = {}
|
439 |
for key, value in zip(keylist, valuelist):
|
|
|
250 |
max_length: int = 15
|
251 |
table: str = None
|
252 |
text_output: Optional[str] = None
|
|
|
253 |
|
254 |
def process(
|
255 |
self, instance: Dict[str, Any], stream_name: Optional[str] = None
|
256 |
) -> Dict[str, Any]:
|
257 |
+
table = dict_get(instance, self.table)
|
258 |
|
259 |
answers = []
|
260 |
if self.text_output is not None:
|
261 |
+
answers = dict_get(instance, self.text_output)
|
262 |
|
263 |
self.truncate_table(table_content=table, answers=answers)
|
264 |
|
|
|
336 |
) -> Dict[str, Any]:
|
337 |
linearized_str = ""
|
338 |
for field in self.fields:
|
339 |
+
value = dict_get(instance, field)
|
340 |
if self.max_cell_length is not None:
|
341 |
truncated_value = truncate_cell(value, self.max_cell_length)
|
342 |
if truncated_value is not None:
|
|
|
366 |
) -> Dict[str, Any]:
|
367 |
linearized_str = ""
|
368 |
for field in self.fields:
|
369 |
+
value = dict_get(instance, field)
|
370 |
if self.max_cell_length is not None:
|
371 |
truncated_value = truncate_cell(value, self.max_cell_length)
|
372 |
if truncated_value is not None:
|
|
|
426 |
|
427 |
fields: List[str]
|
428 |
to_field: str
|
|
|
429 |
|
430 |
def process(
|
431 |
self, instance: Dict[str, Any], stream_name: Optional[str] = None
|
432 |
) -> Dict[str, Any]:
|
433 |
+
keylist = dict_get(instance, self.fields[0])
|
434 |
+
valuelist = dict_get(instance, self.fields[1])
|
435 |
|
436 |
output_dict = {}
|
437 |
for key, value in zip(keylist, valuelist):
|