imvladikon
commited on
Commit
·
0648f1d
1
Parent(s):
a0caf85
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
task_categories:
|
3 |
+
- token-classification
|
4 |
+
language:
|
5 |
+
- ar
|
6 |
+
size_categories:
|
7 |
+
- 10K<n<100K
|
8 |
+
---
|
9 |
+
|
10 |
+
## Arabic NER
|
11 |
+
|
12 |
+
Sample of the Arabic NER data
|
13 |
+
|
14 |
+
|
15 |
+
## Usage
|
16 |
+
|
17 |
+
```bash
|
18 |
+
pip install datasets
|
19 |
+
```
|
20 |
+
|
21 |
+
Login:
|
22 |
+
```
|
23 |
+
huggingface-cli login
|
24 |
+
```
|
25 |
+
|
26 |
+
```python
|
27 |
+
from datasets import load_dataset
|
28 |
+
|
29 |
+
|
30 |
+
ds = load_dataset("iahlt/arabic_ner_mafat")
|
31 |
+
```
|
32 |
+
|
33 |
+
## Sample
|
34 |
+
|
35 |
+
```json
|
36 |
+
{'id': '42',
|
37 |
+
'ner_tags': [32,
|
38 |
+
32,
|
39 |
+
32,
|
40 |
+
32,
|
41 |
+
32,
|
42 |
+
32,
|
43 |
+
32,
|
44 |
+
32,
|
45 |
+
32,
|
46 |
+
32,
|
47 |
+
32,
|
48 |
+
32,
|
49 |
+
32,
|
50 |
+
32,
|
51 |
+
32,
|
52 |
+
32,
|
53 |
+
32,
|
54 |
+
30,
|
55 |
+
28,
|
56 |
+
28,
|
57 |
+
31],
|
58 |
+
'raw_tags': ['O',
|
59 |
+
'O',
|
60 |
+
'O',
|
61 |
+
'O',
|
62 |
+
'O',
|
63 |
+
'O',
|
64 |
+
'O',
|
65 |
+
'O',
|
66 |
+
'O',
|
67 |
+
'O',
|
68 |
+
'O',
|
69 |
+
'O',
|
70 |
+
'O',
|
71 |
+
'O',
|
72 |
+
'O',
|
73 |
+
'O',
|
74 |
+
'O',
|
75 |
+
'B-MISC',
|
76 |
+
'I-MISC',
|
77 |
+
'I-MISC',
|
78 |
+
'L-MISC'],
|
79 |
+
'record': '{"metadata": {"doc_id": '
|
80 |
+
'"0142895c6cdb030b10c8cc2e5c9639f9422bf22ef45a1b314d7a366fc6489938", '
|
81 |
+
'"url": "https://www.alarab.com//Article/1004953", "source": '
|
82 |
+
'"AlArab", "title": "فوائد غير متوقعة للعلكة الخالية من السكر.. '
|
83 |
+
'اكتشفوها معنا!", "authors": "كل العرب (تصوير: iStockphoto)", '
|
84 |
+
'"date": "2021-08-30 13:25:01", "domains": "التغذية الصحيحة:فوائد '
|
85 |
+
'العلكة الخالية من السكر", "parnumber": "36", "sentnumber": "1", '
|
86 |
+
'"manually_qa-ed": "Yes"}, "text": "يجب عليك الامتناع عن مضغ العلكة '
|
87 |
+
'إذا كنت تعاني من أي نوع من الام الفك أو اضطراب الصدغي الفكي.", '
|
88 |
+
'"label": [[75, 94, "MISC"]], "user": "nlhowell", "timestamp": '
|
89 |
+
'1685356359.342268, "flatten": {"tokens": ["يجب", "علي", "ك", '
|
90 |
+
'"الامتناع", "عن", "مضغ", "العلكة", "إذا", "كنت", "تعاني", "من", '
|
91 |
+
'"أي", "نوع", "من", "الام", "الفك", "أو", "اضطراب", "الصدغي", '
|
92 |
+
'"الفكي", "."], "ner_tags": ["O", "O", "O", "O", "O", "O", "O", '
|
93 |
+
'"O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "B-MISC", '
|
94 |
+
'"I-MISC", "I-MISC", "L-MISC"]}}',
|
95 |
+
'tokens': ['يجب',
|
96 |
+
'علي',
|
97 |
+
'ك',
|
98 |
+
'الامتناع',
|
99 |
+
'عن',
|
100 |
+
'مضغ',
|
101 |
+
'العلكة',
|
102 |
+
'إذا',
|
103 |
+
'كنت',
|
104 |
+
'تعاني',
|
105 |
+
'من',
|
106 |
+
'أي',
|
107 |
+
'نوع',
|
108 |
+
'من',
|
109 |
+
'الام',
|
110 |
+
'الفك',
|
111 |
+
'أو',
|
112 |
+
'اضطراب',
|
113 |
+
'الصدغي',
|
114 |
+
'الفكي',
|
115 |
+
'.']}
|
116 |
+
```
|
117 |
+
|
118 |
+
## Visualization
|
119 |
+
|
120 |
+
|
121 |
+
```bash
|
122 |
+
pip install spacy ipython -q
|
123 |
+
```
|
124 |
+
|
125 |
+
```python
|
126 |
+
import json
|
127 |
+
from spacy.training import offsets_to_biluo_tags, biluo_tags_to_spans
|
128 |
+
|
129 |
+
record = ds[676]
|
130 |
+
record["record"] = json.loads(record["record"])
|
131 |
+
|
132 |
+
ner_tags = record["raw_tags"]
|
133 |
+
tokens = record["tokens"]
|
134 |
+
|
135 |
+
|
136 |
+
doc = spacy.tokens.Doc(spacy.blank("ar").vocab, words=tokens)
|
137 |
+
doc.ents = biluo_tags_to_spans(doc, ner_tags)
|
138 |
+
|
139 |
+
print(record["record"]["text"])
|
140 |
+
spacy.displacy.render(doc, style="ent", jupyter=True)
|
141 |
+
```
|
142 |
+
|
143 |
+
|