dkpro / dkpro-cassis

UIMA CAS processing library written in Python
https://pypi.org/project/dkpro-cassis/
Apache License 2.0
84 stars 22 forks source link

Cannot deserialize from JSON Cas if child type comes before super type #276

Closed jcklie closed 1 year ago

jcklie commented 1 year ago

Describe the bug Cannot deserialize from JSON Cas if child type comes before super type.

To Reproduce

with open("test.json") as f:
    load_cas_from_json(f)

Expected behavior No error and it loads.

Error message cassis.typesystem.TypeNotFoundError: Type with name [example.ParentType] not found!

Please complete the following information:

Additional context

{
    "%TYPES": {
        "example.ChildType": {
            "%NAME": "example.ChildType",
            "%SUPER_TYPE": "example.ParentType",
            "childFeature": {
                "%NAME": "childFeature",
                "%RANGE": "uima.cas.Integer"
            }
        },
        "example.ParentType": {
            "%NAME": "example.ParentType",
            "%SUPER_TYPE": "uima.tcas.Annotation",
            "parentFeature": {
                "%NAME": "parentFeature",
                "%RANGE": "uima.cas.String"
            }
        }
    },
    "%FEATURE_STRUCTURES": [
        {
            "%ID": 1,
            "%TYPE": "uima.cas.Sofa",
            "sofaNum": 1,
            "sofaID": "_InitialView"
        },
        {
            "%ID": 2,
            "%TYPE": "example.ChildType",
            "childFeature": "child",
            "parentFeature": "parent",
            "@sofa": 1
        }
    ],
    "%VIEWS": {
        "_InitialView": {
            "%SOFA": 1,
            "%MEMBERS": [
                2
            ]
        }
    }
}