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

The multipleReferencesAllowed flag on array features is not handled #187

Closed reckart closed 2 years ago

reckart commented 2 years ago

Describe the bug The multipleReferencesAllowed on an array feature indicates if the array can be rendered as an XML attributed or not. If when rendered as an attribute, the array does not receive an ID. Also, if two FSes refer to the same array, this array will end up twice in the XMI.

To Reproduce

def test_multiple_references_allowed_true():
    typesystem = TypeSystem()
    Foo = typesystem.create_type("Foo")
    IntegerArray = typesystem.get_type("uima.cas.IntegerArray")
    f = typesystem.create_feature(Foo, "intArray", "uima.cas.IntegerArray", elementType="uima.cas.Integer")

    cas = Cas(typesystem)
    foo = Foo()
    foo.intArray = IntegerArray(elements=[1,2,3])
    cas.add(foo)

    f.multipleReferencesAllowed = True
    actual_xmi = cas.to_xmi(pretty_print=True)
    print(actual_xmi)

    f.multipleReferencesAllowed = False
    actual_xmi = cas.to_xmi(pretty_print=True)
    print(actual_xmi)

Expected behavior If f.multipleReferencesAllowed is true, the array should be rendered as a separate element, otherwise as an attribute.

Please complete the following information: