Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
laleye opened this issue Jan 24, 2023 · 3 comments
Open

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

laleye opened this issue Jan 24, 2023 · 3 comments

Comments

@laleye
Copy link

laleye commented Jan 24, 2023

Describe the bug
Issue with feature annotation that is linked to a custom layer

To Reproduce
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)
If possible, attach a minimal file that triggers the error.

Error message
`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].

Please complete the following information:

  • Version:0.7.3
  • OS: Linux [e.g. Windows, Linux, OS X]

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

@reckart
Copy link
Member

reckart commented Jan 24, 2023

Your type system does not seem to have a feature called label. There is a Value and Date but you seem to have tried value and date in your Python code. Feature names are case sensitive.

@laleye
Copy link
Author

laleye commented Jan 25, 2023

Thanks @reckart for your reply. I fixed it and it seems to work except that in inception it's rather the terms that are displayed instead of the name of the feature as in the following image.

image

The expected behavior:
The displayed tag of Brazil's must be Location since it is linked to the feature Location.

Do I need to add a Label feature to solve this or I missed doing something.
Thanks

@jcklie
Copy link
Collaborator

jcklie commented Jan 25, 2023

Hi,
from the code you provided, it seems like you assign the term by yourself, named_entity[2] has to be the term text because otherwise your assert would fail.

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants