Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from typing import Any, overload, Iterator, Optional, cast\n",
"\n",
"import re\n",
"\n",
"from medcat2.config.config import Config\n",
"from medcat2.tokenizing.tokens import BaseDocument, BaseEntity, BaseToken\n",
"from medcat2.tokenizing.tokens import MutableDocument, MutableEntity, MutableToken\n",
"from medcat.config.config import Config\n",
"from medcat.tokenizing.tokens import BaseDocument, BaseEntity, BaseToken\n",
"from medcat.tokenizing.tokens import MutableDocument, MutableEntity, MutableToken\n",
"\n",
"\n",
"# define \"whitespace\"\n",
Expand Down Expand Up @@ -376,7 +376,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -388,7 +388,7 @@
}
],
"source": [
"from medcat2.tokenizing.tokenizers import register_tokenizer, list_available_tokenizers\n",
"from medcat.tokenizing.tokenizers import register_tokenizer, list_available_tokenizers\n",
"register_tokenizer(\"whitespace-tokenizer\", WhitespaceTokenizer)\n",
"print(\"Registered tokenizers:\", list_available_tokenizers())"
]
Expand All @@ -404,7 +404,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -416,7 +416,7 @@
}
],
"source": [
"from medcat2.tokenizing.tokenizers import create_tokenizer\n",
"from medcat.tokenizing.tokenizers import create_tokenizer\n",
"tokenizer = create_tokenizer(\"whitespace-tokenizer\")\n",
"print(\"We've got one:\", tokenizer)"
]
Expand Down
28 changes: 14 additions & 14 deletions notebooks/advanced/2._Create_and_use_component.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to create and use a (core) component with medcat2\n",
"# How to create and use a (core) component with medcat v2\n",
"\n",
"The overall process is quite simple:\n",
"- Implement and extend `CoreComponent`\n",
Expand All @@ -26,20 +26,20 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# for init args\n",
"from typing import Optional, Any\n",
"\n",
"from medcat2.tokenizing.tokenizers import BaseTokenizer\n",
"from medcat2.vocab import Vocab\n",
"from medcat2.cdb.cdb import CDB\n",
"from medcat.tokenizing.tokenizers import BaseTokenizer\n",
"from medcat.vocab import Vocab\n",
"from medcat.cdb.cdb import CDB\n",
"# for the component itself\n",
"from medcat2.components.types import AbstractCoreComponent, CoreComponentType\n",
"from medcat2.tokenizing.tokens import MutableDocument, MutableEntity\n",
"from medcat2.components.ner.vocab_based_annotator import maybe_annotate_name\n",
"from medcat.components.types import AbstractCoreComponent, CoreComponentType\n",
"from medcat.tokenizing.tokens import MutableDocument, MutableEntity\n",
"from medcat.components.ner.vocab_based_annotator import maybe_annotate_name\n",
"\n",
"# for the randomness\n",
"import random\n",
Expand Down Expand Up @@ -143,11 +143,11 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from medcat2.components.types import register_core_component\n",
"from medcat.components.types import register_core_component\n",
"register_core_component(CoreComponentType.ner, RandomNER.name, RandomNER)"
]
},
Expand All @@ -160,7 +160,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -241,9 +241,9 @@
}
],
"source": [
"from medcat2.config.config import Config\n",
"from medcat2.preprocessors.cleaners import NameDescriptor\n",
"from medcat2.cat import CAT\n",
"from medcat.config.config import Config\n",
"from medcat.preprocessors.cleaners import NameDescriptor\n",
"from medcat.cat import CAT\n",
"import numpy as np\n",
"\n",
"from pprint import pprint\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"source": [
"import os\n",
"import numpy as np\n",
"from medcat2.vocab import Vocab\n",
"from medcat.vocab import Vocab\n",
"\n",
"vocab = Vocab()"
]
Expand Down Expand Up @@ -124,9 +124,9 @@
],
"source": [
"import pandas as pd\n",
"from medcat2.model_creation.cdb_maker import CDBMaker\n",
"from medcat2.cdb import CDB\n",
"from medcat2.config import Config\n",
"from medcat.model_creation.cdb_maker import CDBMaker\n",
"from medcat.cdb import CDB\n",
"from medcat.config import Config\n",
"\n",
"# first we need a config\n",
"# we can use the default for now\n",
Expand Down Expand Up @@ -299,7 +299,7 @@
"metadata": {},
"outputs": [],
"source": [
"from medcat2.cat import CAT\n",
"from medcat.cat import CAT\n",
"\n",
"cat = CAT(cdb, vocab, cnf)"
]
Expand Down Expand Up @@ -379,20 +379,20 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Saved at models/base_model\n"
"Saved at models/base_model_15ba4a6c78264c90\n"
]
}
],
"source": [
"save_path = \"models\"\n",
"mpp = cat.save_model_pack(save_path, pack_name=\"base_model\")\n",
"mpp = cat.save_model_pack(save_path, pack_name=\"base_model\", add_hash_to_pack_name=False)\n",
"print(\"Saved at\", mpp)"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from medcat2.cat import CAT\n",
"from medcat.cat import CAT\n",
"\n",
"\n",
"# NOTE: can refer to the .zip or the folder - both will work just fine\n",
Expand Down Expand Up @@ -143,7 +143,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -156,7 +156,7 @@
],
"source": [
"save_path = \"models\"\n",
"mpp = cat.save_model_pack(save_path, pack_name=\"unsup_trained_model\")\n",
"mpp = cat.save_model_pack(save_path, pack_name=\"unsup_trained_model\", add_hash_to_pack_name=False)\n",
"print(\"Saved at\", mpp)"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"from medcat2.cat import CAT\n",
"from medcat.cat import CAT\n",
"\n",
"model_path = os.path.join(\"models\", \"unsup_trained_model.zip\")\n",
"\n",
Expand All @@ -46,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -63,7 +63,7 @@
],
"source": [
"import pandas as pd\n",
"from medcat2.model_creation.cdb_maker import CDBMaker\n",
"from medcat.model_creation.cdb_maker import CDBMaker\n",
"\n",
"cdb_maker = CDBMaker(cat.config, cat.cdb)\n",
"\n",
Expand Down Expand Up @@ -208,7 +208,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -224,7 +224,7 @@
],
"source": [
"new_model_folder, new_model_name = \"models\", \"sup_trained_model\"\n",
"cat.save_model_pack(new_model_folder, pack_name=new_model_name)\n"
"cat.save_model_pack(new_model_folder, pack_name=new_model_name, add_hash_to_pack_name=False)\n"
]
}
],
Expand Down
10 changes: 5 additions & 5 deletions notebooks/introductory/meta/1._Add_a_MetaCat_to_a_Model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}
],
"source": [
"! pip install \"medcat2[meta-cat] @ git+https://github.com/CogStack/MedCAT2@v0.3.3\" # NOTE: VERSION-STRING"
"! pip install \"medcat[meta-cat] @ git+https://github.com/CogStack/MedCAT2@v0.5.0\" # NOTE: VERSION-STRING"
]
},
{
Expand All @@ -91,7 +91,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "feefc4ff",
"metadata": {},
"outputs": [
Expand All @@ -106,9 +106,9 @@
],
"source": [
"import os\n",
"from medcat2.cat import CAT\n",
"from medcat2.components.addons.meta_cat.meta_cat import MetaCATAddon\n",
"from medcat2.config.config_meta_cat import ConfigMetaCAT\n",
"from medcat.cat import CAT\n",
"from medcat.components.addons.meta_cat.meta_cat import MetaCATAddon\n",
"from medcat.config.config_meta_cat import ConfigMetaCAT\n",
"\n",
"BASIC_MODELS_FOLDER = os.path.join(\"..\", \"basic\", \"models\")\n",
"MODEL_NAME = \"sup_trained_model.zip\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
}
],
"source": [
"! pip install \"medcat2[meta-cat,spacy,deid] @ git+https://github.com/CogStack/MedCAT2@v0.3.3\""
"! pip install \"medcat[meta-cat,spacy,deid] @ git+https://github.com/CogStack/MedCAT2@v0.5.0\""
]
},
{
Expand All @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "486327da",
"metadata": {},
"outputs": [
Expand All @@ -163,7 +163,7 @@
"source": [
"model_path = \"models/medcat1_model_pack.zip\"\n",
"new_model_folder = \"models\" # file in this folder\n",
"! python -m medcat2.utils.legacy.legacy_converter $model_path $new_model_folder --verbose"
"! python -m medcat.utils.legacy.legacy_converter $model_path $new_model_folder --verbose"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
medcat2 @ git+https://github.com/CogStack/MedCAT2@v0.3.3
medcat @ git+https://github.com/CogStack/MedCAT2@v0.5.0
ipykernel
pytest-xdist~=3.6.0
nbmake<1.6
Expand Down