Miscs (Interro 28)
This commit is contained in:
+8
-4
@@ -8,6 +8,9 @@ import shutil
|
||||
from pathlib import Path
|
||||
from collections import defaultdict
|
||||
|
||||
carreau = 1000 // 38
|
||||
|
||||
|
||||
def decode_json(pdf_file):
|
||||
file_path = Path(pdf_file)
|
||||
with open(file_path.with_suffix(".json"), "r") as f:
|
||||
@@ -26,8 +29,7 @@ def decode_json(pdf_file):
|
||||
for d in bb_list:
|
||||
(b, label) = d["box_2d"], d["label"]
|
||||
pn = page_number(b)
|
||||
carreau = 1000 // 38
|
||||
result.append((label, pn, b[0] - int(carreau), b[2]-int(carreau), b[1], b[3]))
|
||||
result.append((label, pn, b[0] - carreau, b[2]-carreau, b[1], b[3]))
|
||||
result.sort(key=lambda x: (x[1], x[2]))
|
||||
return (name, result)
|
||||
|
||||
@@ -98,7 +100,7 @@ def split_an_interro(base_dir, input_pdf, coords_list):
|
||||
|
||||
# RULE 2: Determine stopping label
|
||||
for next_item in coords_list[idx + 1:]:
|
||||
n_clean, n_type, n_pn, n_y_start, _, _, _ = next_item
|
||||
n_clean, n_type, n_pn, n_y_start, n_y_end, _, _ = next_item
|
||||
|
||||
if c_type == "L":
|
||||
is_stop = (n_type in ("L", "N"))
|
||||
@@ -109,7 +111,9 @@ def split_an_interro(base_dir, input_pdf, coords_list):
|
||||
|
||||
if is_stop:
|
||||
end_page = n_pn
|
||||
end_y_target_raw = n_y_start
|
||||
# end_y_target_raw = n_y_start
|
||||
# On avait retiré un carreau précédemment, on le rajoute…
|
||||
end_y_target_raw = min(n_y_start + int(1.25 * carreau), 1000)
|
||||
break
|
||||
|
||||
# RULES 3 & 4: Calculate horizontal boundaries (0.0 to 1.0 fraction of local page width)
|
||||
|
||||
Reference in New Issue
Block a user