def parse_layout(elems, font_stat, combine=False):
boxes_segments = elems.segments<EOL>boxes_curves = elems.curves<EOL>boxes_figures = elems.figures<EOL>page_width = elems.layout.width<EOL>boxes = elems.mentions<EOL>avg_font_pts = get_most_common_font_pts(elems.mentions, font_stat)<EOL>width = get_page_width(boxes + boxes_segments + boxes_figures + boxes_curves)<EOL>char_width = get_char_width(boxes)<EOL>grid_size = avg_font_pts / <NUM_LIT><EOL>for i, m in enumerate(boxes + elems.figures):<EOL><INDENT>m.id = i<EOL>m.feats = defaultdict(bool)<EOL>prefix = "<STR_LIT>"<EOL>if isinstance(m, LTTextLine) and m.font_name:<EOL><INDENT>prefix = m.font_name + "<STR_LIT:->" + str(m.font_size) + "<STR_LIT:->"<EOL><DEDENT>m.xc = (m.x0 + m.x1) / <NUM_LIT><EOL>m.yc = (m.y0 + m.y1) / <NUM_LIT><EOL>m.feats[prefix + "<STR_LIT>"] = m.x0_grid = m.x0 // grid_size<EOL>m.feats[prefix + "<STR_LIT>"] = m.x1_grid = m.x1 // grid_size<EOL>m.feats[prefix + "<STR_LIT>"] = m.xc_grid = m.xc // grid_size<EOL>m.feats[prefix + "<STR_LIT>"] = m.yc_grid = m.yc // grid_size<EOL><DEDENT>tbls, tbl_features = cluster_vertically_aligned_boxes(<EOL>boxes,<EOL>elems.layout.bbox,<EOL>avg_font_pts,<EOL>width,<EOL>char_width,<EOL>boxes_segments,<EOL>boxes_curves,<EOL>boxes_figures,<EOL>page_width,<EOL>combine,<EOL>)<EOL>return tbls, tbl_features<EOL>
Parses pdf texts into a hypergraph grouped into rows
and columns and then output