AlibabaResearch / AlibabaResearch/AdvancedLiterateMachinery

postprocessing of the result

Đang mở
#96 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
1.8k
Fork
195
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I wonder if there is any script that can help to reconstruct (concatinating `text_lists` w.r.t to the polygon positions) in order to form text blocks ? is there any such post-processing analysis that can create comprehensive json file ?

my approach is to create a csv file

```
import json
import csv

input_json_file = '20213684_DocXChain.json'
output_csv_file = 'compiled_text.csv'

# Load JSON data
with open(input_json_file, 'r') as file:
json_data = json.load(file)

# Prepare data for CSV
csv_data = []
for page_data in json_data:
page_number = page_data['page']
for info in page_data['information']:
category_name = info['category_name']
region_poly = info['region_poly']
for text_info in info['text_list']:
position = text_info['position']
content = " ".join(text_info['content'])
# Splitting position into individual coordinates
pos_x1, pos_y1, pos_x2, pos_y2, pos_x3, pos_y3, pos_x4, pos_y4 = position
csv_data.append([page_number, content, pos_x1, pos_y1, pos_x2, pos_y2, pos_x3, pos_y3, pos_x4, pos_y4, category_name, region_poly])

# Write data to CSV
with open(output_csv_file, 'w', newline='', encoding='utf-8') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['Page Number', 'Content', 'PosX1', 'PosY1', 'PosX2', 'PosY2', 'PosX3', 'PosY3', 'PosX4', 'PosY4', 'Category Name', 'Region Poly'])
writer.writerows(csv_data)

print(f"CSV file written to {output_csv_file}")

```

then sort like

```
aa = pd.read_csv(output_csv_file)
sorted_aa = aa.sort_values(by=['ColumnSide', 'PosY1'], ascending=[True, True])
sorted_aa
```

but the orders are not correct

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.