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

resolve reference to sofa for nested FeatureStructure #132

Closed ArneDefauw closed 4 years ago

ArneDefauw commented 4 years ago

For the following typesystem and xml:

https://drive.google.com/drive/folders/1GqWanaAB9Duj8orYLTDtfNILv3OmZD24?usp=sharing

with open('typesystem.xml', 'rb') as f:
    typesystem = load_typesystem(f)

cas = load_cas_from_xmi(open('simple.xml', 'rb'), typesystem=typesystem)

cas.to_xmi( path="../output_dir/simple_out.xml" )  

I get the following error after loading to cas, and then creating an xmi representation:

...
xmi.py in _serialize_feature_structure(self, cas, root, fs)
    365                     child.text = e
    366             elif feature_name == "sofa":
--> 367                 elem.attrib[feature_name] = str(value.xmiID)
    368             elif ts.is_primitive(feature.rangeTypeName):
    369                 elem.attrib[feature_name] = str(value)

AttributeError: 'int' object has no attribute 'xmiID'

This is because references to the Sofa object for nested FeatureStructure is not done correct. ( in the example)

The bug is fixed with this pull request. (The fix, however, causes a problem when an annotation is added to a cas that is not part of the typesystem. However, this feature does not seem to be particularly interesting)

jcklie commented 4 years ago

Thank you for reporting this and for giving a PR. The problem is a bit different than what you are fixing and the tests fail. I opened an issue in #132 and will continue the discussion there.

jcklie commented 4 years ago

Superseeded by #134