flow_inference.xml_processing.XMLProcessor
- class flow_inference.xml_processing.XMLProcessor(xml_file)[source]
Process PAGE XML documents and insert OCR/HTR inference results.
The processor wraps an XML tree, keeps track of the document namespace, and provides helpers for creating and replacing
TextEquivelements. It can update matchingTextLineelements with inferred text and add collected region-level text to the correspondingTextRegionelements.- Parameters:
xml_file (str)
- __init__(xml_file)[source]
Load and parse a PAGE XML file.
- Parameters:
xml_file (
str) – Path to the XML file to parse.- Raises:
FileNotFoundError – If the XML file does not exist.
ValueError – If the XML file cannot be parsed.
- Return type:
None
Methods
__init__(xml_file)Load and parse a PAGE XML file.
create_text_equiv_element(text)Create a TextEquiv element with one Unicode child.
from_string(xml_content)Create an XMLProcessor instance from an XML string.
insert_inferred_lines(root, inferred_lines)Insert inferred text into PAGE XML.
replace_direct_text_equiv(element, text)Replace only direct TextEquiv children of the given element.
tree_to_string()Serialize the XML tree to a string.