File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
medcat/1_create_model/create_modelpack Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ from medcat .vocab import Vocab
2+ from medcat .cdb import CDB
3+ from medcat .cat import CAT
4+
5+
6+ cdb_model_path = "data/medcat_models/cdb"
7+ cdb_model = cdb_model_path + "<NAME OF MODEL HERE>.dat" # Change to specific cdb of interest
8+
9+ vocab_model_path = "data/medcat_models/vocab"
10+ modelpack_path = "data/medcat_models/modelpack"
11+ modelpack_name = "<NAME OF output MODELPACK HERE>.dat" # Change to the name of your model
12+
13+ # Load cdb
14+ cdb = CDB .load (cdb_model )
15+
16+ # Set cdb configuration
17+ # technically we already created this during the cdb creation
18+ cdb .config .ner ['min_name_len' ] = 2
19+ cdb .config .ner ['upper_case_limit_len' ] = 3
20+ cdb .config .general ['spell_check' ] = True
21+ cdb .config .linking ['train_count_threshold' ] = 10
22+ cdb .config .linking ['similarity_threshold' ] = 0.3
23+ cdb .config .linking ['train' ] = True
24+ cdb .config .linking ['disamb_length_limit' ] = 4
25+ cdb .config .general ['full_unlink' ] = True
26+
27+ # Load vocab
28+ vocab = Vocab .load (vocab_model_path )
29+
30+ # Initialise the model
31+ cat = CAT (cdb = cdb , config = cdb .config , vocab = vocab )
32+
33+ # Create and save model pack
34+ cat .create_model_pack (save_dir_path = modelpack_path , model_pack_name = modelpack_name )
35+
You can’t perform that action at this time.
0 commit comments