Datasets:

Languages:
Arabic
Multilinguality:
multilingual
Size Categories:
n<1K
Language Creators:
found
Annotations Creators:
expert-generated
Source Datasets:
extended
ArXiv:
Tags:
License:
albertvillanova HF staff commited on
Commit
7474812
1 Parent(s): c2a239a

Delete loading script

Browse files
Files changed (1) hide show
  1. arabic_pos_dialect.py +0 -153
arabic_pos_dialect.py DELETED
@@ -1,153 +0,0 @@
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
- """TODO: Add a description here."""
16
-
17
-
18
- import csv
19
-
20
- import datasets
21
-
22
-
23
- _CITATION = """
24
- @InProceedings{DARWISH18.562, author = {Kareem Darwish ,Hamdy Mubarak ,Ahmed Abdelali ,Mohamed Eldesouki ,Younes Samih ,Randah Alharbi ,Mohammed Attia ,Walid Magdy and Laura Kallmeyer},
25
- title = {Multi-Dialect Arabic POS Tagging: A CRF Approach},
26
- booktitle = {Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC 2018)},
27
- year = {2018},
28
- month = {may},
29
- date = {7-12},
30
- location = {Miyazaki, Japan},
31
- editor = {Nicoletta Calzolari (Conference chair) and Khalid Choukri and Christopher Cieri and Thierry Declerck and Sara Goggi and Koiti Hasida and Hitoshi Isahara and Bente Maegaard and Joseph Mariani and Hélène Mazo and Asuncion Moreno and Jan Odijk and Stelios Piperidis and Takenobu Tokunaga},
32
- publisher = {European Language Resources Association (ELRA)},
33
- address = {Paris, France},
34
- isbn = {979-10-95546-00-9},
35
- language = {english}
36
- }
37
- """
38
-
39
- _DESCRIPTION = """\
40
- The Dialectal Arabic Datasets contain four dialects of Arabic, Etyptian (EGY), Levantine (LEV), Gulf (GLF), and Maghrebi (MGR). Each dataset consists of a set of 350 manually segmented and POS tagged tweets.
41
- """
42
-
43
- _URL = "https://github.com/qcri/dialectal_arabic_resources/raw/master/"
44
- _DIALECTS = ["egy", "lev", "glf", "mgr"]
45
-
46
-
47
- class ArabicPosDialectConfig(datasets.BuilderConfig):
48
- """BuilderConfig for ArabicPosDialect"""
49
-
50
- def __init__(self, dialect=None, **kwargs):
51
- """
52
-
53
- Args:
54
- dialect: the 3-letter code string of the dialect set that will be used.
55
- Code should be one of the following: egy, lev, glf, mgr.
56
- **kwargs: keyword arguments forwarded to super.
57
- """
58
- super(ArabicPosDialectConfig, self).__init__(**kwargs)
59
- assert dialect in _DIALECTS, ("Invalid dialect code: %s", dialect)
60
- self.dialect = dialect
61
-
62
-
63
- class ArabicPosDialect(datasets.GeneratorBasedBuilder):
64
- """POS-tagged Arabic tweets in four major dialects."""
65
-
66
- VERSION = datasets.Version("1.1.0")
67
- BUILDER_CONFIG_CLASS = ArabicPosDialectConfig
68
- BUILDER_CONFIGS = [
69
- ArabicPosDialectConfig(
70
- name=dialect,
71
- dialect=dialect,
72
- description=f"A set of 350 tweets in the {dialect} dialect of Arabic that have been manually segmented and POS tagged.",
73
- )
74
- for dialect in _DIALECTS
75
- ]
76
-
77
- def _info(self):
78
- return datasets.DatasetInfo(
79
- description=_DESCRIPTION,
80
- features=datasets.Features(
81
- {
82
- "fold": datasets.Value("int32"),
83
- "subfold": datasets.Value("string"),
84
- "words": datasets.Sequence(datasets.Value("string")),
85
- "segments": datasets.Sequence(datasets.Value("string")),
86
- "pos_tags": datasets.Sequence(datasets.Value("string")),
87
- }
88
- ),
89
- # If there's a common (input, target) tuple from the features,
90
- # specify them here. They'll be used if as_supervised=True in
91
- # builder.as_dataset.
92
- supervised_keys=None,
93
- homepage="https://alt.qcri.org/resources/da_resources/",
94
- citation=_CITATION,
95
- )
96
-
97
- def _split_generators(self, dl_manager):
98
- """Returns SplitGenerators."""
99
- # TODO: Downloads the data and defines the splits
100
- # dl_manager is a datasets.download.DownloadManager that can be used to
101
- # download and extract URLs
102
- urls_to_download = {dialect: _URL + f"seg_plus_pos_{dialect}.txt" for dialect in _DIALECTS}
103
- dl_dir = dl_manager.download_and_extract(urls_to_download)
104
- return [
105
- datasets.SplitGenerator(
106
- name=datasets.Split.TRAIN,
107
- # These kwargs will be passed to _generate_examples
108
- gen_kwargs={"filepath": dl_dir[self.config.dialect]},
109
- )
110
- ]
111
-
112
- def _generate_examples(self, filepath):
113
- """Yields examples in the raw (text) form."""
114
- with open(filepath, encoding="utf-8") as csv_file:
115
- reader = csv.DictReader(csv_file, delimiter="\t", quoting=csv.QUOTE_NONE)
116
- fold = -1
117
- subfold = ""
118
- words = []
119
- segments = []
120
- pos_tags = []
121
- curr_sent = -1
122
- for idx, row in enumerate(reader):
123
- # first example
124
- if fold == -1:
125
- fold = row["Fold"]
126
- subfold = row["SubFold"]
127
- curr_sent = int(row["SentID"])
128
- if int(row["SentID"]) != curr_sent:
129
- yield curr_sent, {
130
- "fold": fold,
131
- "subfold": subfold,
132
- "words": words,
133
- "segments": segments,
134
- "pos_tags": pos_tags,
135
- }
136
- fold = row["Fold"]
137
- subfold = row["SubFold"]
138
- words = [row["Word"]]
139
- segments = [row["Segmentation"]]
140
- pos_tags = [row["POS"]]
141
- curr_sent = int(row["SentID"])
142
- else:
143
- words.append(row["Word"])
144
- segments.append(row["Segmentation"])
145
- pos_tags.append(row["POS"])
146
- # last example
147
- yield curr_sent, {
148
- "fold": fold,
149
- "subfold": subfold,
150
- "words": words,
151
- "segments": segments,
152
- "pos_tags": pos_tags,
153
- }