def _lines_from_ocr_output(lines: dict, error_margin: float = 0) -> List[LineElement]:
    """
    Creates LineElement objects from given lines, combining overlapping ones.
    """
    combined: List[LineElement] = []

    for line in lines:
        bbox = line["bbox"]
        spans = [
            TextSpan(
                text=span["text"],
                is_bold=is_bold(span["flags"]),
                is_italic=is_italic(span["flags"]),
                size=span["size"],
            )
            for span in line["spans"]
        ]

        line_element = LineElement(bbox=bbox, spans=tuple(spans))
        for i, other in enumerate(combined):
            overlaps = line_element.overlaps(other, error_margin=error_margin)
            similar_height = line_element.is_at_similar_height(
                other, error_margin=error_margin
            )

            if overlaps and similar_height:
                combined[i] = line_element.combine(other)
                break
        else:
            combined.append(line_element)

    return combined

    Creates LineElement objects from given lines, combining overlapping ones.
    
src/openparse/text/pymupdf/core.py