:py:mod:`medcat.utils.helpers` ============================== .. py:module:: medcat.utils.helpers Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: medcat.utils.helpers.get_important_config_parameters medcat.utils.helpers.cui2tuis medcat.utils.helpers.tui2name medcat.utils.helpers.to_json_simple medcat.utils.helpers.to_json_sumithra medcat.utils.helpers.doc2html medcat.utils.helpers.json2html medcat.utils.helpers.prepare_name medcat.utils.helpers.get_all_from_name medcat.utils.helpers.tkn_inds_from_doc medcat.utils.helpers.tkns_from_doc medcat.utils.helpers.filter_cdb_by_icd10 medcat.utils.helpers.umls_to_icd10cm medcat.utils.helpers.umls_to_icd10_over_snomed medcat.utils.helpers.umls_to_icd10_ext medcat.utils.helpers.umls_to_icd10 medcat.utils.helpers.umls_to_snomed medcat.utils.helpers.snomed_to_umls medcat.utils.helpers.snomed_to_icd10 medcat.utils.helpers.snomed_to_desc medcat.utils.helpers.filter_only_icd10 medcat.utils.helpers.add_names_icd10 medcat.utils.helpers.add_names_icd10cm medcat.utils.helpers.remove_icd10_ranges medcat.utils.helpers.dep_check_scispacy medcat.utils.helpers.run_cv medcat.utils.helpers.has_new_spacy medcat.utils.helpers.has_spacy_model medcat.utils.helpers.ensure_spacy_model Attributes ~~~~~~~~~~ .. autoapisummary:: medcat.utils.helpers.logger .. py:data:: logger .. py:function:: get_important_config_parameters(config) .. py:function:: cui2tuis(cdb, cui) .. py:function:: tui2name(cdb, tui) .. py:function:: to_json_simple(docs, cdb) output: [{'text': , 'entities': [, ]}] :param docs: The list of documents. :param cdb: The concept database :type cdb: CDB :Returns: **List[Dict]** -- The output dict. .. py:function:: to_json_sumithra(docs, cdb) output: [ [ text, {'entities': [, ]} ], ...] :param docs: The list of documents. :param cdb: The concept database :type cdb: CDB :Returns: **List[List]** -- The output list. .. py:function:: doc2html(doc) .. py:function:: json2html(doc) .. py:function:: prepare_name(cat, name, version='CLEAN') Cleans up the name. :param cat: The model pack. :param name: The name to prepare. :param version: The version of prepare to use. :Returns: **Tuple[str, List]** -- The name and tokens .. py:function:: get_all_from_name(name, nlp, source_value, SEP='', version='clean') .. py:function:: tkn_inds_from_doc(spacy_doc, text_inds=None, source_val=None) .. py:function:: tkns_from_doc(spacy_doc, start, end) .. py:function:: filter_cdb_by_icd10(cdb) Filters an existing CDB to only contain concepts that have an associated ICD-10 code. Can be used for snomed orr UMLS CDBs. :param cdb: The input CDB :type cdb: CDB :Returns: **CDB** -- The filtered CDB .. py:function:: umls_to_icd10cm(cdb, csv_path) .. py:function:: umls_to_icd10_over_snomed(cdb, pickle_path) .. py:function:: umls_to_icd10_ext(cdb, pickle_path) .. py:function:: umls_to_icd10(cdb, csv_path) Map UMLS CDB to ICD10 concepts. :param cdb: The CDB :type cdb: CDB :param csv_path: The path to the file to load. .. py:function:: umls_to_snomed(cdb, pickle_path) Map UMLS CDB to SNOMED concepts. :param cdb: The CDB :type cdb: CDB :param pickle_path: The path to the file to load. .. py:function:: snomed_to_umls(cdb, pickle_path) Map SNOMED CDB to UMLS concepts. :param cdb: The concept database. :type cdb: CDB :param pickle_path: The file path. :type pickle_path: str .. py:function:: snomed_to_icd10(cdb, csv_path) Add map from cui to icd10 for concepts. :param cdb: The concept database. :type cdb: CDB :param csv_path: The file path. :type csv_path: str .. py:function:: snomed_to_desc(cdb, csv_path) Add descriptions to the concepts. :param cdb: The concept database. :type cdb: CDB :param csv_path: The file path. :type csv_path: str .. py:function:: filter_only_icd10(doc, cat) .. py:function:: add_names_icd10(csv_path, cat) .. py:function:: add_names_icd10cm(cdb, csv_path, cat) .. py:function:: remove_icd10_ranges(cdb) .. py:function:: dep_check_scispacy() .. py:function:: run_cv(cdb_path, data_path, vocab_path, cv=100, nepochs=16, test_size=0.1, lr=1, groups=None, **kwargs) .. py:function:: has_new_spacy() Figures out whether or not a newer version of spacy is installed. This plays a role in how some parts of the Span needs to be interacted with. As of writing, the new version starts at v3.3.1. :Returns: **bool** -- Whether new version was detected. .. py:function:: has_spacy_model(model_name) Checks if the spacy model is available. :param model_name: The model name. :type model_name: str :Returns: **bool** -- True if the model is available, False otherwise. .. py:function:: ensure_spacy_model(model_name) Ensure the specified spacy model exists. If the model does not currently exist, it will attempt downloading it. :param model_name: The spacy model name. :type model_name: str