foyez commited on
Commit
f340dc8
·
1 Parent(s): 66db2d0

Delete pake.py

Browse files
Files changed (1) hide show
  1. pake.py +0 -133
pake.py DELETED
@@ -1,133 +0,0 @@
1
- """Inspec benchmark dataset for keyphrase extraction an generation."""
2
-
3
-
4
- import csv
5
- import json
6
- import os
7
-
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
- @inproceedings{hulth2003improved,
15
- title={Improved automatic keyword extraction given more linguistic knowledge},
16
- author={Hulth, Anette},
17
- booktitle={Proceedings of the 2003 conference on Empirical methods in natural language processing},
18
- pages={216--223},
19
- year={2003}
20
- }
21
- """
22
-
23
- # You can copy an official description
24
- _DESCRIPTION = """\
25
- Inspec benchmark dataset for keyphrase extraction an generation.
26
- """
27
-
28
- # TODO: Add a link to an official homepage for the dataset here
29
- _HOMEPAGE = "https://aclanthology.org/W03-1028.pdf"
30
-
31
- # TODO: Add the licence for the dataset here if you can find it
32
- _LICENSE = "Apache 2.0 License"
33
-
34
- # TODO: Add link to the official dataset URLs here
35
- # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
36
- # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
37
- _URLS = {
38
- "test": "test.csv",
39
- "train": "train.csv",
40
- }
41
-
42
- # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
43
- class Inspec(datasets.GeneratorBasedBuilder):
44
- """TODO: Short description of my dataset."""
45
-
46
- VERSION = datasets.Version("1.1.0")
47
-
48
- # This is an example of a dataset with multiple configurations.
49
- # If you don't want/need to define several sub-sets in your dataset,
50
- # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
51
-
52
- # If you need to make complex sub-parts in the datasets with configurable options
53
- # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
54
- # BUILDER_CONFIG_CLASS = MyBuilderConfig
55
-
56
- # You will be able to load one or the other configurations in the following list with
57
- # data = datasets.load_dataset('my_dataset', 'first_domain')
58
- # data = datasets.load_dataset('my_dataset', 'second_domain')
59
- BUILDER_CONFIGS = [
60
- datasets.BuilderConfig(name="raw", version=VERSION, description="This part of my dataset covers the raw data."),
61
- ]
62
-
63
- DEFAULT_CONFIG_NAME = "raw" # It's not mandatory to have a default configuration. Just use one if it make sense.
64
-
65
- def _info(self):
66
- # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
67
- if self.config.name == "raw": # This is the name of the configuration selected in BUILDER_CONFIGS above
68
- features = datasets.Features(
69
- {
70
- "id": datasets.Value("uint64"),
71
- "title": datasets.Value("string"),
72
- "abstract": datasets.Value("string"),
73
- "keyphrases": datasets.features.Sequence(datasets.Value("string")),
74
- }
75
- )
76
- return datasets.DatasetInfo(
77
- # This is the description that will appear on the datasets page.
78
- description=_DESCRIPTION,
79
- # This defines the different columns of the dataset and their types
80
- features=features, # Here we define them above because they are different between the two configurations
81
- # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
82
- # specify them. They'll be used if as_supervised=True in builder.as_dataset.
83
- # supervised_keys=("sentence", "label"),
84
- # Homepage of the dataset for documentation
85
- homepage=_HOMEPAGE,
86
- # License for the dataset if available
87
- license=_LICENSE,
88
- # Citation for the dataset
89
- citation=_CITATION,
90
- )
91
-
92
- def _split_generators(self, dl_manager):
93
- # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
94
- # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
95
-
96
- # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
97
- # 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.
98
- # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
99
- urls = _URLS
100
- data_dir = dl_manager.download_and_extract(urls)
101
- return [
102
- datasets.SplitGenerator(
103
- name=datasets.Split.TRAIN,
104
- # These kwargs will be passed to _generate_examples
105
- gen_kwargs={
106
- "filepath": os.path.join(data_dir["train"]),
107
- "split": "train",
108
- },
109
- ),
110
- datasets.SplitGenerator(
111
- name=datasets.Split.TEST,
112
- # These kwargs will be passed to _generate_examples
113
- gen_kwargs={
114
- "filepath": os.path.join(data_dir["test"]),
115
- "split": "test"
116
- },
117
- ),
118
- ]
119
-
120
- # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
121
- def _generate_examples(self, filepath, split):
122
- # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
123
- # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
124
- with open(filepath, encoding="utf-8") as f:
125
- for key, row in enumerate(f):
126
- data = json.loads(row)
127
- # Yields examples as (key, example) tuples
128
- yield key, {
129
- "id": data["id"],
130
- "title": data["title"],
131
- "abstract": data["abstract"],
132
- "keyphrases": data["keyphrases"],
133
- }