Muhsabrys commited on
Commit
d67eea8
ยท
verified ยท
1 Parent(s): 34b2614

Upload notebook.ipynb

Browse files
Files changed (1) hide show
  1. notebook.ipynb +95 -0
notebook.ipynb ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# AMWAL: Arabic Financial Named Entity Recognition (NER)\n",
8
+ "\n",
9
+ "This notebook demonstrates the **correct and supported way** to use the AMWAL model.\n",
10
+ "\n",
11
+ "> โš ๏ธ **Important**: Do **not** use `spacy.load(\"AMWAL_ArFinNER\")`.\n",
12
+ "> This model must be loaded via the provided `load_ner()` API.\n"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": null,
18
+ "metadata": {},
19
+ "outputs": [],
20
+ "source": [
21
+ "# Install dependencies\n",
22
+ "!pip install -q spacy huggingface_hub\n",
23
+ "!pip install -q git+https://huggingface.co/Muhsabrys/AMWAL_ArFinNER\n"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": null,
29
+ "metadata": {},
30
+ "outputs": [],
31
+ "source": [
32
+ "# Correct usage\n",
33
+ "from amwal import load_ner\n",
34
+ "\n",
35
+ "ner = load_ner()\n",
36
+ "\n",
37
+ "text = \"ุฃุนู„ู† ุตู†ุฏูˆู‚ ู‚ุทุฑ ุงู„ุณูŠุงุฏูŠ ุนู† ุงุณุชุซู…ุงุฑ ุจู‚ูŠู…ุฉ 500 ู…ู„ูŠูˆู† ุฏูˆู„ุงุฑ ุฃู…ุฑูŠูƒูŠ ููŠ ุณู†ุฏุงุช ุญูƒูˆู…ูŠุฉ ูŠุงุจุงู†ูŠุฉ ููŠ ุทูˆูƒูŠูˆ.\"\n",
38
+ "result = ner(text)\n",
39
+ "\n",
40
+ "result\n"
41
+ ]
42
+ },
43
+ {
44
+ "cell_type": "markdown",
45
+ "metadata": {},
46
+ "source": [
47
+ "## Alternative: Load directly from Hugging Face without installation\n",
48
+ "\n",
49
+ "This method is useful if you do not want to install the package system-wide."
50
+ ]
51
+ },
52
+ {
53
+ "cell_type": "code",
54
+ "execution_count": null,
55
+ "metadata": {},
56
+ "outputs": [],
57
+ "source": [
58
+ "from huggingface_hub import snapshot_download\n",
59
+ "import sys\n",
60
+ "\n",
61
+ "repo_path = snapshot_download(\"Muhsabrys/AMWAL_ArFinNER\")\n",
62
+ "sys.path.append(repo_path)\n",
63
+ "\n",
64
+ "from amwal import load_ner\n",
65
+ "ner = load_ner(local_path=repo_path)\n",
66
+ "\n",
67
+ "ner(\"ุฃุนู„ู† ุตู†ุฏูˆู‚ ู‚ุทุฑ ุงู„ุณูŠุงุฏูŠ ุนู† ุงุณุชุซู…ุงุฑ ุจู‚ูŠู…ุฉ 500 ู…ู„ูŠูˆู† ุฏูˆู„ุงุฑ ุฃู…ุฑูŠูƒูŠ ููŠ ุณู†ุฏุงุช ุญูƒูˆู…ูŠุฉ ูŠุงุจุงู†ูŠุฉ ููŠ ุทูˆูƒูŠูˆ.\")\n"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "markdown",
72
+ "metadata": {},
73
+ "source": [
74
+ "## Notes\n",
75
+ "\n",
76
+ "- AMWAL is a **spaCy-based** NER system.\n",
77
+ "- It is **not compatible** with Hugging Face Transformers APIs.\n",
78
+ "- Always use the `load_ner()` function provided by the package.\n"
79
+ ]
80
+ }
81
+ ],
82
+ "metadata": {
83
+ "kernelspec": {
84
+ "display_name": "Python 3",
85
+ "language": "python",
86
+ "name": "python3"
87
+ },
88
+ "language_info": {
89
+ "name": "python",
90
+ "version": "3.x"
91
+ }
92
+ },
93
+ "nbformat": 4,
94
+ "nbformat_minor": 5
95
+ }