Get annotation suggestions for the INCEpTION text annotation platform from spaCy, Sentence BERT, scikit-learn and more. Runs as a web-service compatible with the external recommender API of INCEpTION.
Apache License 2.0
40
stars
17
forks
source link
Bug for plugging an external recommender for one out of two Features in one Layer #36
Hello, I noticed a bug when I add my external recommender for NER predictions.
My task: I have a Layer Span, with 2 Features:
Label, for NER annotations, which is of type String
Assertion for multi-classification annotations, which is of type uima.cas.StringArray [not required]
I have an external recommender which aims to make predictions for Label feature only, based on a NER hugging face model.
I have a ValueError when I connect my recommender ValueError: Not a primitive collection type: uima.cas.StringArray.
I noticed I only have the issue when some Spans do not have an annotation for Assertion (even if I did not set it to Required) and everything works perfectly when the only Feature is Label (String) (ie removing Assertion feature).
The issue might come from the fact that:
when a Span is annotated for Label but not Assertion, its value = fs["Assertion"] is empty and is detected as a string instance, which creates an error when calls _parse_primitive_array
TYPE_NAME_STRING_ARRAY is not a case in _parse_primitive_array whereas belonging to _PRIMITIVE_COLLECTION_TYPES (not consistant with the error message ValueError: Not a primitive collection type: uima.cas.StringArray)
Issue:
9286-123145460297728 2022-05-16 14:28:50,907 - werkzeug - INFO - 172.16.159.100 - - [16/May/2022 14:28:50] "POST /camembert_ner/predict HTTP/1.1" 500 -
Traceback (most recent call last):
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/ariadne/server.py", line 40, in _predict
req = parse_prediction_request(json_data)
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/ariadne/protocol.py", line 75, in parse_prediction_request
cas = load_cas_from_xmi(document["xmi"], typesystem)
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/cassis/xmi.py", line 95, in load_cas_from_xmi
return deserializer.deserialize(
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/cassis/xmi.py", line 247, in deserialize
fs[feature_name] = FSType(elements=self._parse_primitive_array(feature.rangeType, value))
File "/Users//projects/fhir-lighter/lib/ner_camembert/.venv/lib/python3.9/site-packages/cassis/xmi.py", line 459, in _parse_primitive_array
raise ValueError(f"Not a primitive collection type: {type_name}")
ValueError: Not a primitive collection type: uima.cas.StringArray
Hello, I noticed a bug when I add my external recommender for NER predictions.
My task: I have a Layer
Span
, with 2 Features:String
uima.cas.StringArray
[not required]I have an external recommender which aims to make predictions for Label feature only, based on a NER hugging face model. I have a ValueError when I connect my recommender
ValueError: Not a primitive collection type: uima.cas.StringArray
.I noticed I only have the issue when some
Spans
do not have an annotation for Assertion (even if I did not set it toRequired
) and everything works perfectly when the only Feature is Label (String) (ie removing Assertion feature).The issue might come from the fact that:
Span
is annotated for Label but not Assertion, itsvalue = fs["Assertion"]
is empty and is detected as a string instance, which creates an error when calls_parse_primitive_array
TYPE_NAME_STRING_ARRAY
is not a case in_parse_primitive_array
whereas belonging to_PRIMITIVE_COLLECTION_TYPES
(not consistant with the error messageValueError: Not a primitive collection type: uima.cas.StringArray
)Issue:
Do you have a way around it? Thanks