Skip to content

Commit

Permalink
fix: propagate cell type (#73)
Browse files Browse the repository at this point in the history
* fix: propagate cell type

Signed-off-by: Michele Dolfi <[email protected]>

* update test results

Signed-off-by: Michele Dolfi <[email protected]>

---------

Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm authored Sep 17, 2024
1 parent b03a7de commit 27c5852
Show file tree
Hide file tree
Showing 6 changed files with 1,207 additions and 1,199 deletions.
3 changes: 3 additions & 0 deletions src/andromeda/tooling/structs/elements/table_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace andromeda
std::array<uint64_t,2> col_span,
std::array<float, 4> bbox,
//nlohmann::json bbox,
std::string type,
std::string orig);

nlohmann::json to_json();
Expand Down Expand Up @@ -65,9 +66,11 @@ namespace andromeda
std::array<uint64_t,2> row_span,
std::array<uint64_t,2> col_span,
std::array<float, 4> bbox,
std::string type,
std::string orig):
text_element(),
i(i), j(j),
type(type),

row_span(row_span),
col_span(col_span),
Expand Down
8 changes: 7 additions & 1 deletion src/andromeda/tooling/structs/subjects/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ namespace andromeda
text = grid.at(i).at(j).at("text");
}

std::string type = "";
if (grid.at(i).at(j).count("type")==1)
{
type = grid.at(i).at(j).at("type").get<std::string>();
}

std::array<float, 4> bbox = {0.0, 0.0, 0.0, 0.0};
if(grid.at(i).at(j).count("bbox")==1 and
grid.at(i).at(j).at("bbox").is_array())
Expand Down Expand Up @@ -332,7 +338,7 @@ namespace andromeda
}
}

data.back().emplace_back(i, j, row_span, col_span, bbox, text);
data.back().emplace_back(i, j, row_span, col_span, bbox, type, text);
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions tests/data/docs/1806.02284.nlp.json
Original file line number Diff line number Diff line change
Expand Up @@ -96460,7 +96460,7 @@
]
],
"text": "",
"type": ""
"type": "col_header"
},
{
"bbox": [
Expand Down Expand Up @@ -96613,7 +96613,7 @@
]
],
"text": "",
"type": ""
"type": "body"
},
{
"bbox": [
Expand Down Expand Up @@ -97069,7 +97069,7 @@
]
],
"text": "",
"type": ""
"type": "col_header"
},
{
"bbox": null,
Expand All @@ -97092,7 +97092,7 @@
]
],
"text": "",
"type": ""
"type": "col_header"
},
{
"bbox": [
Expand Down Expand Up @@ -97405,7 +97405,7 @@
]
],
"text": "",
"type": ""
"type": "body"
},
{
"bbox": [
Expand Down Expand Up @@ -97456,7 +97456,7 @@
]
],
"text": "",
"type": ""
"type": "body"
},
{
"bbox": [
Expand Down Expand Up @@ -98099,7 +98099,7 @@
]
],
"text": "",
"type": ""
"type": "body"
}
],
[
Expand Down Expand Up @@ -98348,7 +98348,7 @@
]
],
"text": "",
"type": ""
"type": "body"
}
],
[
Expand Down Expand Up @@ -98597,7 +98597,7 @@
]
],
"text": "",
"type": ""
"type": "body"
}
],
[
Expand Down Expand Up @@ -98846,7 +98846,7 @@
]
],
"text": "",
"type": ""
"type": "body"
}
],
[
Expand Down Expand Up @@ -99095,7 +99095,7 @@
]
],
"text": "",
"type": ""
"type": "body"
}
],
[
Expand Down Expand Up @@ -99344,7 +99344,7 @@
]
],
"text": "",
"type": ""
"type": "body"
}
],
[
Expand Down Expand Up @@ -99593,7 +99593,7 @@
]
],
"text": "",
"type": ""
"type": "body"
}
]
],
Expand Down
Loading

0 comments on commit 27c5852

Please sign in to comment.