Skip to content

XML Parsing Does not Handle Comments or Empty Elements #54

@justin0mcateer

Description

@justin0mcateer

The XML parsing logic for labeled data currently produces empty values for any XML comment elements in the input. XML comments are handy for organizing labeled examples into different use cases within a single file. The same code also would produce empty elements if there were training examples with no tagged elements (for whatever reason).

These empty items cause the program to crash with an unhandled exception when the training process starts to iterate over the training examples specifically at 'training.trainModel' at line 22.

This could be resolved by simply ignoring comments and/or elements with no children in 'data_format_utils._strip_formatting' or 'data_format_utils.iter'. The code to skip these elements could look like:

    for sequence_xml in self.xml:
        # Skip comments
        if isinstance(sequence_xml, etree._Comment):
            continue
        
        # Skip empty sequences
        if len(sequence_xml) == 0:
            continue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions