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

Types extending primitive types are not considered primitive #93

Closed GregSilverman closed 4 years ago

GregSilverman commented 4 years ago

Describe the bug

When selecting view, the error invalid literal for int() with base 10: 'CARDINAL' is thrown.

To Reproduce

Run following:

fname = '20132.txt.xmi'
typesystem = 'TypeSystem.xmi'
with open(fname, 'rb') as f:
    cas = load_cas_from_xmi(f, typesystem=typesystem)

view = cas.get_view('Analysis')
print([x for x in view.select("biomedicus.v2.UmlsConcept")])

20132.txt.xmi.zip TypeSystem.xml.zip

Expected behavior Expect to see annotations in view (NB: this had worked in previous versions)

Error message See above.

Please complete the following information:

jcklie commented 4 years ago

The problem is that edu.umn.biomedicus.numbers.NumberType is not seen as a primitive type even though it extends uima.cas.String which . We need to check inheritance in is_primitive.

jcklie commented 4 years ago

I merged the fix in master and will maybe releae it this or early next week.

reckart commented 4 years ago

AFAIK strings are the only primitive type which can be extended - and the idea in doing so is that you can define a set of fixed values which the string feature can assume (i.e. defining an "enum"):

<typeDescription>
            <name>edu.umn.biomedicus.numbers.NumberType</name>
            <description>Automatically generated type from edu.umn.biomedicus.numbers.NumberType</description>
            <supertypeName>uima.cas.String</supertypeName>
            <allowedValues>
                <value>
                    <string>CARDINAL</string>
                    <description>Auto generated from enum constant</description>
                </value>
                <value>
                    <string>ORDINAL</string>
                    <description>Auto generated from enum constant</description>
                </value>
                <value>
                    <string>FRACTION</string>
                    <description>Auto generated from enum constant</description>
                </value>
                <value>
                    <string>DECIMAL</string>
                    <description>Auto generated from enum constant</description>
                </value>
            </allowedValues>
        </typeDescription>
GregSilverman commented 4 years ago

Hi, looks like the fix in 0.2.4 worked. Thanks!