albertvillanova HF staff commited on
Commit
2a555d3
1 Parent(s): 304e10f

Delete loading script

Browse files
Files changed (1) hide show
  1. aeslc.py +0 -107
aeslc.py DELETED
@@ -1,107 +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
- """Annotated Enron Subject Line Corpus Dataset."""
18
-
19
-
20
- import glob
21
- import os
22
-
23
- import datasets
24
-
25
-
26
- _CITATION = """
27
- @misc{zhang2019email,
28
- title={This Email Could Save Your Life: Introducing the Task of Email Subject Line Generation},
29
- author={Rui Zhang and Joel Tetreault},
30
- year={2019},
31
- eprint={1906.03497},
32
- archivePrefix={arXiv},
33
- primaryClass={cs.CL}
34
- }
35
- """
36
-
37
- _DESCRIPTION = """
38
- A collection of email messages of employees in the Enron Corporation.
39
-
40
- There are two features:
41
- - email_body: email body text.
42
- - subject_line: email subject text.
43
- """
44
-
45
- # From: https://github.com/ryanzhumich/AESLC/archive/master.zip
46
- _URL = "data.zip"
47
-
48
- _DOCUMENT = "email_body"
49
- _SUMMARY = "subject_line"
50
-
51
-
52
- class Aeslc(datasets.GeneratorBasedBuilder):
53
- """Annotated Enron Subject Line Corpus Dataset."""
54
-
55
- VERSION = datasets.Version("1.0.0")
56
-
57
- def _info(self):
58
- return datasets.DatasetInfo(
59
- description=_DESCRIPTION,
60
- features=datasets.Features({_DOCUMENT: datasets.Value("string"), _SUMMARY: datasets.Value("string")}),
61
- supervised_keys=(_DOCUMENT, _SUMMARY),
62
- homepage="https://github.com/ryanzhumich/AESLC",
63
- citation=_CITATION,
64
- )
65
-
66
- def _split_generators(self, dl_manager):
67
- """Returns SplitGenerators."""
68
- dl_path = dl_manager.download_and_extract(_URL)
69
- input_path = os.path.join(dl_path, "AESLC-master", "enron_subject_line")
70
- return [
71
- datasets.SplitGenerator(
72
- name=datasets.Split.TRAIN,
73
- gen_kwargs={"pattern": os.path.join(input_path, "train", "*.subject")},
74
- ),
75
- datasets.SplitGenerator(
76
- name=datasets.Split.VALIDATION,
77
- gen_kwargs={"pattern": os.path.join(input_path, "dev", "*.subject")},
78
- ),
79
- datasets.SplitGenerator(
80
- name=datasets.Split.TEST,
81
- gen_kwargs={"pattern": os.path.join(input_path, "test", "*.subject")},
82
- ),
83
- ]
84
-
85
- def _generate_examples(self, pattern=None):
86
- """Yields examples."""
87
- for filename in sorted(glob.glob(pattern)):
88
- email_body, subject_line = _parse_email_file(filename)
89
- key = os.path.basename(filename).rstrip(".subject")
90
- yield key, {_DOCUMENT: email_body, _SUMMARY: subject_line}
91
-
92
-
93
- def _parse_email_file(filename):
94
- """Parse email file text for email body and subject."""
95
- with open(filename, encoding="utf-8") as f:
96
- email_body = ""
97
- for line in f:
98
- if line == "\n":
99
- break
100
- email_body += line
101
- line = next(f)
102
- subject = ""
103
- for line in f:
104
- if line == "\n":
105
- break
106
- subject += line
107
- return email_body, subject