{ "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 }