Skip to content

Commit cf529a2

Browse files
authored
CU-8699j8t08 Update install targets and adapt library changes (#9)
* CU-8699j8t08: Fix minor README issue (technically unrelated) * CU-8699j8t08: Update install instructions with monorepo release targets * CU-8699j8t08: Update install targets to monorepo in tutorials * CU-8699j8t08: Simplfiy install targets * CU-8699j8t08: Remove accidentally added optional install parts * CU-8699j8t08: Update some tutorials code to reflect library changes * Update NER component example code to changes * Fix arguments for creating a new component * CU-8699j8t08: Fix typo * CU-8699j8t08: Update tokenizer registration * CU-8699j8t08: Fix another typo * Fix NER component registration in tutorials
1 parent 8aa249b commit cf529a2

File tree

6 files changed

+21
-23
lines changed

6 files changed

+21
-23
lines changed

medcat-v2-tutorials/notebooks/advanced/1._Creating_and_using_a_custom_tokenizer.ipynb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
},
317317
{
318318
"cell_type": "code",
319-
"execution_count": 4,
319+
"execution_count": null,
320320
"metadata": {},
321321
"outputs": [],
322322
"source": [
@@ -355,14 +355,9 @@
355355
" def get_entity_class(self) -> type[MutableEntity]:\n",
356356
" return Entity\n",
357357
"\n",
358-
" # for creation of class based on config\n",
359-
" @classmethod\n",
360-
" def get_init_args(cls, config: Config) -> list[Any]:\n",
361-
" return []\n",
362-
"\n",
363358
" @classmethod\n",
364-
" def get_init_kwargs(cls, config: Config) -> dict[str, Any]:\n",
365-
" return {}"
359+
" def create_new_tokenizer(cls, config: Config) -> 'WhitespaceTokenizer':\n",
360+
" return cls()"
366361
]
367362
},
368363
{
@@ -389,7 +384,7 @@
389384
],
390385
"source": [
391386
"from medcat.tokenizing.tokenizers import register_tokenizer, list_available_tokenizers\n",
392-
"register_tokenizer(\"whitespace-tokenizer\", WhitespaceTokenizer)\n",
387+
"register_tokenizer(\"whitespace-tokenizer\", WhitespaceTokenizer.create_new_tokenizer)\n",
393388
"print(\"Registered tokenizers:\", list_available_tokenizers())"
394389
]
395390
},
@@ -417,7 +412,9 @@
417412
],
418413
"source": [
419414
"from medcat.tokenizing.tokenizers import create_tokenizer\n",
420-
"tokenizer = create_tokenizer(\"whitespace-tokenizer\")\n",
415+
"cnf = Config()\n",
416+
"cnf.general.nlp.provider = \"whitespace-tokenizer\" \n",
417+
"tokenizer = create_tokenizer(\"whitespace-tokenizer\", cnf)\n",
421418
"print(\"We've got one:\", tokenizer)"
422419
]
423420
},

