|
--- |
|
task_categories: |
|
- token-classification |
|
language: |
|
- ar |
|
size_categories: |
|
- 10K<n<100K |
|
configs: |
|
- config_name: default |
|
data_files: |
|
- split: train |
|
path: data/train-* |
|
dataset_info: |
|
features: |
|
- name: tokens |
|
sequence: string |
|
- name: raw_tags |
|
sequence: string |
|
- name: ner_tags |
|
sequence: int64 |
|
- name: spaces |
|
sequence: int64 |
|
- name: spans |
|
list: |
|
- name: end |
|
dtype: int64 |
|
- name: label |
|
dtype: string |
|
- name: start |
|
dtype: int64 |
|
- name: text |
|
dtype: string |
|
- name: record |
|
dtype: string |
|
- name: text |
|
dtype: string |
|
splits: |
|
- name: train |
|
num_bytes: 181231147 |
|
num_examples: 40000 |
|
download_size: 52900580 |
|
dataset_size: 181231147 |
|
--- |
|
|
|
## Arabic NER |
|
|
|
This dataset provides spans-level and token-level Named Entity Recognition (NER) annotations for Arabic text. |
|
|
|
It includes: |
|
|
|
Coarse-grained annotations (e.g., MISC, ORG, LOC, etc.) appearing in the spans field. |
|
Fine-grained annotations in BILUO format (e.g., B-MISC, I-MISC, L-MISC) in the raw_tags field, and their corresponding numeric IDs in the ner_tags field. |
|
|
|
Check annotation guideline and details [here](https://iahlt.github.io/arabic_ner/) |
|
|
|
Below is a brief description of each field: |
|
|
|
tokens: A list of individual tokens (words) extracted from the text. Important note, it's processed using span-based annotation(spans), to get morhpology-rich token-based annotation, please use your own tokenization and processing method. |
|
raw_tags: The original, text-based BILUO entity tags per token (e.g., B-MISC, I-MISC, etc.). |
|
ner_tags: The integer indices corresponding to each raw_tags label (following the label scheme in dataset_info). |
|
spaces: A sequence of integers (0 or 1) indicating whether a space follows the corresponding token. |
|
spans: A list of dictionaries, each containing (top-level of the annotated record["label_hierarchy"] which contains both annotations fine- and coarse-grained): |
|
start and end character offsets of the entity in the original text |
|
text of the entity span |
|
label (entity) |
|
record: A JSON-encoded string with additional metadata about the document ['metadata', 'text', 'label', 'user', 'timestamp', 'flatten', 'label_hierarchy', 'has_overlappings', 'n_hierarchy_levels'] |
|
Sample of the Arabic NER data: |
|
|
|
|
|
## Usage |
|
|
|
```bash |
|
pip install datasets |
|
``` |
|
|
|
Login: |
|
``` |
|
huggingface-cli login |
|
``` |
|
|
|
```python |
|
from datasets import load_dataset |
|
|
|
|
|
ds = load_dataset("iahlt/arabic_ner_mafat") |
|
|
|
for sample in ds["train"]: |
|
print(sample) |
|
|
|
``` |
|
|
|
## Sample |
|
|
|
```json |
|
{ |
|
"tokens": ["يجب", "عليك", "الامتناع", "عن", "مضغ", "العلكة", "ا", "ٕ", "ذا", "كنت", "تعاني", "من", "ا", "ٔ", "ي", "نوع", "من", "الام", "الفك", "ا", "ٔ", "و", "اضطراب", "الصدغي", "الفكي", "."], |
|
"raw_tags": ["O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "B-MISC", "I-MISC", "L-MISC", "O"], |
|
"ner_tags": [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 30, 28, 31, 32], |
|
"spaces": [1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0], |
|
"spans": [ |
|
{ |
|
"end": 94, |
|
"label": "MISC", |
|
"start": 75, |
|
"text": "اضطراب الصدغي الفكي" |
|
} |
|
], |
|
"record": "{\"metadata\": {\"doc_id\": \"0142895c6cdb030b10c8cc2e5c9639f9422bf22ef45a1b314d7a366fc6489938\", \"url\": \"https://www.alarab.com//Article/1004953\", \"source\": \"AlArab\", \"title\": \"فوائد غير متوقعة للعلكة الخالية من السكر.. اكتشفوها معنا!\", \"authors\": \"كل العرب (تصوير: iStockphoto)\", \"date\": \"2021-08-30 13:25:01\", \"domains\": \"التغذية الصحيحة:فوائد العلكة الخالية من السكر\", \"parnumber\": \"36\", \"sentnumber\": \"1\", \"manually_qa-ed\": \"Yes\"}, \"text\": \"يجب عليك الامتناع عن مضغ العلكة إذا كنت تعاني من أي نوع من الام الفك أو اضطراب الصدغي الفكي.\", \"label\": [[75, 94, \"MISC\"]], \"user\": \"nlhowell\", \"timestamp\": 1685356359.342268, \"flatten\": {\"tokens\": [\"يجب\", \"عليك\", \"الامتناع\", \"عن\", \"مضغ\", \"العلكة\", \"ا\", \"ٕ\", \"ذا\", \"كنت\", \"تعاني\", \"من\", \"ا\", \"ٔ\", \"ي\", \"نوع\", \"من\", \"الام\", \"الفك\", \"ا\", \"ٔ\", \"و\", \"اضطراب\", \"الصدغي\", \"الفكي\", \".\"], \"ner_tags\": [\"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"B-MISC\", \"I-MISC\", \"L-MISC\", \"O\"], \"spaces\": [1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0]}, \"label_hierarchy\": {\"0\": [{\"end\": 94, \"label\": \"MISC\", \"start\": 75, \"text\": \"اضطراب الصدغي الفكي\"}], \"1\": null, \"2\": null, \"3\": null, \"4\": null, \"5\": null}, \"has_overlappings\": false, \"n_hierarchy_levels\": 1}" |
|
} |
|
``` |
|
|
|
## Visualization |
|
|
|
|
|
```bash |
|
pip install spacy ipython -q |
|
``` |
|
|
|
```python |
|
import json |
|
from spacy.training import offsets_to_biluo_tags, biluo_tags_to_spans |
|
|
|
record = ds[676] |
|
record["record"] = json.loads(record["record"]) |
|
|
|
ner_tags = record["raw_tags"] |
|
tokens = record["tokens"] |
|
|
|
|
|
doc = spacy.tokens.Doc(spacy.blank("ar").vocab, words=tokens) |
|
doc.ents = biluo_tags_to_spans(doc, ner_tags) |
|
|
|
print(record["record"]["text"]) |
|
spacy.displacy.render(doc, style="ent", jupyter=True) |
|
``` |
|
|
|
|
|
|