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

String in multipleReferencesAllowed is incorrectly parsed #157

Closed DavidHuebner closed 3 years ago

DavidHuebner commented 3 years ago

Describe the bug The String value "false" of the feature multipleReferencesAllowed is incorrectly parsed as True.

The problem is in the function _get_elem_as_bool(elem) in typesystem.py where bool(elem.text) is called. For non-empty string values, this boolean is always True. We should use a slightly more advanced method to parse strings into booleans.

To Reproduce Steps to reproduce the behavior:

  1. Download a TypeSystem with multipleReferencesAllowed=false: https://raw.githubusercontent.com/apache/uima-ruta/main/ruta-typesystem/src/main/resources/org/apache/uima/ruta/engine/RutaInternalTypeSystem.xml
  2. Execute
    with open('RutaInternalTypeSystem.xml', 'rb') as f:
        typesystem = load_typesystem(f)
    assert typesystem._types["org.apache.uima.ruta.type.DebugRuleElementMatches"]._features["inlinedActionBlocks"].multipleReferencesAllowed is False

Expected behavior String value "false" should correctly be parsed as False (boolean).

Error message

Please complete the following information:

jcklie commented 3 years ago

Thanks for reporting! It should be fixed in master. I wait a bit in case you find more bugs, then I will release later this week. Is that an important bug/feature for you? I never understood nor used multipleReferencesAllowed.

DavidHuebner commented 3 years ago

Fantastic! Thanks again for your quick response. I encountered this problem when I deserialized/serialized a typesystem which was then incompatible with the original typesystem. I was not actually interested in the value of the multipleReferencesAllowed.

It is perfectly fine for now to work from the master branch / dev version. So, an immediate release is not needed.

Thanks again!

DavidHuebner commented 3 years ago

Hey @jcklie , would you mind triggering a release now? We want to release our code now and it would be great to work on a released dkpro-cassis version. Highly appreciated!

jcklie commented 3 years ago

I released it, please have a try and close the bug when it works for you.