(self, cfg: Optional[Dict] = None)
| 472 | }] |
| 473 | |
| 474 | def __init__(self, cfg: Optional[Dict] = None): |
| 475 | super().__init__(cfg) |
| 476 | self.data_root = self.cfg.get('path', os.path.join(DEFAULT_WORKSPACE, 'tools', self.name)) |
| 477 | self.db = Storage({'storage_root_path': self.data_root}) |
| 478 | self.structured_doc = self.cfg.get('structured_doc', True) |
| 479 | |
| 480 | |
| 481 | self.parsers = { |
| 482 | 'pdf': parse_pdf, |
| 483 | 'docx': parse_word, |
| 484 | 'doc': parse_word, |
| 485 | 'pptx': parse_ppt, |
| 486 | 'txt': parse_txt, |
| 487 | 'jsonl': parse_txt, |
| 488 | 'jsonld': parse_txt, |
| 489 | 'pdb': parse_txt, |
| 490 | 'py': parse_txt, |
| 491 | 'html': parse_html, |
| 492 | 'xml': parse_xml, |
| 493 | 'csv': lambda p: parse_tabular_file(p, sep=','), |
| 494 | 'tsv': lambda p: parse_tabular_file(p, sep='\t'), |
| 495 | 'xlsx': parse_tabular_file, |
| 496 | 'xls': parse_tabular_file, |
| 497 | 'zip': self.parse_zip |
| 498 | } |
| 499 | |
| 500 | def call(self, params: Union[str, dict], **kwargs) -> Union[str, list]: |
| 501 | params = self._verify_json_format_args(params) |
nothing calls this directly
no test coverage detected