albertvillanova HF staff commited on
Commit
dafc90c
1 Parent(s): 6b67ee6

Delete loading script

Browse files
Files changed (1) hide show
  1. sms_spam.py +0 -92
sms_spam.py DELETED
@@ -1,92 +0,0 @@
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
- """SMS Spam Collection Data Set"""
18
-
19
-
20
- import os
21
-
22
- import datasets
23
- from datasets.tasks import TextClassification
24
-
25
-
26
- _CITATION = """\
27
- @inproceedings{Almeida2011SpamFiltering,
28
- title={Contributions to the Study of SMS Spam Filtering: New Collection and Results},
29
- author={Tiago A. Almeida and Jose Maria Gomez Hidalgo and Akebo Yamakami},
30
- year={2011},
31
- booktitle = "Proceedings of the 2011 ACM Symposium on Document Engineering (DOCENG'11)",
32
- }
33
- """
34
-
35
- _DESCRIPTION = """\
36
- The SMS Spam Collection v.1 is a public set of SMS labeled messages that have been collected for mobile phone spam research.
37
- It has one collection composed by 5,574 English, real and non-enconded messages, tagged according being legitimate (ham) or spam.
38
- """
39
-
40
- _DATA_URL = "http://archive.ics.uci.edu/ml/machine-learning-databases/00228/smsspamcollection.zip"
41
-
42
-
43
- class SmsSpam(datasets.GeneratorBasedBuilder):
44
- """SMS Spam Collection Data Set"""
45
-
46
- BUILDER_CONFIGS = [
47
- datasets.BuilderConfig(
48
- name="plain_text",
49
- version=datasets.Version("1.0.0", ""),
50
- description="Plain text import of SMS Spam Collection Data Set",
51
- )
52
- ]
53
-
54
- def _info(self):
55
- return datasets.DatasetInfo(
56
- description=_DESCRIPTION,
57
- features=datasets.Features(
58
- {
59
- "sms": datasets.Value("string"),
60
- "label": datasets.features.ClassLabel(names=["ham", "spam"]),
61
- }
62
- ),
63
- supervised_keys=("sms", "label"),
64
- homepage="http://archive.ics.uci.edu/ml/datasets/SMS+Spam+Collection",
65
- citation=_CITATION,
66
- task_templates=[TextClassification(text_column="sms", label_column="label")],
67
- )
68
-
69
- def _split_generators(self, dl_manager):
70
- dl_dir = dl_manager.download_and_extract(_DATA_URL)
71
- return [
72
- datasets.SplitGenerator(
73
- name=datasets.Split.TRAIN, gen_kwargs={"filepath": os.path.join(dl_dir, "SMSSpamCollection")}
74
- ),
75
- ]
76
-
77
- def _generate_examples(self, filepath):
78
- """This function returns the examples in the raw (text) form."""
79
-
80
- with open(filepath, encoding="utf-8") as sms_file:
81
- for idx, line in enumerate(sms_file):
82
- fields = line.split("\t")
83
-
84
- if fields[0] == "ham":
85
- label = 0
86
- else:
87
- label = 1
88
-
89
- yield idx, {
90
- "sms": fields[1],
91
- "label": label,
92
- }