Skip to content

Upload/download annotations and documents to/from CAS #7

@reckart

Description

@reckart

It would be nice if there were convenience upload/download methods that directly accept DKPro Cassis Cas objects.

For uploading, the Cas object can be serialized to XMI and uploaded.

For downloading, INCEpTION exports XMIs actually as ZIP files containing a type system file and the XMI file - this can be converted to a Cas object using code like this:

with TemporaryDirectory() as tmpdir:
        with ZipFile(BytesIO(pycaprio.api.annotation(1, 4, annotation_format=InceptionFormat.XMI))) as xmi_zip:
            type_system = load_typesystem(BytesIO(xmi_zip.read('TypeSystem.xml')))
            for i in xmi_zip.filelist:
                if i.filename.endswith('.xmi'):
                    cas = load_cas_from_xmi(BytesIO(xmi_zip.read(i)), typesystem=type_system)
                    break # There is only one XMI per ZIP

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions