add rebuild result
Showing
2 changed files
with
9 additions
and
2 deletions
| ... | @@ -255,7 +255,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -255,7 +255,7 @@ class Command(BaseCommand, LoggerMixin): |
| 255 | result_dict = ocr_res.get('data', {}) | 255 | result_dict = ocr_res.get('data', {}) |
| 256 | 256 | ||
| 257 | wb = BSWorkbook(set(), set(), set(), set(), set()) | 257 | wb = BSWorkbook(set(), set(), set(), set(), set()) |
| 258 | wb.ltgt_build(label, result_dict) | 258 | rebuild_res = wb.ltgt_build(label, result_dict) |
| 259 | wb.remove_base_sheet() | 259 | wb.remove_base_sheet() |
| 260 | wb.save(excel_path) | 260 | wb.save(excel_path) |
| 261 | except Exception as e: | 261 | except Exception as e: | ... | ... |
| ... | @@ -704,21 +704,28 @@ class BSWorkbook(Workbook): | ... | @@ -704,21 +704,28 @@ class BSWorkbook(Workbook): |
| 704 | 704 | ||
| 705 | def ltgt_build(self, label, result_dict): | 705 | def ltgt_build(self, label, result_dict): |
| 706 | ws = self.create_sheet(label) | 706 | ws = self.create_sheet(label) |
| 707 | rebuild_res = {} | ||
| 707 | for key, value in result_dict.items(): | 708 | for key, value in result_dict.items(): |
| 708 | if isinstance(value, list): | 709 | if isinstance(value, list): |
| 709 | value_list = [dict_item.get('words') for dict_item in value] | 710 | value_list = [dict_item.get('words') for dict_item in value] |
| 710 | ws.append((key, *value_list)) | 711 | ws.append((key, '、'.join(value_list))) |
| 712 | rebuild_res[key] = '、'.join(value_list) | ||
| 711 | elif isinstance(value, dict): | 713 | elif isinstance(value, dict): |
| 712 | if 'words' in value: | 714 | if 'words' in value: |
| 713 | ws.append((key, value['words'])) | 715 | ws.append((key, value['words'])) |
| 716 | rebuild_res[key] = value['words'] | ||
| 714 | else: | 717 | else: |
| 715 | for sub_key, sub_value in value.items(): | 718 | for sub_key, sub_value in value.items(): |
| 716 | if isinstance(sub_value, dict): | 719 | if isinstance(sub_value, dict): |
| 717 | ws.append(('{0}: {1}'.format(key, sub_key), sub_value.get('words', ''))) | 720 | ws.append(('{0}: {1}'.format(key, sub_key), sub_value.get('words', ''))) |
| 721 | rebuild_res['{0}: {1}'.format(key, sub_key)] = sub_value.get('words', '') | ||
| 718 | else: | 722 | else: |
| 719 | ws.append(('{0}: {1}'.format(key, sub_key), sub_value)) | 723 | ws.append(('{0}: {1}'.format(key, sub_key), sub_value)) |
| 724 | rebuild_res['{0}: {1}'.format(key, sub_key)] = sub_value | ||
| 720 | else: | 725 | else: |
| 721 | ws.append((key, value)) | 726 | ws.append((key, value)) |
| 727 | rebuild_res[key] = value | ||
| 728 | return rebuild_res | ||
| 722 | 729 | ||
| 723 | def simple_license_rebuild(self, license_summary, document_scheme): | 730 | def simple_license_rebuild(self, license_summary, document_scheme): |
| 724 | # for ic_license_dict in license_summary.get(consts.IC_CLASSIFY, []): | 731 | # for ic_license_dict in license_summary.get(consts.IC_CLASSIFY, []): | ... | ... |
-
Please register or sign in to post a comment