orieg commited on
Commit
545036c
1 Parent(s): 4e20008

add dummy data and update default config and split ranges

Browse files
dataset_infos.json CHANGED
@@ -1 +1 @@
1
- {"mendeley": {"description": "\nElsevier OA CC-By is a corpus of 40k (40, 091) open access (OA) CC-BY articles\nfrom across Elsevier\u2019s journals and include the full text of the article, the metadata,\nthe bibliographic information for each reference, and author highlights.\n", "citation": "\n@article{Kershaw2020ElsevierOC,\n title = {Elsevier OA CC-By Corpus},\n author = {Daniel James Kershaw and R. Koeling},\n journal = {ArXiv},\n year = {2020},\n volume = {abs/2008.00774},\n doi = {https://doi.org/10.48550/arXiv.2008.00774},\n url = {https://elsevier.digitalcommonsdata.com/datasets/zm33cdndxs},\n keywords = {Science, Natural Language Processing, Machine Learning, Open Dataset},\n abstract = {We introduce the Elsevier OA CC-BY corpus. This is the first open\n corpus of Scientific Research papers which has a representative sample\n from across scientific disciplines. This corpus not only includes the\n full text of the article, but also the metadata of the documents, \n along with the bibliographic information for each reference.}\n}\n", "homepage": "https://elsevier.digitalcommonsdata.com/datasets/zm33cdndxs/3", "license": "CC-BY-4.0", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "abstract": {"dtype": "string", "id": null, "_type": "Value"}, "subjareas": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "keywords": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "asjc": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "body_text": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "author_highlights": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "elsevier_oa_cc_by", "config_name": "mendeley", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1080581428, "num_examples": 32072, "dataset_name": "elsevier_oa_cc_by"}, "test": {"name": "test", "num_bytes": 134576262, "num_examples": 4009, "dataset_name": "elsevier_oa_cc_by"}, "validation": {"name": "validation", "num_bytes": 134793940, "num_examples": 4008, "dataset_name": "elsevier_oa_cc_by"}}, "download_checksums": {"https://data.mendeley.com/public-files/datasets/zm33cdndxs/files/4e03ae48-04a7-44d4-b103-ce73e548679c/file_downloaded": {"num_bytes": 1008401964, "checksum": "885e5fedbc342a84ac3831396d8c057fcc9fe5abf318f13fb3303bdd8e2fac32"}}, "download_size": 1008401964, "post_processing_size": null, "dataset_size": 1349951630, "size_in_bytes": 2358353594}}
1
+ {"mendeley": {"description": "\nElsevier OA CC-By is a corpus of 40k (40, 091) open access (OA) CC-BY articles\nfrom across Elsevier\u2019s journals and include the full text of the article, the metadata,\nthe bibliographic information for each reference, and author highlights.\n", "citation": "\n@article{Kershaw2020ElsevierOC,\n title = {Elsevier OA CC-By Corpus},\n author = {Daniel James Kershaw and R. Koeling},\n journal = {ArXiv},\n year = {2020},\n volume = {abs/2008.00774},\n doi = {https://doi.org/10.48550/arXiv.2008.00774},\n url = {https://elsevier.digitalcommonsdata.com/datasets/zm33cdndxs},\n keywords = {Science, Natural Language Processing, Machine Learning, Open Dataset},\n abstract = {We introduce the Elsevier OA CC-BY corpus. This is the first open\n corpus of Scientific Research papers which has a representative sample\n from across scientific disciplines. This corpus not only includes the\n full text of the article, but also the metadata of the documents, \n along with the bibliographic information for each reference.}\n}\n", "homepage": "https://elsevier.digitalcommonsdata.com/datasets/zm33cdndxs/3", "license": "CC-BY-4.0", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "abstract": {"dtype": "string", "id": null, "_type": "Value"}, "subjareas": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "keywords": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "asjc": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "body_text": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "author_highlights": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "elsevier_oa_cc_by", "config_name": "mendeley", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1080581428, "num_examples": 32072, "dataset_name": "elsevier_oa_cc_by"}, "test": {"name": "test", "num_bytes": 134576262, "num_examples": 4009, "dataset_name": "elsevier_oa_cc_by"}, "validation": {"name": "validation", "num_bytes": 134793940, "num_examples": 4008, "dataset_name": "elsevier_oa_cc_by"}}, "download_checksums": {"https://data.mendeley.com/public-files/datasets/zm33cdndxs/files/4e03ae48-04a7-44d4-b103-ce73e548679c/file_downloaded": {"num_bytes": 1008401964, "checksum": "885e5fedbc342a84ac3831396d8c057fcc9fe5abf318f13fb3303bdd8e2fac32"}}, "download_size": 1008401964, "post_processing_size": null, "dataset_size": 1349951630, "size_in_bytes": 2358353594}, "all": {"description": "\nElsevier OA CC-By is a corpus of 40k (40, 091) open access (OA) CC-BY articles\nfrom across Elsevier\u2019s journals and include the full text of the article, the metadata,\nthe bibliographic information for each reference, and author highlights.\n", "citation": "\n@article{Kershaw2020ElsevierOC,\n title = {Elsevier OA CC-By Corpus},\n author = {Daniel James Kershaw and R. Koeling},\n journal = {ArXiv},\n year = {2020},\n volume = {abs/2008.00774},\n doi = {https://doi.org/10.48550/arXiv.2008.00774},\n url = {https://elsevier.digitalcommonsdata.com/datasets/zm33cdndxs},\n keywords = {Science, Natural Language Processing, Machine Learning, Open Dataset},\n abstract = {We introduce the Elsevier OA CC-BY corpus. This is the first open\n corpus of Scientific Research papers which has a representative sample\n from across scientific disciplines. This corpus not only includes the\n full text of the article, but also the metadata of the documents, \n along with the bibliographic information for each reference.}\n}\n", "homepage": "https://elsevier.digitalcommonsdata.com/datasets/zm33cdndxs/3", "license": "CC-BY-4.0", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "abstract": {"dtype": "string", "id": null, "_type": "Value"}, "subjareas": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "keywords": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "asjc": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "body_text": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "author_highlights": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "elsevier_oa_cc_by", "config_name": "all", "version": {"version_str": "1.0.1", "description": null, "major": 1, "minor": 0, "patch": 1}, "splits": {"train": {"name": "train", "num_bytes": 1080581428, "num_examples": 32072, "dataset_name": "elsevier_oa_cc_by"}, "test": {"name": "test", "num_bytes": 134532311, "num_examples": 4008, "dataset_name": "elsevier_oa_cc_by"}, "validation": {"name": "validation", "num_bytes": 134823237, "num_examples": 4009, "dataset_name": "elsevier_oa_cc_by"}}, "download_checksums": {"https://data.mendeley.com/public-files/datasets/zm33cdndxs/files/4e03ae48-04a7-44d4-b103-ce73e548679c/file_downloaded": {"num_bytes": 1008401964, "checksum": "885e5fedbc342a84ac3831396d8c057fcc9fe5abf318f13fb3303bdd8e2fac32"}}, "download_size": 1008401964, "post_processing_size": null, "dataset_size": 1349936976, "size_in_bytes": 2358338940}}
dummy/all/1.0.1/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bdabb82a40ce2702f719b6d3bf54b761483ee76f942fbc88754ab37a7ef3bb35
3
+ size 13967789
elsevier-oa-cc-by.py CHANGED
@@ -54,21 +54,19 @@ _HOMEPAGE = "https://elsevier.digitalcommonsdata.com/datasets/zm33cdndxs/3"
54
 
