File size: 2,827 Bytes
d67eea8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 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 |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# AMWAL: Arabic Financial Named Entity Recognition (NER)\n",
"\n",
"This notebook demonstrates the **correct and supported way** to use the AMWAL model.\n",
"\n",
"> โ ๏ธ **Important**: Do **not** use `spacy.load(\"AMWAL_ArFinNER\")`.\n",
"> This model must be loaded via the provided `load_ner()` API.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Install dependencies\n",
"!pip install -q spacy huggingface_hub\n",
"!pip install -q git+https://huggingface.co/Muhsabrys/AMWAL_ArFinNER\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Correct usage\n",
"from amwal import load_ner\n",
"\n",
"ner = load_ner()\n",
"\n",
"text = \"ุฃุนูู ุตูุฏูู ูุทุฑ ุงูุณูุงุฏู ุนู ุงุณุชุซู
ุงุฑ ุจููู
ุฉ 500 ู
ูููู ุฏููุงุฑ ุฃู
ุฑููู ูู ุณูุฏุงุช ุญููู
ูุฉ ูุงุจุงููุฉ ูู ุทูููู.\"\n",
"result = ner(text)\n",
"\n",
"result\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Alternative: Load directly from Hugging Face without installation\n",
"\n",
"This method is useful if you do not want to install the package system-wide."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from huggingface_hub import snapshot_download\n",
"import sys\n",
"\n",
"repo_path = snapshot_download(\"Muhsabrys/AMWAL_ArFinNER\")\n",
"sys.path.append(repo_path)\n",
"\n",
"from amwal import load_ner\n",
"ner = load_ner(local_path=repo_path)\n",
"\n",
"ner(\"ุฃุนูู ุตูุฏูู ูุทุฑ ุงูุณูุงุฏู ุนู ุงุณุชุซู
ุงุฑ ุจููู
ุฉ 500 ู
ูููู ุฏููุงุฑ ุฃู
ุฑููู ูู ุณูุฏุงุช ุญููู
ูุฉ ูุงุจุงููุฉ ูู ุทูููู.\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Notes\n",
"\n",
"- AMWAL is a **spaCy-based** NER system.\n",
"- It is **not compatible** with Hugging Face Transformers APIs.\n",
"- Always use the `load_ner()` function provided by the package.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.x"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|