Skip to content

Commit 5de9cab

Browse files
tomolopolisTom Searle
andauthored
chore(medcat): CU-869a98zwq: use old name (#118)
* chore(medcat): CU-869a98zwq: use old name * Update README with tutorial link and quick ref guide * chore(medcat): CU-869a98zwq: fixl lint --------- Co-authored-by: Tom Searle <[email protected]>
1 parent 3adce7c commit 5de9cab

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

medcat-v2/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@ Original paper for v1 on [arXiv](https://arxiv.org/abs/2010.01165).
2121
As MedCAT v2 is still in early release, we do not currently have any models publically available.
2222
You can still use models for v1, however (see the [README](https://github.com/CogStack/cogstack-nlp/blob/main/medcat-v2/README.md) there).
2323

24-
If you wish you can also convert the v1 models into the v2 format (see tutorial (TODO + link)).
24+
If you wish you can also convert the v1 models into the v2 format (see [tutorial](https://github.com/CogStack/cogstack-nlp/blob/main/medcat-v2-tutorials/notebooks/introductory/migration/1._Migrate_v1_model_to_v2.ipynb)).
25+
26+
```python
27+
from medcat.utils.legacy import legacy_converter
28+
from medcat.storage.serialisers import AvailableSerialisers
29+
old_model = '<path to old v1 model>'
30+
new_model_dir = '<dir to place new model in>'
31+
legacy_converter.do_conversion(old_model_path, new_model_dir, AvailableSerialisers.dill)
32+
```
33+
OR
34+
```bash
35+
model_path = "models/medcat1_model_pack.zip"
36+
new_model_folder = "models" # file in this folder
37+
! python -m medcat.utils.legacy.legacy_converter $model_path $new_model_folder --verbose
38+
```
2539

2640
## News
2741
- **MedCAT 2.0.0** was released 18. August 2025.

medcat-v2/medcat/utils/legacy/conversion_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(self, medcat1_model_pack_path: str,
3131
ser_type: AvailableSerialisers = AvailableSerialisers.dill):
3232
if medcat1_model_pack_path.endswith(".zip"):
3333
folder_path = medcat1_model_pack_path[:-4]
34+
self.old_model_name = os.path.split(medcat1_model_pack_path)[1]
3435
unpack(medcat1_model_pack_path, folder_path)
3536
medcat1_model_pack_path = folder_path
3637
if not os.path.isdir(medcat1_model_pack_path):
@@ -147,6 +148,7 @@ def convert(self) -> CAT:
147148
logger.info("Saving converted model to '%s'",
148149
self.new_model_folder)
149150
cat.save_model_pack(self.new_model_folder,
151+
pack_name=self.old_model_name + 'v2',
150152
serialiser_type=self.ser_type)
151153
return cat
152154

0 commit comments

Comments
 (0)