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

Error: 'KeyError: 17' #94

Closed GregSilverman closed 5 years ago

GregSilverman commented 5 years ago

Describe the bug

When selecting view, the error Keyerror: 17 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)

t = typesystem.get_type('org.apache.ctakes.typesystem.type.textsem.DiseaseDisorderMention')
typesystem.add_feature(t, name='id', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='ontologyConceptArr', rangeTypeName='uima.cas.FSArray', elementType='org.apache.ctakes.typesystem.type.refsem.UmlsConcept')
typesystem.add_feature(t, name='subject', rangeTypeName='uima.cas.String')
typesystem.add_feature(t, name='typeID', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='discoveryTechnique', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='confidence', rangeTypeName='uima.cas.Double')
typesystem.add_feature(t, name='polarity', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='uncertainty', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='conditional', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='generic', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='historyOf', rangeTypeName='uima.cas.Integer')

t = typesystem.get_type('org.apache.ctakes.typesystem.type.textsem.SignSymptomMention')
typesystem.add_feature(t, name='id', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='ontologyConceptArr', rangeTypeName='uima.cas.FSArray', elementType='org.apache.ctakes.typesystem.type.refsem.UmlsConcept')
typesystem.add_feature(t, name='subject', rangeTypeName='uima.cas.String')
typesystem.add_feature(t, name='typeID', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='discoveryTechnique', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='confidence', rangeTypeName='uima.cas.Double')
typesystem.add_feature(t, name='polarity', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='uncertainty', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='conditional', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='generic', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='historyOf', rangeTypeName='uima.cas.Integer')

t = typesystem.get_type('org.apache.ctakes.typesystem.type.textsem.MedicationMention')
typesystem.add_feature(t, name='id', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='ontologyConceptArr', rangeTypeName='uima.cas.FSArray', elementType='org.apache.ctakes.typesystem.type.refsem.UmlsConcept')
typesystem.add_feature(t, name='subject', rangeTypeName='uima.cas.String')
typesystem.add_feature(t, name='typeID', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='discoveryTechnique', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='confidence', rangeTypeName='uima.cas.Double')
typesystem.add_feature(t, name='polarity', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='uncertainty', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='conditional', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='generic', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='historyOf', rangeTypeName='uima.cas.Integer')

t = typesystem.get_type('org.apache.ctakes.typesystem.type.textsem.ProcedureMention')
typesystem.add_feature(t, name='id', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='ontologyConceptArr', rangeTypeName='uima.cas.FSArray', elementType='org.apache.ctakes.typesystem.type.refsem.UmlsConcept')
typesystem.add_feature(t, name='subject', rangeTypeName='uima.cas.String')
typesystem.add_feature(t, name='typeID', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='discoveryTechnique', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='confidence', rangeTypeName='uima.cas.Double')
typesystem.add_feature(t, name='polarity', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='uncertainty', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='conditional', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='generic', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='historyOf', rangeTypeName='uima.cas.Integer')

t = typesystem.get_type('org.apache.ctakes.typesystem.type.textsem.AnatomicalSiteMention')
typesystem.add_feature(t, name='id', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='ontologyConceptArr', rangeTypeName='uima.cas.FSArray', elementType='org.apache.ctakes.typesystem.type.refsem.UmlsConcept')
typesystem.add_feature(t, name='subject', rangeTypeName='uima.cas.String')
typesystem.add_feature(t, name='typeID', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='discoveryTechnique', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='confidence', rangeTypeName='uima.cas.Double')
typesystem.add_feature(t, name='polarity', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='uncertainty', rangeTypeName='uima.cas.Integer')
typesystem.add_feature(t, name='conditional', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='generic', rangeTypeName='uima.cas.Boolean')
typesystem.add_feature(t, name='historyOf', rangeTypeName='uima.cas.Integer')

view = cas.get_view('_InitialView')
print([x for x in view.select("org.apache.ctakes.typesystem.type.textsem.DiseaseDisorderMention")])

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

Expected behavior Expect to see annotations in view.

Error message See above.

Please complete the following information:

GregSilverman commented 5 years ago

Hi, this is the more critical of the two errors I just submitted, since I cannot get the particular annotation run in cTAKES to work in v 0.2.2 (the other error, generated by BioMedICUS in ver. 0.2.3, is not thrown in ver. 0.2.2).

I haven't had time to look into the error itself, but I feel like I've seen it before wrt to a namespace issue. Would appreciate any suggestions you have, since I'm under a pretty tight deadline now.

GregSilverman commented 5 years ago

Never mind. I figured this out.

reckart commented 5 years ago

So what was it?

GregSilverman commented 5 years ago

While testing, I had deleted an annotation with a feature that needed to be added to the typesystem definition. Thus, the source of the missing key! Oops!

The other issue though is still a problem, but I do have a workaround using 0.2.2.

Otherwise, the error with the collection seems to be mitigated with 0.2.3.

Thanks!

On Thu, Nov 21, 2019, 8:43 AM Richard Eckart de Castilho < notifications@github.com> wrote:

So what was it?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dkpro/dkpro-cassis/issues/94?email_source=notifications&email_token=AAHV3OQKCCYQBSCP5GNGXH3QU2F73A5CNFSM4JP4COXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE2ILHQ#issuecomment-557090206, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHV3OWESLXRHJDL3INZ3XLQU2F73ANCNFSM4JP4COXA .