medcat.model_creation.cdb_maker
Classes:
-
CDBMaker–Given a CSV it creates a CDB or updates an existing one.
Attributes:
CDBMaker
Bases: object
Given a CSV it creates a CDB or updates an existing one.
The CSV is expected to have
Parameters:
-
(configConfig) –Global config for MedCAT.
-
(cdbCDB, default:None) –If set the
CDBMakerwill update the existingCDBwith new concepts in the CSV (Default valueNone).
Methods:
-
prepare_csvs–Compile one or multiple CSVs into a CDB.
-
reset_cdb–This will re-create a new internal CDB based on the same config.
Attributes:
Source code in medcat-v2/medcat/model_creation/cdb_maker.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
cnf_cm
instance-attribute
cnf_cm = cdb_maker
prepare_csvs
prepare_csvs(csv_paths: Union[DataFrame, list[str]], sep: str = ',', encoding: Optional[str] = None, escapechar: Optional[str] = None, index_col: bool = False, full_build: bool = False, only_existing_cuis: bool = False, **kwargs: Any) -> CDB
Compile one or multiple CSVs into a CDB.
This class/method generally uses the same instance of the CDB.
So if you're using the same CDBMaker and calling prepare_csvs
multiple times, you are likely to get leakage from prior calls
into new ones.
To reset the CDB, call reset_cdb.
Parameters:
-
(csv_pathsUnion[DataFrame, list[str]]) –An array of paths to the csv files that should be processed. Can also be an array of pd.DataFrames
-
(sepstr, default:',') –If necessary a custom separator for the csv files Defaults to ','.
-
(encodingOptional[str], default:None) –Encoding to be used for reading the CSV file Defaults to
None. -
(escapecharOptional[str], default:None) –Escape char for the CSV (Default value None).
-
(index_colbool, default:False) –Index column for pandas read_csv (Default value False).
-
(full_buildbool, default:False) –If False only the core portions of the CDB will be built (the ones required for the functioning of MedCAT). If True, everything will be added to the CDB - this usually includes concept descriptions, various forms of names etc (take care that this option produces a much larger CDB). Defaults to False.
-
(only_existing_cuisbool, default:False) –If True no new CUIs will be added, but only linked names will be extended. Mainly used when enriching names of a CDB (e.g. SNOMED with UMLS terms). Default to
False. -
(kwargsAny, default:{}) –Will be passed to pandas for CSV reading
Note
**kwargs: Will be passed to pandas for CSV reading
Returns:
-
CDB(CDB) –CDB with the new concepts added.
Source code in medcat-v2/medcat/model_creation/cdb_maker.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
reset_cdb
reset_cdb() -> None
This will re-create a new internal CDB based on the same config.
This will be necessary if/when you're wishing to call prepare_csvs
multiple times on the same object CDBMaker instance.
Source code in medcat-v2/medcat/model_creation/cdb_maker.py
48 49 50 51 52 53 54 | |