Datasets:
Convert to Parquet format and remove loading script
#4
by elie-mada - opened
- README.md +26 -6
- data/test-00000-of-00001.parquet +3 -0
- data/train-00000-of-00001.parquet +3 -0
- data/validation-00000-of-00001.parquet +3 -0
- ptb_text_only.py +0 -146
README.md
CHANGED
|
@@ -22,11 +22,20 @@ task_ids:
|
|
| 22 |
- masked-language-modeling
|
| 23 |
paperswithcode_id: null
|
| 24 |
pretty_name: Penn Treebank
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
dataset_info:
|
| 26 |
features:
|
| 27 |
- name: sentence
|
| 28 |
dtype: string
|
| 29 |
-
config_name:
|
| 30 |
splits:
|
| 31 |
- name: train
|
| 32 |
num_bytes: 5143706
|
|
@@ -80,7 +89,7 @@ dataset_info:
|
|
| 80 |
|
| 81 |
### Dataset Summary
|
| 82 |
|
| 83 |
-
This is the Penn Treebank Project: Release 2 CDROM, featuring a million words of 1989 Wall Street Journal material.
|
| 84 |
The rare words in this version are already replaced with <unk> token. The numbers are replaced with <N> token.
|
| 85 |
|
| 86 |
### Supported Tasks and Leaderboards
|
|
@@ -95,15 +104,23 @@ The text in the dataset is in American English
|
|
| 95 |
|
| 96 |
### Data Instances
|
| 97 |
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
### Data Fields
|
| 101 |
|
| 102 |
-
|
| 103 |
|
| 104 |
### Data Splits
|
| 105 |
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
## Dataset Creation
|
| 109 |
|
|
@@ -161,6 +178,7 @@ Dataset provided for research purposes only. Please check dataset license for ad
|
|
| 161 |
|
| 162 |
### Citation Information
|
| 163 |
|
|
|
|
| 164 |
@article{marcus-etal-1993-building,
|
| 165 |
title = "Building a Large Annotated Corpus of {E}nglish: The {P}enn {T}reebank",
|
| 166 |
author = "Marcus, Mitchell P. and
|
|
@@ -173,6 +191,8 @@ Dataset provided for research purposes only. Please check dataset license for ad
|
|
| 173 |
url = "https://www.aclweb.org/anthology/J93-2004",
|
| 174 |
pages = "313--330",
|
| 175 |
}
|
|
|
|
|
|
|
| 176 |
### Contributions
|
| 177 |
|
| 178 |
-
Thanks to [@harshalmittal4](https://github.com/harshalmittal4) for adding this dataset.
|
|
|
|
| 22 |
- masked-language-modeling
|
| 23 |
paperswithcode_id: null
|
| 24 |
pretty_name: Penn Treebank
|
| 25 |
+
configs:
|
| 26 |
+
- config_name: default
|
| 27 |
+
data_files:
|
| 28 |
+
- split: train
|
| 29 |
+
path: data/train-*
|
| 30 |
+
- split: test
|
| 31 |
+
path: data/test-*
|
| 32 |
+
- split: validation
|
| 33 |
+
path: data/validation-*
|
| 34 |
dataset_info:
|
| 35 |
features:
|
| 36 |
- name: sentence
|
| 37 |
dtype: string
|
| 38 |
+
config_name: default
|
| 39 |
splits:
|
| 40 |
- name: train
|
| 41 |
num_bytes: 5143706
|
|
|
|
| 89 |
|
| 90 |
### Dataset Summary
|
| 91 |
|
| 92 |
+
This is the Penn Treebank Project: Release 2 CDROM, featuring a million words of 1989 Wall Street Journal material.
|
| 93 |
The rare words in this version are already replaced with <unk> token. The numbers are replaced with <N> token.
|
| 94 |
|
| 95 |
### Supported Tasks and Leaderboards
|
|
|
|
| 104 |
|
| 105 |
### Data Instances
|
| 106 |
|
| 107 |
+
An example instance:
|
| 108 |
+
|
| 109 |
+
```json
|
| 110 |
+
{"sentence": "pierre <unk> N years old will join the board as a nonexecutive director nov. N"}
|
| 111 |
+
```
|
| 112 |
|
| 113 |
### Data Fields
|
| 114 |
|
| 115 |
+
- `sentence` (string): A sentence from the Wall Street Journal corpus with rare words replaced by `<unk>` and numbers by `<N>`.
|
| 116 |
|
| 117 |
### Data Splits
|
| 118 |
|
| 119 |
+
| Split | Examples |
|
| 120 |
+
|------------|----------|
|
| 121 |
+
| train | 42,068 |
|
| 122 |
+
| test | 3,761 |
|
| 123 |
+
| validation | 3,370 |
|
| 124 |
|
| 125 |
## Dataset Creation
|
| 126 |
|
|
|
|
| 178 |
|
| 179 |
### Citation Information
|
| 180 |
|
| 181 |
+
```bibtex
|
| 182 |
@article{marcus-etal-1993-building,
|
| 183 |
title = "Building a Large Annotated Corpus of {E}nglish: The {P}enn {T}reebank",
|
| 184 |
author = "Marcus, Mitchell P. and
|
|
|
|
| 191 |
url = "https://www.aclweb.org/anthology/J93-2004",
|
| 192 |
pages = "313--330",
|
| 193 |
}
|
| 194 |
+
```
|
| 195 |
+
|
| 196 |
### Contributions
|
| 197 |
|
| 198 |
+
Thanks to [@harshalmittal4](https://github.com/harshalmittal4) for adding this dataset.
|
data/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5078fcc161548ad940c63610099ebfc9af25eca7bf7ec274900d0aa153484cc1
|
| 3 |
+
size 257503
|
data/train-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a86b8f1cdd524640b97b71da4a1ebdae60aaeb61132dc4c457db5f868d8e5db6
|
| 3 |
+
size 2915174
|
data/validation-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4373b0c0cafc169366b8f76e96a9c9917b9b1cd003fecdc82326c7da14c88b8f
|
| 3 |
+
size 232009
|
ptb_text_only.py
DELETED
|
@@ -1,146 +0,0 @@
|
|
| 1 |
-
# coding=utf-8
|
| 2 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 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 |
-
Load the Penn Treebank dataset.
|
| 17 |
-
|
| 18 |
-
This is the Penn Treebank Project: Release 2 CDROM, featuring a million words of 1989 Wall
|
| 19 |
-
Street Journal material.
|
| 20 |
-
"""
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
import datasets
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# TODO: Add BibTeX citation
|
| 27 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
| 28 |
-
_CITATION = """\
|
| 29 |
-
@article{marcus-etal-1993-building,
|
| 30 |
-
title = "Building a Large Annotated Corpus of {E}nglish: The {P}enn {T}reebank",
|
| 31 |
-
author = "Marcus, Mitchell P. and
|
| 32 |
-
Santorini, Beatrice and
|
| 33 |
-
Marcinkiewicz, Mary Ann",
|
| 34 |
-
journal = "Computational Linguistics",
|
| 35 |
-
volume = "19",
|
| 36 |
-
number = "2",
|
| 37 |
-
year = "1993",
|
| 38 |
-
url = "https://www.aclweb.org/anthology/J93-2004",
|
| 39 |
-
pages = "313--330",
|
| 40 |
-
}
|
| 41 |
-
"""
|
| 42 |
-
|
| 43 |
-
# TODO: Add description of the dataset here
|
| 44 |
-
# You can copy an official description
|
| 45 |
-
_DESCRIPTION = """\
|
| 46 |
-
This is the Penn Treebank Project: Release 2 CDROM, featuring a million words of 1989 Wall Street Journal material. This corpus has been annotated for part-of-speech (POS) information. In addition, over half of it has been annotated for skeletal syntactic structure.
|
| 47 |
-
"""
|
| 48 |
-
|
| 49 |
-
# TODO: Add a link to an official homepage for the dataset here
|
| 50 |
-
_HOMEPAGE = "https://catalog.ldc.upenn.edu/LDC99T42"
|
| 51 |
-
|
| 52 |
-
# TODO: Add the licence for the dataset here if you can find it
|
| 53 |
-
_LICENSE = "LDC User Agreement for Non-Members"
|
| 54 |
-
|
| 55 |
-
# TODO: Add link to the official dataset URLs here
|
| 56 |
-
# The HuggingFace dataset library don't host the datasets but only point to the original files
|
| 57 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
| 58 |
-
_URL = "https://raw.githubusercontent.com/wojzaremba/lstm/master/data/"
|
| 59 |
-
_TRAINING_FILE = "ptb.train.txt"
|
| 60 |
-
_DEV_FILE = "ptb.valid.txt"
|
| 61 |
-
_TEST_FILE = "ptb.test.txt"
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
class PtbTextOnlyConfig(datasets.BuilderConfig):
|
| 65 |
-
"""BuilderConfig for PtbTextOnly"""
|
| 66 |
-
|
| 67 |
-
def __init__(self, **kwargs):
|
| 68 |
-
"""BuilderConfig PtbTextOnly.
|
| 69 |
-
Args:
|
| 70 |
-
**kwargs: keyword arguments forwarded to super.
|
| 71 |
-
"""
|
| 72 |
-
super(PtbTextOnlyConfig, self).__init__(**kwargs)
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
class PtbTextOnly(datasets.GeneratorBasedBuilder):
|
| 76 |
-
"""Load the Penn Treebank dataset."""
|
| 77 |
-
|
| 78 |
-
VERSION = datasets.Version("1.1.0")
|
| 79 |
-
|
| 80 |
-
# This is an example of a dataset with multiple configurations.
|
| 81 |
-
# If you don't want/need to define several sub-sets in your dataset,
|
| 82 |
-
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 83 |
-
|
| 84 |
-
# If you need to make complex sub-parts in the datasets with configurable options
|
| 85 |
-
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 86 |
-
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
| 87 |
-
|
| 88 |
-
# You will be able to load one or the other configurations in the following list with
|
| 89 |
-
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 90 |
-
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 91 |
-
BUILDER_CONFIGS = [
|
| 92 |
-
PtbTextOnlyConfig(
|
| 93 |
-
name="penn_treebank",
|
| 94 |
-
version=VERSION,
|
| 95 |
-
description="Load the Penn Treebank dataset",
|
| 96 |
-
),
|
| 97 |
-
]
|
| 98 |
-
|
| 99 |
-
def _info(self):
|
| 100 |
-
features = datasets.Features({"sentence": datasets.Value("string")})
|
| 101 |
-
return datasets.DatasetInfo(
|
| 102 |
-
# This is the description that will appear on the datasets page.
|
| 103 |
-
description=_DESCRIPTION,
|
| 104 |
-
# This defines the different columns of the dataset and their types
|
| 105 |
-
features=features, # Here we define them above because they are different between the two configurations
|
| 106 |
-
# If there's a common (input, target) tuple from the features,
|
| 107 |
-
# specify them here. They'll be used if as_supervised=True in
|
| 108 |
-
# builder.as_dataset.
|
| 109 |
-
supervised_keys=None,
|
| 110 |
-
# Homepage of the dataset for documentation
|
| 111 |
-
homepage=_HOMEPAGE,
|
| 112 |
-
# License for the dataset if available
|
| 113 |
-
license=_LICENSE,
|
| 114 |
-
# Citation for the dataset
|
| 115 |
-
citation=_CITATION,
|
| 116 |
-
)
|
| 117 |
-
|
| 118 |
-
def _split_generators(self, dl_manager):
|
| 119 |
-
"""Returns SplitGenerators."""
|
| 120 |
-
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
| 121 |
-
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 122 |
-
|
| 123 |
-
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
| 124 |
-
# 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.
|
| 125 |
-
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 126 |
-
my_urls = {
|
| 127 |
-
"train": f"{_URL}{_TRAINING_FILE}",
|
| 128 |
-
"dev": f"{_URL}{_DEV_FILE}",
|
| 129 |
-
"test": f"{_URL}{_TEST_FILE}",
|
| 130 |
-
}
|
| 131 |
-
data_dir = dl_manager.download_and_extract(my_urls)
|
| 132 |
-
return [
|
| 133 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_dir["train"]}),
|
| 134 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_dir["test"]}),
|
| 135 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": data_dir["dev"]}),
|
| 136 |
-
]
|
| 137 |
-
|
| 138 |
-
def _generate_examples(self, filepath):
|
| 139 |
-
"""Yields examples."""
|
| 140 |
-
# TODO: This method will receive as arguments the `gen_kwargs` defined in the previous `_split_generators` method.
|
| 141 |
-
# It is in charge of opening the given file and yielding (key, example) tuples from the dataset
|
| 142 |
-
# The key is not important, it's more here for legacy reason (legacy from tfds)
|
| 143 |
-
with open(filepath, encoding="utf-8") as f:
|
| 144 |
-
for id_, line in enumerate(f):
|
| 145 |
-
line = line.strip()
|
| 146 |
-
yield id_, {"sentence": line}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|