Create masader.py
Browse files- masader.py +103 -0
masader.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
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 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
"""Arabic Poetry Metric dataset."""
|
18 |
+
|
19 |
+
|
20 |
+
import os
|
21 |
+
import datasets
|
22 |
+
import pandas as pd
|
23 |
+
|
24 |
+
_DESCRIPTION = """\
|
25 |
+
Masader is the largest public catalogue for Arabic NLP datasets, which consists of more than 200 datasets annotated with 25 attributes.
|
26 |
+
"""
|
27 |
+
|
28 |
+
_CITATION = """\
|
29 |
+
@misc{alyafeai2021masader,
|
30 |
+
title={Masader: Metadata Sourcing for Arabic Text and Speech Data Resources},
|
31 |
+
author={Zaid Alyafeai and Maraim Masoud and Mustafa Ghaleb and Maged S. Al-shaibani},
|
32 |
+
year={2021},
|
33 |
+
eprint={2110.06744},
|
34 |
+
archivePrefix={arXiv},
|
35 |
+
primaryClass={cs.CL}
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
columns = ['No.', 'Name', 'Subsets', 'Link', 'License', 'Year', 'Language',
|
40 |
+
'Dialect', 'Domain', 'Form', 'Collection Style', 'Description',
|
41 |
+
'Volume', 'Unit', 'Ethical Risks', 'Provider', 'Derived From',
|
42 |
+
'Paper Title', 'Paper Link', 'Script', 'Tokenized', 'Host', 'Access',
|
43 |
+
'Cost', 'Test Split']
|
44 |
+
|
45 |
+
class MasaderConfig(datasets.BuilderConfig):
|
46 |
+
"""BuilderConfig for Masader."""
|
47 |
+
|
48 |
+
def __init__(self, **kwargs):
|
49 |
+
"""BuilderConfig for MetRec.
|
50 |
+
|
51 |
+
Args:
|
52 |
+
**kwargs: keyword arguments forwarded to super.
|
53 |
+
"""
|
54 |
+
super(MasaderConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
55 |
+
|
56 |
+
|
57 |
+
class Masader(datasets.GeneratorBasedBuilder):
|
58 |
+
"""Masaderdataset."""
|
59 |
+
|
60 |
+
BUILDER_CONFIGS = [
|
61 |
+
MetRecConfig(
|
62 |
+
name="plain_text",
|
63 |
+
description="Plain text",
|
64 |
+
)
|
65 |
+
]
|
66 |
+
|
67 |
+
def _info(self):
|
68 |
+
return datasets.DatasetInfo(
|
69 |
+
description=_DESCRIPTION,
|
70 |
+
features=datasets.Features(
|
71 |
+
{
|
72 |
+
columns[i]: datasets.Value("string") for i in range(len(columns)),
|
73 |
+
}
|
74 |
+
),
|
75 |
+
supervised_keys=None,
|
76 |
+
homepage="https://github.com/arbml/Masader",
|
77 |
+
citation=_CITATION,)
|
78 |
+
|
79 |
+
def _split_generators(self, dl_manager):
|
80 |
+
sheet_id = "1YO-Vl4DO-lnp8sQpFlcX1cDtzxFoVkCmU1PVw_ZHJDg"
|
81 |
+
sheet_name = "filtered_clean"
|
82 |
+
url = f"https://docs.google.com/spreadsheets/d/{sheet_id}/gviz/tq?tqx=out:csv&sheet={sheet_name}"
|
83 |
+
|
84 |
+
return [
|
85 |
+
datasets.SplitGenerator(
|
86 |
+
name=datasets.Split.TRAIN, gen_kwargs={"directory":url }
|
87 |
+
),
|
88 |
+
]
|
89 |
+
|
90 |
+
def _generate_examples(self, url):
|
91 |
+
"""Generate examples."""
|
92 |
+
# For labeled examples, extract the label from the path.
|
93 |
+
|
94 |
+
|
95 |
+
df = pd.read_csv(url, usecols=range(34))
|
96 |
+
subsets = []
|
97 |
+
for i, entry in enumerate(df.values):
|
98 |
+
if str(df.values[i][0]) == "nan":
|
99 |
+
continue
|
100 |
+
|
101 |
+
entry_list = entry.tolist()
|
102 |
+
masader_entry = {col:entry_list[i] for i,col in enumerate(columns)}
|
103 |
+
yield i, masader_entry
|