medcat-v2-tutorials/notebooks/advanced/2._Create_and_use_component.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"from medcat.tokenizing.tokenizers import BaseTokenizer\n",
3737
"from medcat.vocab import Vocab\n",
3838
"from medcat.cdb.cdb import CDB\n",
39+
"from medcat.config.config import Ner\n",
3940
"# for the component itself\n",
4041
"from medcat.components.types import AbstractCoreComponent, CoreComponentType\n",
4142
"from medcat.tokenizing.tokens import MutableDocument, MutableEntity\n",
@@ -63,11 +64,11 @@
6364
" name = \"RANDOM_NER\"\n",
6465
"\n",
6566
" # NOTE: NEED TO IMPLEMENT \n",
66-
" # the arguments provide to the init method in order\n",
6767
" @classmethod\n",
68-
" def get_init_args(cls, tokenizer: BaseTokenizer, cdb: CDB, vocab: Vocab,\n",
69-
" model_load_path: Optional[str]) -> list[Any]:\n",
70-
" return [tokenizer, cdb]\n",
68+
" def create_new_component(\n",
69+
" cls, cnf: Ner, tokenizer: BaseTokenizer, cdb: CDB, vocab: Vocab,\n",
70+
" model_load_path: Optional[str]) -> 'RandomNER':\n",
71+
" return cls(tokenizer, cdb)\n",
7172
"\n",
7273
" # NOTE: NEED TO IMPLEMENT\n",
7374
" # the keyword arguments to the init method\n",
@@ -148,7 +149,7 @@
148149
"outputs": [],
149150
"source": [
150151
"from medcat.components.types import register_core_component\n",
151-
"register_core_component(CoreComponentType.ner, RandomNER.name, RandomNER)"
152+
"register_core_component(CoreComponentType.ner, RandomNER.name, RandomNER.create_new_component)"
152153
]
153154
},
154155
{

medcat-v2-tutorials/notebooks/introductory/meta/1._Add_a_MetaCat_to_a_Model.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
}
7777
],
7878
"source": [
79-
"! pip install \"medcat[meta-cat] @ git+https://github.com/CogStack/MedCAT2@v0.8.0\" # NOTE: VERSION-STRING"
79+
"! pip install \"medcat[meta-cat] @ git+https://github.com/CogStack/cogstack-nlp@medcat/v0.10.0#subdirectory=medcat-v2\" # NOTE: VERSION-STRING"
8080
]
8181
},
8282
{

medcat-v2-tutorials/notebooks/introductory/migration/1._Migrate_v1_model_to_v2.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
}
132132
],
133133
"source": [
134-
"! pip install \"medcat[meta-cat,spacy,deid] @ git+https://github.com/CogStack/MedCAT2@v0.8.0\""
134+
"! pip install \"medcat[meta-cat,spacy,deid] @ git+https://github.com/CogStack/cogstack-nlp@medcat/v0.10.0#subdirectory=medcat-v2\""
135135
]
136136
},
137137
{

medcat-v2-tutorials/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
medcat @ git+https://github.com/CogStack/MedCAT2@v0.8.0
1+
medcat @ git+https://github.com/CogStack/cogstack-nlp@medcat/v0.10.0#subdirectory=medcat-v2
22
ipykernel
33
pytest-xdist~=3.6.0
44
nbmake<1.6

medcat-v2/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ Currently MedCAT v2 is in Beta.
4545
As such, we're not yet pushing to PyPI.
4646
And because of that the current installation command for (only) core MedCAT v2 is:
4747
```
48-
pip install "medcat @ git+https://github.com/CogStack/MedCAT2@v0.8.0"
48+
pip install "medcat @ git+https://github.com/CogStack/cogstack-nlp.git@refs/tags/medcat/v0.10.0#subdirectory=medcat-v2"
4949
```
5050
Do note that **this installs only the core MedCAT v2**.
5151
**It does not necessary dependencies for `spacy`-based tokenizing or MetaCATs or DeID**.
5252
However, all of those are supported as well.
5353
You can install them as follows:
5454
```
55-
pip install "medcat[spacy] @ git+https://github.com/CogStack/MedCAT2@v0.8.0" # for spacy-based tokenizer
56-
pip install "medcat[meta-cat] @ git+https://github.com/CogStack/MedCAT2@v0.8.0" # for MetaCAT
57-
pip install "medcat[deid] @ git+https://github.com/CogStack/MedCAT2@v0.8.0" # for DeID models
58-
pip install "medcat[spacy,meta-cat,deid,rel-cat,dict-ner] @ git+https://github.com/CogStack/MedCAT2@v0.8.0" # for all of the sbove
55+
pip install "medcat[spacy] @ git+https://github.com/CogStack/cogstack-nlp.git@refs/tags/medcat/v0.10.0#subdirectory=medcat-v2" # for spacy-based tokenizer
56+
pip install "medcat[meta-cat] @ git+https://github.com/CogStack/cogstack-nlp.git@refs/tags/medcat/v0.10.0#subdirectory=medcat-v2" # for MetaCAT
57+
pip install "medcat[deid] @ git+https://github.com/CogStack/cogstack-nlp.git@refs/tags/medcat/v0.10.0#subdirectory=medcat-v2" # for DeID models
58+
pip install "medcat[spacy,meta-cat,deid,rel-cat,dict-ner] @ git+https://github.com/CogStack/cogstack-nlp.git@refs/tags/medcat/v0.10.0#subdirectory=medcat-v2" # for all of the sbove
5959
```
6060

6161
PS:

0 commit comments

Comments
 (0)