55
  _LICENSE = "CC-BY-4.0"
56
 
57
- _URLS = {
58
- "mendeley": "https://data.mendeley.com/public-files/datasets/zm33cdndxs/files/4e03ae48-04a7-44d4-b103-ce73e548679c/file_downloaded"
59
- }
60
 
61
 
62
  class ElsevierOaCcBy(datasets.GeneratorBasedBuilder):
63
  """Elsevier OA CC-By Dataset."""
64
 
65
- VERSION = datasets.Version("1.0.0")
66
 
67
  BUILDER_CONFIGS = [
68
- datasets.BuilderConfig(name="mendeley", version=VERSION, description="Official Mendeley dataset"),
69
  ]
70
 
71
- DEFAULT_CONFIG_NAME = "mendeley"
72
 
73
  def _info(self):
74
  features = datasets.Features(
@@ -105,11 +103,16 @@ class ElsevierOaCcBy(datasets.GeneratorBasedBuilder):
105
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
106
  # 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.
107
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
108
- urls = _URLS[self.config.name]
109
- data_dir = dl_manager.download_and_extract(urls)
110
 
111
  corpus_path = os.path.join(data_dir, "json")
112
 
 
 
 
 
 
 
113
  return [
114
  datasets.SplitGenerator(
115
  name=datasets.Split.TRAIN,
@@ -117,7 +120,7 @@ class ElsevierOaCcBy(datasets.GeneratorBasedBuilder):
117
  gen_kwargs={
118
  "filepath": corpus_path,
119
  "split": "train",
120
- "split_range": [0, 32072]
121
  },
122
  ),
123
  datasets.SplitGenerator(
@@ -126,7 +129,7 @@ class ElsevierOaCcBy(datasets.GeneratorBasedBuilder):
126
  gen_kwargs={
127
  "filepath": corpus_path,
128
  "split": "test",
129
- "split_range": [32073, 36082]
130
  },
131
  ),
132
  datasets.SplitGenerator(
@@ -135,14 +138,13 @@ class ElsevierOaCcBy(datasets.GeneratorBasedBuilder):
135
  gen_kwargs={
136
  "filepath": corpus_path,
137
  "split": "validation",
138
- "split_range": [36083, 40091]
139
  },
140
  ),
141
  ]
142
 
143
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
144
  def _generate_examples(self, filepath, split, split_range):
145
- # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
146
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
147
  json_files = glob.glob(f"{filepath}/*.json")
148
  for doc in json_files[split_range[0]:split_range[1]]:
54
 
55
  _LICENSE = "CC-BY-4.0"
56
 
57
+ _URL = "https://data.mendeley.com/public-files/datasets/zm33cdndxs/files/4e03ae48-04a7-44d4-b103-ce73e548679c/file_downloaded"
 
 
58
 
59
 
60
  class ElsevierOaCcBy(datasets.GeneratorBasedBuilder):
61
  """Elsevier OA CC-By Dataset."""
62
 
63
+ VERSION = datasets.Version("1.0.1")
64
 
65
  BUILDER_CONFIGS = [
66
+ datasets.BuilderConfig(name="all", version=VERSION, description="Official Mendeley dataset for Elsevier OA CC-By Corpus"),
67
  ]
68
 
69
+ DEFAULT_CONFIG_NAME = "all"
70
 
71
  def _info(self):
72
  features = datasets.Features(
103
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
104
  # 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.
105
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
106
+ data_dir = dl_manager.download_and_extract(_URL)
 
107
 
108
  corpus_path = os.path.join(data_dir, "json")
109
 
110
+ doc_count = len(glob.glob(f"{corpus_path}/*.json"))
111
+
112
+ train_split = [0, doc_count*80//100]
113
+ test_split = [doc_count*80//100+1, doc_count*90//100]
114
+ validation_split = [doc_count*90//100+1, doc_count]
115
+
116
  return [
117
  datasets.SplitGenerator(
118
  name=datasets.Split.TRAIN,
120
  gen_kwargs={
121
  "filepath": corpus_path,
122
  "split": "train",
123
+ "split_range": train_split
124
  },
125
  ),
126
  datasets.SplitGenerator(
129
  gen_kwargs={
130
  "filepath": corpus_path,
131
  "split": "test",
132
+ "split_range": test_split
133
  },
134
  ),
135
  datasets.SplitGenerator(
138
  gen_kwargs={
139
  "filepath": corpus_path,
140
  "split": "validation",
141
+ "split_range": validation_split
142
  },
143
  ),
144
  ]
145
 
146
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
147
  def _generate_examples(self, filepath, split, split_range):
 
148
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
149
  json_files = glob.glob(f"{filepath}/*.json")
150
  for doc in json_files[split_range[0]:split_range[1]]: