Datasets:
dainis-boumber
commited on
Commit
•
b9b3f32
1
Parent(s):
d504457
Delete sms/gdds.py
Browse files- sms/gdds.py +0 -135
sms/gdds.py
DELETED
@@ -1,135 +0,0 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
import csv
|
5 |
-
import json
|
6 |
-
import os
|
7 |
-
import sys
|
8 |
-
import datasets
|
9 |
-
|
10 |
-
|
11 |
-
# TODO: Add BibTeX citation
|
12 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
13 |
-
_CITATION = """\
|
14 |
-
TODO: Add citation here
|
15 |
-
"""
|
16 |
-
|
17 |
-
# TODO: Add description of the dataset here
|
18 |
-
# You can copy an official description
|
19 |
-
_DESCRIPTION = """\
|
20 |
-
This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
|
21 |
-
"""
|
22 |
-
|
23 |
-
# TODO: Add a link to an official homepage for the dataset here
|
24 |
-
_HOMEPAGE = ""
|
25 |
-
|
26 |
-
# TODO: Add the licence for the dataset here if you can find it
|
27 |
-
_LICENSE = ""
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
32 |
-
class GDDS(datasets.GeneratorBasedBuilder):
|
33 |
-
"""TODO: Short description of my dataset."""
|
34 |
-
|
35 |
-
VERSION = datasets.Version("2.1.0")
|
36 |
-
|
37 |
-
# This is an example of a dataset with multiple configurations.
|
38 |
-
# If you don't want/need to define several sub-sets in your dataset,
|
39 |
-
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
40 |
-
|
41 |
-
# If you need to make complex sub-parts in the datasets with configurable options
|
42 |
-
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
43 |
-
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
44 |
-
|
45 |
-
# You will be able to load one or the other configurations in the following list with
|
46 |
-
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
47 |
-
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
48 |
-
BUILDER_CONFIGS = [
|
49 |
-
datasets.BuilderConfig(name="fake_news", version=VERSION, description="This part of my dataset covers a first domain"),
|
50 |
-
datasets.BuilderConfig(name="job_scams", version=VERSION, description="This part of my dataset covers a second domain"),
|
51 |
-
datasets.BuilderConfig(name="phishing", version=VERSION, description="This part of my dataset covers a second domain"),
|
52 |
-
datasets.BuilderConfig(name="political_statements", version=VERSION, description="This part of my dataset covers a first domain"),
|
53 |
-
datasets.BuilderConfig(name="product_reviews", version=VERSION, description="This part of my dataset covers a second domain"),
|
54 |
-
datasets.BuilderConfig(name="sms", version=VERSION, description="This part of my dataset covers a second domain"),
|
55 |
-
datasets.BuilderConfig(name="twitter_rumours", version=VERSION, description="This part of my dataset covers a first domain"),
|
56 |
-
]
|
57 |
-
|
58 |
-
def _info(self):
|
59 |
-
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
60 |
-
features = datasets.Features(
|
61 |
-
{
|
62 |
-
"text": datasets.Value("string"),
|
63 |
-
"label": datasets.ClassLabel(num_classes=2)
|
64 |
-
# These are the features of your dataset like images, labels ...
|
65 |
-
}
|
66 |
-
)
|
67 |
-
return datasets.DatasetInfo(
|
68 |
-
# This is the description that will appear on the datasets page.
|
69 |
-
description=_DESCRIPTION,
|
70 |
-
# This defines the different columns of the dataset and their types
|
71 |
-
features=features, # Here we define them above because they are different between the two configurations
|
72 |
-
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
73 |
-
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
74 |
-
# supervised_keys=("sentence", "label"),
|
75 |
-
# Homepage of the dataset for documentation
|
76 |
-
homepage=_HOMEPAGE,
|
77 |
-
# License for the dataset if available
|
78 |
-
license=_LICENSE,
|
79 |
-
# Citation for the dataset
|
80 |
-
citation=_CITATION,
|
81 |
-
)
|
82 |
-
|
83 |
-
def _split_generators(self, dl_manager):
|
84 |
-
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
85 |
-
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
86 |
-
|
87 |
-
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
88 |
-
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
89 |
-
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
90 |
-
urls = {
|
91 |
-
"train": self.config.name+"/train.jsonl",
|
92 |
-
"test": self.config.name+"/test.jsonl",
|
93 |
-
"validate": self.config.name+"/validate.jsonl",
|
94 |
-
}
|
95 |
-
data_dir = dl_manager.download_and_extract(urls)
|
96 |
-
|
97 |
-
return [
|
98 |
-
datasets.SplitGenerator(
|
99 |
-
name=datasets.Split.TRAIN,
|
100 |
-
# These kwargs will be passed to _generate_examples
|
101 |
-
gen_kwargs={
|
102 |
-
"filepath": os.path.join(data_dir, "train.jsonl"),
|
103 |
-
"split": "train",
|
104 |
-
},
|
105 |
-
),
|
106 |
-
datasets.SplitGenerator(
|
107 |
-
name=datasets.Split.VALIDATION,
|
108 |
-
# These kwargs will be passed to _generate_examples
|
109 |
-
gen_kwargs={
|
110 |
-
"filepath": os.path.join(data_dir, "validate.jsonl"),
|
111 |
-
"split": "dev",
|
112 |
-
},
|
113 |
-
),
|
114 |
-
datasets.SplitGenerator(
|
115 |
-
name=datasets.Split.TEST,
|
116 |
-
# These kwargs will be passed to _generate_examples
|
117 |
-
gen_kwargs={
|
118 |
-
"filepath": os.path.join(data_dir, "test.jsonl"),
|
119 |
-
"split": "test"
|
120 |
-
},
|
121 |
-
),
|
122 |
-
]
|
123 |
-
|
124 |
-
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
125 |
-
def _generate_examples(self, filepath, split):
|
126 |
-
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
127 |
-
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
128 |
-
with open(filepath, encoding="utf-8") as f:
|
129 |
-
for key, row in enumerate(f):
|
130 |
-
data = json.loads(row)
|
131 |
-
yield key, {
|
132 |
-
"text": data["text"],
|
133 |
-
"label": "" if split == "test" else data["label"],
|
134 |
-
}
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|