api.utils
Module Contents
Classes
A simple class to mimic spaCy entity structure for remote API responses. |
|
A simple class to mimic spaCy document structure for remote API responses. |
|
Simple filter object for remote service when cat is not available. |
Functions
|
Call the remote MedCAT service API to process text. |
|
|
|
Add annotations from spacy_doc to the database. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Attributes
- api.utils.logger
- class api.utils.RemoteEntity(entity_data, text)
A simple class to mimic spaCy entity structure for remote API responses.
- __init__(entity_data, text)
- get_addon_data(key)
Mimic get_addon_data for meta_cat_meta_anns.
- class api.utils.RemoteSpacyDoc(linked_ents)
A simple class to mimic spaCy document structure for remote API responses.
- __init__(linked_ents)
- api.utils.call_remote_model_service(service_url, text)
Call the remote MedCAT service API to process text.
- Args:
service_url: Base URL of the remote service (e.g., http://medcat-service:8000) text: Text to process
- Returns:
RemoteSpacyDoc object with linked_ents
- api.utils.remove_annotations(document, project, partial=False)
- class api.utils.SimpleFilters(cuis=None, cuis_exclude=None)
Simple filter object for remote service when cat is not available.
- __init__(cuis=None, cuis_exclude=None)
- api.utils.add_annotations(spacy_doc, user, project, document, existing_annotations, cat=None, filters=None, similarity_threshold=0.3)
Add annotations from spacy_doc to the database.
- Args:
spacy_doc: spaCy document with linked_ents or RemoteSpacyDoc user: User object project: ProjectAnnotateEntities object document: Document object existing_annotations: List of existing AnnotatedEntity objects cat: CAT object (optional, required if filters not provided) filters: SimpleFilters object (optional, used when cat is None) similarity_threshold: float (optional, default 0.3, used when cat is None)
- api.utils.clear_cdb_cnf_addons(cdb, cdb_id)
- Parameters:
cdb (medcat.cdb.CDB) –
cdb_id (str | int) –
- api.utils.get_create_cdb_infos(cdb, concept, cui, cui_info_prop, code_prop, desc_prop, model_clazz)
- api.utils.create_annotation(source_val, selection_occurrence_index, cui, user, project, document)
- Parameters:
source_val (str) –
selection_occurrence_index (int) –
cui (str) –
user (django.contrib.auth.models.User) –
project (api.models.ProjectAnnotateEntities) –
document (api.models.Document) –
- api.utils.train_medcat(cat, project, document)
- api.utils.prep_docs(project_id, doc_ids, user_id)
- Parameters:
project_id (List[int]) –
doc_ids (List[int]) –
user_id (int) –
- api.utils.save_project_anno(sender, instance, **kwargs)
- api.utils.env_str_to_bool(var, default)
- Parameters:
var (str) –
default (bool) –