impresso / impresso-py

Impresso Python Library to interact with the Impresso Public API
https://impresso-project.ch
GNU Affero General Public License v3.0
0 stars 0 forks source link

ner-nel not working properly #11

Open EmanuelaBoros opened 1 month ago

EmanuelaBoros commented 1 month ago
Jean-Baptiste Nicolas Robert Schuman ( 
29 June 1886 – 4 September 1963) was a Luxembourg-born French 
statesman. Schuman was a Christian democratic (Popular 
Republican Movement) political thinker and activist. 
"""
result = impresso.tools.ner_nel(
    text=text
)
result```

Problem:

KeyError Traceback (most recent call last) Cell In[24], line 7 1 text = """ 2 Jean-Baptiste Nicolas Robert Schuman ( 3 29 June 1886 – 4 September 1963) was a Luxembourg-born French 4 statesman. Schuman was a Christian democratic (Popular 5 Republican Movement) political thinker and activist. 6 """ ----> 7 result = impresso.tools.ner_nel( 8 text=text 9 ) 10 result

File /opt/anaconda3/envs/p11/lib/python3.11/site-packages/impresso/resources/tools.py:94, in ToolsResource.ner_nel(self, text) 83 def ner_nel(self, text: str) -> NerContainer: 84 """Named Entity Recognition and Named Entity Linking 85 86 This method is slower than ner but provides linking to external resources. (...) 92 NerContainer: List of named entities 93 """ ---> 94 result = perform_ner.sync( 95 client=self._api_client, 96 body=ImpressoNamedEntityRecognitionRequest( 97 text=text, method=ImpressoNamedEntityRecognitionRequestMethod.NER_NEL 98 ), 99 ) 100 raise_for_error(result) 102 return NerContainer( 103 result, 104 ImpressoNerSchema, 105 web_app_search_result_url=None, 106 )

File /opt/anaconda3/envs/p11/lib/python3.11/site-packages/impresso/api_client/api/tools/perform_ner.py:125, in sync(client, body) 107 def sync( 108 *, 109 client: AuthenticatedClient, 110 body: ImpressoNamedEntityRecognitionRequest, 111 ) -> Optional[Union[Error, ImpressoNamedEntityRecognitionResponse]]: 112 """Perform named entity recognition (and optional named entity linking) of a text 113 114 Args: (...) 122 Union[Error, ImpressoNamedEntityRecognitionResponse] 123 """ --> 125 return sync_detailed( 126 client=client, 127 body=body, 128 ).parsed

File /opt/anaconda3/envs/p11/lib/python3.11/site-packages/impresso/api_client/api/tools/perform_ner.py:104, in sync_detailed(client, body) 96 kwargs = _get_kwargs( 97 body=body, 98 ) 100 response = client.get_httpx_client().request( 101 **kwargs, 102 ) --> 104 return _build_response(client=client, response=response)

File /opt/anaconda3/envs/p11/lib/python3.11/site-packages/impresso/api_client/api/tools/perform_ner.py:74, in _build_response(client, response) 67 def _build_response( 68 *, client: Union[AuthenticatedClient, Client], response: httpx.Response 69 ) -> Response[Union[Error, ImpressoNamedEntityRecognitionResponse]]: 70 return Response( 71 status_code=HTTPStatus(response.status_code), 72 content=response.content, 73 headers=response.headers, ---> 74 parsed=_parse_response(client=client, response=response), 75 )

File /opt/anaconda3/envs/p11/lib/python3.11/site-packages/impresso/api_client/api/tools/perform_ner.py:38, in _parse_response(client, response) 34 def _parse_response( 35 *, client: Union[AuthenticatedClient, Client], response: httpx.Response 36 ) -> Optional[Union[Error, ImpressoNamedEntityRecognitionResponse]]: 37 if response.status_code == HTTPStatus.CREATED: ---> 38 response_201 = ImpressoNamedEntityRecognitionResponse.from_dict(response.json()) 40 return response_201 41 if response.status_code == HTTPStatus.UNAUTHORIZED:

File /opt/anaconda3/envs/p11/lib/python3.11/site-packages/impresso/api_client/models/impresso_named_entity_recognition_response.py:61, in ImpressoNamedEntityRecognitionResponse.from_dict(cls, src_dict) 58 d = src_dict.copy() 59 model_id = d.pop("modelId") ---> 61 text = d.pop("text") 63 timestamp = isoparse(d.pop("timestamp")) 65 entities = []

KeyError: 'text'

EmanuelaBoros commented 1 month ago

It's from my side. I'm working on it (entity schemas that fits our inside data and the API)