Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant serialize byte arrays #167

Closed
jcklie opened this issue Aug 13, 2021 · 0 comments
Closed

Cant serialize byte arrays #167

jcklie opened this issue Aug 13, 2021 · 0 comments

Comments

@jcklie
Copy link
Collaborator

jcklie commented Aug 13, 2021

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'
@jcklie jcklie self-assigned this Aug 13, 2021
@reckart reckart assigned reckart and jcklie and unassigned jcklie and reckart Aug 13, 2021
jcklie added a commit that referenced this issue Aug 14, 2021
- Add function to check whether something is a primitive array
jcklie added a commit that referenced this issue Aug 14, 2021
- Add basic support for serializing/deserializing primitive arrays
@jcklie jcklie added this to the 0.6.0 milestone Aug 14, 2021
jcklie added a commit that referenced this issue Aug 14, 2021
* #167 - Cant serialize byte arrays

- Add function to check whether something is a primitive array
- Add basic support for serializing/deserializing primitive arrays
@jcklie jcklie closed this as completed Aug 14, 2021
reckart added a commit that referenced this issue Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants