Skip to content

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (12, 4) + inhomogeneous part. #202

@bang123-box

Description

@bang123-box

in the grits.py file, when the code meet "pred_topology_grid = np.array(cells_to_relspan_grid(pred_cells))", some error occurs:
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (12, 4) + inhomogeneous part.
`
def grits_from_html(true_html, pred_html):
"""
Compute GriTS_Con and GriTS_Top for two HTML sequences.
"""

metrics = {}
true_cells = html_to_cells(true_html)
pred_cells = html_to_cells(pred_html)
# Convert lists of cells to matrices of grid cells
true_topology_grid = np.array(cells_to_relspan_grid(true_cells))
pred_topology_grid = np.array(cells_to_relspan_grid(pred_cells))
true_text_grid = np.array(cells_to_grid(true_cells, key='cell_text'), dtype=object)
pred_text_grid = np.array(cells_to_grid(pred_cells, key='cell_text'), dtype=object)

grits_con, grits_precision_con, grits_recall_con,grits_con_upper_bound = grits_con(true_text_grid, pred_text_grid)

return grits_con, grits_precision_con, grits_recall_con,grits_con_upper_bound`

I suspect this issue might be caused by an inconsistent number of cells per row in my pred_html, which leads to some empty cells in the resulting grid. I was wondering if this scenario was considered when the metric was designed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions