Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
Persian
Size:
1K<n<10K
License:
Commit
•
817f06e
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +159 -0
- dataset_infos.json +1 -0
- dummy/fold1/1.1.0/dummy_data.zip +3 -0
- dummy/fold2/1.1.0/dummy_data.zip +3 -0
- dummy/fold3/1.1.0/dummy_data.zip +3 -0
- persian_ner.py +168 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language_creators:
|
5 |
+
- expert-generated
|
6 |
+
languages:
|
7 |
+
- fa
|
8 |
+
licenses:
|
9 |
+
- cc-by-4-0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 1K<n<10K
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- structure-prediction
|
18 |
+
task_ids:
|
19 |
+
- named-entity-recognition
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card for [Persian NER]
|
23 |
+
|
24 |
+
## Table of Contents
|
25 |
+
- [Dataset Description](#dataset-description)
|
26 |
+
- [Dataset Summary](#dataset-summary)
|
27 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
28 |
+
- [Languages](#languages)
|
29 |
+
- [Dataset Structure](#dataset-structure)
|
30 |
+
- [Data Instances](#data-instances)
|
31 |
+
- [Data Fields](#data-instances)
|
32 |
+
- [Data Splits](#data-instances)
|
33 |
+
- [Dataset Creation](#dataset-creation)
|
34 |
+
- [Curation Rationale](#curation-rationale)
|
35 |
+
- [Source Data](#source-data)
|
36 |
+
- [Annotations](#annotations)
|
37 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
38 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
39 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
40 |
+
- [Discussion of Biases](#discussion-of-biases)
|
41 |
+
- [Other Known Limitations](#other-known-limitations)
|
42 |
+
- [Additional Information](#additional-information)
|
43 |
+
- [Dataset Curators](#dataset-curators)
|
44 |
+
- [Licensing Information](#licensing-information)
|
45 |
+
- [Citation Information](#citation-information)
|
46 |
+
|
47 |
+
## Dataset Description
|
48 |
+
|
49 |
+
- **Homepage:** [Github](https://github.com/HaniehP/PersianNER)
|
50 |
+
- **Repository:** [Github](https://github.com/HaniehP/PersianNER)
|
51 |
+
- **Paper:** [Aclweb](https://www.aclweb.org/anthology/C16-1319)
|
52 |
+
- **Leaderboard:**
|
53 |
+
- **Point of Contact:**
|
54 |
+
|
55 |
+
### Dataset Summary
|
56 |
+
|
57 |
+
The dataset includes 7,682 Persian sentences, split into 250,015 tokens and their NER labels. It is available in 3 folds to be used in turn as training and test sets. The NER tags are in IOB format.
|
58 |
+
|
59 |
+
### Supported Tasks and Leaderboards
|
60 |
+
|
61 |
+
[More Information Needed]
|
62 |
+
|
63 |
+
### Languages
|
64 |
+
|
65 |
+
[More Information Needed]
|
66 |
+
|
67 |
+
## Dataset Structure
|
68 |
+
|
69 |
+
### Data Instances
|
70 |
+
|
71 |
+
|
72 |
+
### Data Fields
|
73 |
+
|
74 |
+
- `id`: id of the sample
|
75 |
+
- `tokens`: the tokens of the example text
|
76 |
+
- `ner_tags`: the NER tags of each token
|
77 |
+
|
78 |
+
The NER tags correspond to this list:
|
79 |
+
```
|
80 |
+
"O", "I-event", "I-fac", "I-loc", "I-org", "I-pers", "I-pro", "B-event", "B-fac", "B-loc", "B-org", "B-pers", "B-pro"
|
81 |
+
```
|
82 |
+
|
83 |
+
### Data Splits
|
84 |
+
|
85 |
+
Training and test splits
|
86 |
+
|
87 |
+
## Dataset Creation
|
88 |
+
|
89 |
+
### Curation Rationale
|
90 |
+
|
91 |
+
[More Information Needed]
|
92 |
+
|
93 |
+
### Source Data
|
94 |
+
|
95 |
+
#### Initial Data Collection and Normalization
|
96 |
+
|
97 |
+
[More Information Needed]
|
98 |
+
|
99 |
+
#### Who are the source language producers?
|
100 |
+
|
101 |
+
Hanieh Poostchi, Ehsan Zare Borzeshi, Mohammad Abdous, Massimo Piccardi
|
102 |
+
|
103 |
+
### Annotations
|
104 |
+
|
105 |
+
#### Annotation process
|
106 |
+
|
107 |
+
[More Information Needed]
|
108 |
+
|
109 |
+
#### Who are the annotators?
|
110 |
+
|
111 |
+
Hanieh Poostchi, Ehsan Zare Borzeshi, Mohammad Abdous, Massimo Piccardi
|
112 |
+
|
113 |
+
### Personal and Sensitive Information
|
114 |
+
|
115 |
+
[More Information Needed]
|
116 |
+
|
117 |
+
## Considerations for Using the Data
|
118 |
+
|
119 |
+
### Social Impact of Dataset
|
120 |
+
|
121 |
+
[More Information Needed]
|
122 |
+
|
123 |
+
### Discussion of Biases
|
124 |
+
|
125 |
+
[More Information Needed]
|
126 |
+
|
127 |
+
### Other Known Limitations
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
## Additional Information
|
132 |
+
|
133 |
+
Dataset is published for academic use only
|
134 |
+
|
135 |
+
### Dataset Curators
|
136 |
+
|
137 |
+
[More Information Needed]
|
138 |
+
|
139 |
+
### Licensing Information
|
140 |
+
|
141 |
+
Creative Commons Attribution 4.0 International License.
|
142 |
+
|
143 |
+
### Citation Information
|
144 |
+
|
145 |
+
@inproceedings{poostchi-etal-2016-personer,
|
146 |
+
title = "{P}erso{NER}: {P}ersian Named-Entity Recognition",
|
147 |
+
author = "Poostchi, Hanieh and
|
148 |
+
Zare Borzeshi, Ehsan and
|
149 |
+
Abdous, Mohammad and
|
150 |
+
Piccardi, Massimo",
|
151 |
+
booktitle = "Proceedings of {COLING} 2016, the 26th International Conference on Computational Linguistics: Technical Papers",
|
152 |
+
month = dec,
|
153 |
+
year = "2016",
|
154 |
+
address = "Osaka, Japan",
|
155 |
+
publisher = "The COLING 2016 Organizing Committee",
|
156 |
+
url = "https://www.aclweb.org/anthology/C16-1319",
|
157 |
+
pages = "3381--3389",
|
158 |
+
abstract = "Named-Entity Recognition (NER) is still a challenging task for languages with low digital resources. The main difficulties arise from the scarcity of annotated corpora and the consequent problematic training of an effective NER pipeline. To abridge this gap, in this paper we target the Persian language that is spoken by a population of over a hundred million people world-wide. We first present and provide ArmanPerosNERCorpus, the first manually-annotated Persian NER corpus. Then, we introduce PersoNER, an NER pipeline for Persian that leverages a word embedding and a sequential max-margin classifier. The experimental results show that the proposed approach is capable of achieving interesting MUC7 and CoNNL scores while outperforming two alternatives based on a CRF and a recurrent neural network.",
|
159 |
+
}
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"fold1": {"description": "The dataset includes 250,015 tokens and 7,682 Persian sentences in total. It is available in 3 folds to be used in turn as training and test sets. The NER tags are in IOB format.\n", "citation": "@inproceedings{poostchi-etal-2016-personer,\n title = \"{P}erso{NER}: {P}ersian Named-Entity Recognition\",\n author = \"Poostchi, Hanieh and\n Zare Borzeshi, Ehsan and\n Abdous, Mohammad and\n Piccardi, Massimo\",\n booktitle = \"Proceedings of {COLING} 2016, the 26th International Conference on Computational Linguistics: Technical Papers\",\n month = dec,\n year = \"2016\",\n address = \"Osaka, Japan\",\n publisher = \"The COLING 2016 Organizing Committee\",\n url = \"https://www.aclweb.org/anthology/C16-1319\",\n pages = \"3381--3389\",\n abstract = \"Named-Entity Recognition (NER) is still a challenging task for languages with low digital resources. The main difficulties arise from the scarcity of annotated corpora and the consequent problematic training of an effective NER pipeline. To abridge this gap, in this paper we target the Persian language that is spoken by a population of over a hundred million people world-wide. We first present and provide ArmanPerosNERCorpus, the first manually-annotated Persian NER corpus. Then, we introduce PersoNER, an NER pipeline for Persian that leverages a word embedding and a sequential max-margin classifier. The experimental results show that the proposed approach is capable of achieving interesting MUC7 and CoNNL scores while outperforming two alternatives based on a CRF and a recurrent neural network.\",\n}\n", "homepage": "", "license": "Creative Commons Attribution 4.0 International License", "features": {"tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 13, "names": ["O", "I-event", "I-fac", "I-loc", "I-org", "I-pers", "I-pro", "B-event", "B-fac", "B-loc", "B-org", "B-pers", "B-pro"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": {"input": "tokens", "output": "ner_tags"}, "builder_name": "persian_ner", "config_name": "fold1", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3362102, "num_examples": 5121, "dataset_name": "persian_ner"}, "test": {"name": "test", "num_bytes": 1646481, "num_examples": 2560, "dataset_name": "persian_ner"}}, "download_checksums": {"https://github.com/HaniehP/PersianNER/raw/master/ArmanPersoNERCorpus.zip": {"num_bytes": 1931170, "checksum": "4a7aa9b3a52707468bb40f00b152f83fa922a76d20b6b0e2c24845712c34b664"}}, "download_size": 1931170, "post_processing_size": null, "dataset_size": 5008583, "size_in_bytes": 6939753}, "fold2": {"description": "The dataset includes 250,015 tokens and 7,682 Persian sentences in total. It is available in 3 folds to be used in turn as training and test sets. The NER tags are in IOB format.\n", "citation": "@inproceedings{poostchi-etal-2016-personer,\n title = \"{P}erso{NER}: {P}ersian Named-Entity Recognition\",\n author = \"Poostchi, Hanieh and\n Zare Borzeshi, Ehsan and\n Abdous, Mohammad and\n Piccardi, Massimo\",\n booktitle = \"Proceedings of {COLING} 2016, the 26th International Conference on Computational Linguistics: Technical Papers\",\n month = dec,\n year = \"2016\",\n address = \"Osaka, Japan\",\n publisher = \"The COLING 2016 Organizing Committee\",\n url = \"https://www.aclweb.org/anthology/C16-1319\",\n pages = \"3381--3389\",\n abstract = \"Named-Entity Recognition (NER) is still a challenging task for languages with low digital resources. The main difficulties arise from the scarcity of annotated corpora and the consequent problematic training of an effective NER pipeline. To abridge this gap, in this paper we target the Persian language that is spoken by a population of over a hundred million people world-wide. We first present and provide ArmanPerosNERCorpus, the first manually-annotated Persian NER corpus. Then, we introduce PersoNER, an NER pipeline for Persian that leverages a word embedding and a sequential max-margin classifier. The experimental results show that the proposed approach is capable of achieving interesting MUC7 and CoNNL scores while outperforming two alternatives based on a CRF and a recurrent neural network.\",\n}\n", "homepage": "", "license": "Creative Commons Attribution 4.0 International License", "features": {"tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 13, "names": ["O", "I-event", "I-fac", "I-loc", "I-org", "I-pers", "I-pro", "B-event", "B-fac", "B-loc", "B-org", "B-pers", "B-pro"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": {"input": "tokens", "output": "ner_tags"}, "builder_name": "persian_ner", "config_name": "fold2", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3344561, "num_examples": 5120, "dataset_name": "persian_ner"}, "test": {"name": "test", "num_bytes": 1664022, "num_examples": 2561, "dataset_name": "persian_ner"}}, "download_checksums": {"https://github.com/HaniehP/PersianNER/raw/master/ArmanPersoNERCorpus.zip": {"num_bytes": 1931170, "checksum": "4a7aa9b3a52707468bb40f00b152f83fa922a76d20b6b0e2c24845712c34b664"}}, "download_size": 1931170, "post_processing_size": null, "dataset_size": 5008583, "size_in_bytes": 6939753}, "fold3": {"description": "The dataset includes 250,015 tokens and 7,682 Persian sentences in total. It is available in 3 folds to be used in turn as training and test sets. The NER tags are in IOB format.\n", "citation": "@inproceedings{poostchi-etal-2016-personer,\n title = \"{P}erso{NER}: {P}ersian Named-Entity Recognition\",\n author = \"Poostchi, Hanieh and\n Zare Borzeshi, Ehsan and\n Abdous, Mohammad and\n Piccardi, Massimo\",\n booktitle = \"Proceedings of {COLING} 2016, the 26th International Conference on Computational Linguistics: Technical Papers\",\n month = dec,\n year = \"2016\",\n address = \"Osaka, Japan\",\n publisher = \"The COLING 2016 Organizing Committee\",\n url = \"https://www.aclweb.org/anthology/C16-1319\",\n pages = \"3381--3389\",\n abstract = \"Named-Entity Recognition (NER) is still a challenging task for languages with low digital resources. The main difficulties arise from the scarcity of annotated corpora and the consequent problematic training of an effective NER pipeline. To abridge this gap, in this paper we target the Persian language that is spoken by a population of over a hundred million people world-wide. We first present and provide ArmanPerosNERCorpus, the first manually-annotated Persian NER corpus. Then, we introduce PersoNER, an NER pipeline for Persian that leverages a word embedding and a sequential max-margin classifier. The experimental results show that the proposed approach is capable of achieving interesting MUC7 and CoNNL scores while outperforming two alternatives based on a CRF and a recurrent neural network.\",\n}\n", "homepage": "", "license": "Creative Commons Attribution 4.0 International License", "features": {"tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 13, "names": ["O", "I-event", "I-fac", "I-loc", "I-org", "I-pers", "I-pro", "B-event", "B-fac", "B-loc", "B-org", "B-pers", "B-pro"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": {"input": "tokens", "output": "ner_tags"}, "builder_name": "persian_ner", "config_name": "fold3", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3310491, "num_examples": 5121, "dataset_name": "persian_ner"}, "test": {"name": "test", "num_bytes": 1698092, "num_examples": 2560, "dataset_name": "persian_ner"}}, "download_checksums": {"https://github.com/HaniehP/PersianNER/raw/master/ArmanPersoNERCorpus.zip": {"num_bytes": 1931170, "checksum": "4a7aa9b3a52707468bb40f00b152f83fa922a76d20b6b0e2c24845712c34b664"}}, "download_size": 1931170, "post_processing_size": null, "dataset_size": 5008583, "size_in_bytes": 6939753}}
|
dummy/fold1/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b6e24fae9c1ad38e606a87fe5abf83b1b517aea506bebf73f9117ee683595e93
|
3 |
+
size 9238
|
dummy/fold2/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d09d9e5aeaef3ed7485ded734084e6bc13efd8aacbe664c851498062f2493e00
|
3 |
+
size 9238
|
dummy/fold3/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d09d9e5aeaef3ed7485ded734084e6bc13efd8aacbe664c851498062f2493e00
|
3 |
+
size 9238
|
persian_ner.py
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""ArmanPerosNERCorpus - the first manually-annotated Persian NER corpus."""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import os
|
20 |
+
|
21 |
+
import datasets
|
22 |
+
|
23 |
+
|
24 |
+
_CITATION = """\
|
25 |
+
@inproceedings{poostchi-etal-2016-personer,
|
26 |
+
title = "{P}erso{NER}: {P}ersian Named-Entity Recognition",
|
27 |
+
author = "Poostchi, Hanieh and
|
28 |
+
Zare Borzeshi, Ehsan and
|
29 |
+
Abdous, Mohammad and
|
30 |
+
Piccardi, Massimo",
|
31 |
+
booktitle = "Proceedings of {COLING} 2016, the 26th International Conference on Computational Linguistics: Technical Papers",
|
32 |
+
month = dec,
|
33 |
+
year = "2016",
|
34 |
+
address = "Osaka, Japan",
|
35 |
+
publisher = "The COLING 2016 Organizing Committee",
|
36 |
+
url = "https://www.aclweb.org/anthology/C16-1319",
|
37 |
+
pages = "3381--3389",
|
38 |
+
abstract = "Named-Entity Recognition (NER) is still a challenging task for languages with low digital resources. The main difficulties arise from the scarcity of annotated corpora and the consequent problematic training of an effective NER pipeline. To abridge this gap, in this paper we target the Persian language that is spoken by a population of over a hundred million people world-wide. We first present and provide ArmanPerosNERCorpus, the first manually-annotated Persian NER corpus. Then, we introduce PersoNER, an NER pipeline for Persian that leverages a word embedding and a sequential max-margin classifier. The experimental results show that the proposed approach is capable of achieving interesting MUC7 and CoNNL scores while outperforming two alternatives based on a CRF and a recurrent neural network.",
|
39 |
+
}
|
40 |
+
"""
|
41 |
+
|
42 |
+
# TODO: Add description of the dataset here
|
43 |
+
# You can copy an official description
|
44 |
+
_DESCRIPTION = """\
|
45 |
+
The dataset includes 250,015 tokens and 7,682 Persian sentences in total. It is available in 3 folds to be used in turn as training and test sets. The NER tags are in IOB format.
|
46 |
+
"""
|
47 |
+
|
48 |
+
_HOMEPAGE = ""
|
49 |
+
|
50 |
+
_LICENSE = "Creative Commons Attribution 4.0 International License"
|
51 |
+
|
52 |
+
_URL = "https://github.com/HaniehP/PersianNER/raw/master/ArmanPersoNERCorpus.zip"
|
53 |
+
|
54 |
+
|
55 |
+
class PersianNER(datasets.GeneratorBasedBuilder):
|
56 |
+
"""ArmanPerosNERCorpus - the first manually-annotated Persian NER corpus."""
|
57 |
+
|
58 |
+
VERSION = datasets.Version("1.1.0")
|
59 |
+
|
60 |
+
# This is an example of a dataset with multiple configurations.
|
61 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
62 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
63 |
+
|
64 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
65 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
66 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
67 |
+
|
68 |
+
# You will be able to load one or the other configurations in the following list with
|
69 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
70 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
71 |
+
BUILDER_CONFIGS = [
|
72 |
+
datasets.BuilderConfig(
|
73 |
+
name="fold1", version=VERSION, description="This is the first fold of the ArmanPersoNERCorpus"
|
74 |
+
),
|
75 |
+
datasets.BuilderConfig(
|
76 |
+
name="fold2", version=VERSION, description="This is the second fold of the ArmanPersoNERCorpus"
|
77 |
+
),
|
78 |
+
datasets.BuilderConfig(
|
79 |
+
name="fold3", version=VERSION, description="This is the third fold of the ArmanPersoNERCorpus"
|
80 |
+
),
|
81 |
+
]
|
82 |
+
|
83 |
+
DEFAULT_CONFIG_NAME = "fold1" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
84 |
+
|
85 |
+
def _info(self):
|
86 |
+
features = datasets.Features(
|
87 |
+
{
|
88 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
89 |
+
"ner_tags": datasets.Sequence(
|
90 |
+
datasets.ClassLabel(
|
91 |
+
names=[
|
92 |
+
"O",
|
93 |
+
"I-event",
|
94 |
+
"I-fac",
|
95 |
+
"I-loc",
|
96 |
+
"I-org",
|
97 |
+
"I-pers",
|
98 |
+
"I-pro",
|
99 |
+
"B-event",
|
100 |
+
"B-fac",
|
101 |
+
"B-loc",
|
102 |
+
"B-org",
|
103 |
+
"B-pers",
|
104 |
+
"B-pro",
|
105 |
+
]
|
106 |
+
)
|
107 |
+
),
|
108 |
+
}
|
109 |
+
)
|
110 |
+
|
111 |
+
return datasets.DatasetInfo(
|
112 |
+
description=_DESCRIPTION,
|
113 |
+
features=features,
|
114 |
+
supervised_keys=("tokens", "ner_tags"),
|
115 |
+
homepage=_HOMEPAGE,
|
116 |
+
license=_LICENSE,
|
117 |
+
citation=_CITATION,
|
118 |
+
)
|
119 |
+
|
120 |
+
def _split_generators(self, dl_manager):
|
121 |
+
"""Returns SplitGenerators."""
|
122 |
+
|
123 |
+
my_urls = _URL
|
124 |
+
data_dir = dl_manager.download_and_extract(my_urls)
|
125 |
+
|
126 |
+
return [
|
127 |
+
datasets.SplitGenerator(
|
128 |
+
name=datasets.Split.TRAIN,
|
129 |
+
gen_kwargs={
|
130 |
+
"filepath": os.path.join(data_dir, f"train_{self.config.name}.txt"),
|
131 |
+
"split": "train",
|
132 |
+
},
|
133 |
+
),
|
134 |
+
datasets.SplitGenerator(
|
135 |
+
name=datasets.Split.TEST,
|
136 |
+
gen_kwargs={"filepath": os.path.join(data_dir, f"test_{self.config.name}.txt"), "split": "test"},
|
137 |
+
),
|
138 |
+
]
|
139 |
+
|
140 |
+
def _generate_examples(self, filepath, split):
|
141 |
+
""" Yields examples. """
|
142 |
+
|
143 |
+
with open(filepath, "r", encoding="utf-8") as f:
|
144 |
+
id_ = 0
|
145 |
+
tokens = []
|
146 |
+
ner_labels = []
|
147 |
+
for line in f:
|
148 |
+
stripped_line = line.strip(" \n") # strip away whitespaces AND new line characters
|
149 |
+
if len(stripped_line) == 0:
|
150 |
+
# If line is empty, it means we reached the end of a sentence.
|
151 |
+
# We can yield the tokens and labels
|
152 |
+
if len(tokens) > 0 and len(ner_labels) > 0:
|
153 |
+
yield id_, {
|
154 |
+
"tokens": tokens,
|
155 |
+
"ner_tags": ner_labels,
|
156 |
+
}
|
157 |
+
else:
|
158 |
+
# Do not yield if tokens or ner_labels is empty
|
159 |
+
# It can be the case if several empty lines are contiguous
|
160 |
+
continue
|
161 |
+
# Then we need to increment the _id and reset the tokens and ner_labels list
|
162 |
+
id_ += 1
|
163 |
+
tokens = []
|
164 |
+
ner_labels = []
|
165 |
+
else:
|
166 |
+
token, ner_label = line.split(" ") # Retrieve token and label
|
167 |
+
tokens.append(token)
|
168 |
+
ner_labels.append(ner_label)
|