dkpro / dkpro-cassis

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

Cant serialize byte arrays #167

Closed jcklie closed 3 years ago

jcklie commented 3 years ago

Describe the bug

Cant serialize byte arrays

To Reproduce

import random

from cassis import *

data = bytearray(random.getrandbits(8) for _ in range(8))

cas = Cas()

ByteArray = cas.typesystem.get_type("uima.cas.ByteArray")
ba = ByteArray(elements=list(data))

cas.add_annotation(ba)

print(ba)

print(cas.to_xmi(pretty_print=True))

Expected behavior A clear and concise description of what you expected to happen.

Error message

Traceback (most recent call last):
  File "C:/Users/klie/AppData/Roaming/JetBrains/PyCharm2021.2/scratches/cassis/Quechua/bita.py", line 16, in <module>
    print(cas.to_xmi(pretty_print=True))
  File "D:\git\dkpro-cassis\cassis\cas.py", line 522, in to_xmi
    serializer.serialize(sink, self, pretty_print=pretty_print)
  File "D:\git\dkpro-cassis\cassis\xmi.py", line 309, in serialize
    self._serialize_feature_structure(cas, root, fs)
  File "D:\git\dkpro-cassis\cassis\xmi.py", line 410, in _serialize_feature_structure
    elements = " ".join(str(e.xmiID) for e in value)
  File "D:\git\dkpro-cassis\cassis\xmi.py", line 410, in <genexpr>
    elements = " ".join(str(e.xmiID) for e in value)
AttributeError: 'int' object has no attribute 'xmiID'