Skip to content

decoder

autocorpus.ac_bioc.decoder ¤

This module provides deserialization functionality for BioC objects.

It includes classes for handling JSON and XML formats and converting them into BioCCollection objects.

Classes¤

BioCJSON ¤

JSON deserialization for BioC objects.

Functions¤
loads(json_str) staticmethod ¤

Deserialize a BioC JSON string into a BioCCollection object.

Parameters:

Name Type Description Default
json_str str

A string containing BioC JSON data.

required

Returns:

Name Type Description
BioCCollection BioCCollection

The deserialized BioCCollection object.

Source code in autocorpus/ac_bioc/decoder.py
16
17
18
19
20
21
22
23
24
25
26
27
@staticmethod
def loads(json_str: str) -> BioCCollection:
    """Deserialize a BioC JSON string into a BioCCollection object.

    Args:
        json_str (str): A string containing BioC JSON data.

    Returns:
        BioCCollection: The deserialized BioCCollection object.
    """
    data = json.loads(json_str)
    return BioCCollection.from_json(data)

BioCXML ¤

XML deserialization for BioC objects.

Functions¤
loads(xml_str) staticmethod ¤

Deserialize a BioC XML string into a BioCCollection object.

Parameters:

Name Type Description Default
xml_str str

A string containing BioC XML data.

required

Returns:

Name Type Description
BioCCollection BioCCollection

The deserialized BioCCollection object.

Source code in autocorpus/ac_bioc/decoder.py
33
34
35
36
37
38
39
40
41
42
43
44
@staticmethod
def loads(xml_str: str) -> BioCCollection:
    """Deserialize a BioC XML string into a BioCCollection object.

    Args:
        xml_str (str): A string containing BioC XML data.

    Returns:
        BioCCollection: The deserialized BioCCollection object.
    """
    root = ET.fromstring(xml_str)
    return BioCCollection.from_xml(root)