Savanamed / pycaprio

Python client to the INCEpTION annotation tool
https://pycaprio.rtfd.io
MIT License
9 stars 5 forks source link

Unable to rely on a feature of a custom layer for annotation #41

Closed laleye closed 1 year ago

laleye commented 1 year ago

I'm having trouble annotating in inception a layer from a feature.

Description

Here is a snippet of my typesstsem file.

<typeDescription>

            <name>webanno.custom.Concept</name>

            <description/>

            <supertypeName>uima.tcas.Annotation</supertypeName>

            <features>

                <featureDescription>

                    <name>Date</name>

                    <description/>

                    <rangeTypeName>uima.cas.String</rangeTypeName>

                </featureDescription>

                <featureDescription>

                    <name>Disease</name>

                    <description/>

                    <rangeTypeName>uima.cas.String</rangeTypeName>

                </featureDescription>

                <featureDescription>

                    <name>Value</name>

                    <description/>

                    <rangeTypeName>uima.cas.String</rangeTypeName>

                </featureDescription>

                <featureDescription>

                    <name>Insect</name>

                    <description/>

                    <rangeTypeName>uima.cas.String</rangeTypeName>

                </featureDescription>

                <featureDescription>

                    <name>Location</name>

                    <description/>

                    <rangeTypeName>uima.cas.String</rangeTypeName>

                </featureDescription>

                <featureDescription>

                    <name>Pest</name>

                    <description/>

                    <rangeTypeName>uima.cas.String</rangeTypeName>

                </featureDescription>

                <featureDescription>

                    <name>Plant</name>

                    <description/>

                    <rangeTypeName>uima.cas.String</rangeTypeName>

                </featureDescription>

            </features>

        </typeDescription>

Here is the piece of code to create the annotation:

SENTENCE_TYPE = "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence"
TOKEN_TYPE = "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token"
NER_TYPE = "webanno.custom.Concept"

Sentence = ts.get_type(SENTENCE_TYPE)
Token = ts.get_type(TOKEN_TYPE)
NamedEntity = ts.get_type(NER_TYPE)

for named_entity in entities:
    cas_named_entity = NamedEntity(begin=named_entity[0], end=named_entity[1], label = named_entity[2])
    cas.add_annotation(cas_named_entity)
    assert named_entity[2] == cas_named_entity.get_covered_text()

named_entity contains as example (43, 50, Date)

With the code above, I get the following error:

TypeError: webanno_custom_Concept.__init__() got an unexpected keyword argument 'label' The same error occurs when I replace label= named_entity[2] by value= named_entity[2]or by the name of the feature Date date= named_entity[2].

I specify that everything works correctly when I use the primitive layer Span instead of the custom layer created.

Any idea to understand why this problem arises or any other idea of workaround?

laleye commented 1 year ago

It was a problem with the incorrectly written feature name.