(xml_path)
| 236 | |
| 237 | |
| 238 | def parse_poster_xml_for_figures(xml_path): |
| 239 | root = parse_xml_with_recovery(xml_path) |
| 240 | |
| 241 | poster_w = float(root.get("Width", "1")) |
| 242 | poster_h = float(root.get("Height", "1")) |
| 243 | poster_area = poster_w * poster_h |
| 244 | |
| 245 | records = [] |
| 246 | |
| 247 | for panel in root.findall("Panel"): |
| 248 | px, py = float(panel.get("left", 0)), float(panel.get("right", 0)) |
| 249 | pw, ph = float(panel.get("width", 1)), float(panel.get("height", 1)) |
| 250 | panel_area = pw * ph |
| 251 | sp = panel_area / poster_area |
| 252 | rp = pw / ph if ph > 0 else 1.0 |
| 253 | |
| 254 | lp = sum(len(t.text.strip()) for t in panel.findall("Text") if t.text) |
| 255 | |
| 256 | for fig in panel.findall("Figure"): |
| 257 | fx, fy = float(fig.get("left", 0)), float(fig.get("right", 0)) |
| 258 | fw, fh = float(fig.get("width", 1)), float(fig.get("height", 1)) |
| 259 | |
| 260 | sg = (fw * fh) / poster_area |
| 261 | rg = fw / fh if fh > 0 else 1.0 |
| 262 | ug = fw / pw if pw > 0 else 0.1 |
| 263 | |
| 264 | panel_center_x = px + pw / 2 |
| 265 | fig_center_x = fx + fw / 2 |
| 266 | delta_x = fig_center_x - panel_center_x |
| 267 | |
| 268 | hg = 0 if delta_x < -pw / 6 else (2 if delta_x > pw / 6 else 1) |
| 269 | |
| 270 | record = {"sp": sp, "rp": rp, "lp": lp, "sg": sg, "rg": rg, "hg": hg, "ug": ug} |
| 271 | records.append(record) |
| 272 | |
| 273 | return records |
| 274 | |
| 275 | |
| 276 | def train_figure_model(figure_records): |
no test coverage detected