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

Cassis does not resolve feature declared for supertype #97

Closed reneverheij closed 5 years ago

reneverheij commented 5 years ago

Call to load_cas_from_xmi() fails with TypeError: tokenProperties.zip

Traceback (most recent call last):
  File "load_wex_ts.py", line 17, in <module>
    cas = load_cas_from_xmi(cas_file, typeSystem)
  File "C:\Users\x\git\github\dkpro-cassis\cassis\xmi.py", line 40, in load_cas_from_xmi
    return deserializer.deserialize(source, typesystem=typesystem)
  File "C:\Users\x\git\github\dkpro-cassis\cassis\xmi.py", line 113, in deserialize
    fs = self._parse_feature_structure(typesystem, elem, children)
  File "C:\Users\x\git\github\dkpro-cassis\cassis\xmi.py", line 225, in _parse_feature_structure
    return AnnotationType(**attributes)
  File "C:\Users\x\git\github\dkpro-cassis\cassis\typesystem.py", line 188, in __call__
    return self._constructor(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'tokenProperties'

I think the error is the result of cassis not resolving features that are declared in a supertype. During a debugging session, I established that the error occurred while cassis was trying to resolve feature 'tokenProperties' on type 'TitleCaseAlphabetic'. Inspection of the type system descriptor shows that this feature is not part of type TitleCaseAlphabetic, but of a supertype called 'uima.tt.TokenLikeAnnotation'. The inheritance hierarchy is as follows:

com.ibm.langware.uimatypes.TitleCaseAlphabetic
inherits from:
    com.ibm.langware.uimatypes.Alphabetic
    inherits from:
        com.ibm.langware.uimatypes.WordLikeToken
        inherits from:
            uima.tt.TokenAnnotation
            inherits from:
                uima.tt.TokenLikeAnnotation
                has feature: tokenProperties

To Reproduce Load the attached ts.xml and cas.xml files. The load_cas_from_xmi() should return a CAS object without incident.

Please complete the following information:

jcklie commented 5 years ago

Thank you for the report! It looks like the inheriting of features does not work over more than 1 level. I will have a look.

jcklie commented 5 years ago

The fix is in master, it would be nice if you could test it. There was another problem in your cas which is that a feature is called "type". I also fixed that issue hopefully.

reckart commented 5 years ago

How about adding a list of "tested" type systems to the README?

reckart commented 5 years ago

Well, maybe not - after all, we want to be compatible with all of them and having a list might give people the idea that we only care to support specific ones.

reneverheij commented 5 years ago

I can confirm that the error no longer occurs. Thank you for your support!

reneverheij commented 5 years ago

When will this fix be released?

jcklie commented 5 years ago

I just released it, please have a try.

reneverheij commented 5 years ago

I've tested it, the bug is gone in version 0.2.5