Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复单元格占多行多列,导出表格标注报错的问题 #119

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion PPOCRLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3181,7 +3181,6 @@ def exportJSON(self):
"""
export PPLabel and CSV to JSON (PubTabNet)
"""
import pandas as pd

# automatically save annotations
self.saveFilestate()
Expand Down
18 changes: 10 additions & 8 deletions libs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,16 @@ def convert_token(html_list):
elif col == "td":
token_list.extend(["<td>", "</td>"])
else:
token_list.append("<td")
if "colspan" in col:
_, n = col.split("colspan=")
token_list.append(' colspan="{}"'.format(int(n)))
if "rowspan" in col:
_, n = col.split("rowspan=")
token_list.append(' rowspan="{}"'.format(int(n)))
token_list.extend([">", "</td>"])
token_list.append("<td") # Start the td tag
# Use regex to match "colspan" and "rowspan" attributes and their values
colspan_match = re.search(r"colspan=(\d+)", col)
rowspan_match = re.search(r"rowspan=(\d+)", col)
if colspan_match:
token_list.append(f' colspan="{colspan_match.group(1)}"')
if rowspan_match:
token_list.append(f' rowspan="{rowspan_match.group(1)}"')
token_list.append(">") # End the opening td tag
token_list.append("</td>") # Close the td tag
token_list.append("</tr>")
token_list.append("</tbody>")

Expand Down