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

feat: table evaluations for fixed html table generation #3196

Merged

Conversation

pawel-kmiecik
Copy link
Contributor

Update to the evaluation script to handle correct HTML syntax for tables.
See Unstructured-IO/unstructured-inference#355 for details.

This change:

  • modifies transforming HTML tables to evaluation internal cells format
  • fixes the indexing of the output (internal format cells) when HTML cells use spans

@@ -32,21 +59,39 @@ def _convert_table_from_html(content: str) -> List[Dict[str, Any]]:
if headers:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be simplified to

cells = row.findAll(["th", "td"])
for j, cell_data in enumerate(cells):
    cell = {
        "y": i,
        "x": j,
        "w": int(cell_data.attrs.get("colspan", 1)),
        "h": int(cell_data.attrs.get("rowspan", 1)),
        "content": cell_data.text,
    }
    table_data.append(cell)

@pawel-kmiecik pawel-kmiecik added this pull request to the merge queue Jun 14, 2024
Merged via the queue into main with commit 29e64eb Jun 14, 2024
46 checks passed
@pawel-kmiecik pawel-kmiecik deleted the pawel/fix-table-evaluations-for-fixed-html-table-generation branch June 14, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants