Convert dataset to Parquet (#2)
Browse files- Convert dataset to Parquet (99c109824ce14ddd085e7d7316beec3833551f0b)
- Delete loading script (0a1a067458ec4e5b870ab301ad289975d332af46)
- Delete legacy dataset_infos.json (dd632434c3db8b7be5e3de5b3e2659ea1fb33949)
Files changed (5)
- README.mdAdded+30
- data/test-00000-of-00001.parquetAdded+3
- data/train-00000-of-00001.parquetAdded+3
- dataset_infos.jsonDeleted-1
- labels.pyDeleted-93
123456789101112131415161718192021222324252627282930---dataset_info: features: - name: text dtype: string - name: label dtype: class_label: names: '0': World '1': Sports '2': Business '3': Sci/Tech splits: - name: train num_bytes: 29817303 num_examples: 120000 - name: test num_bytes: 1879474 num_examples: 7600 download_size: 19820267 dataset_size: 31696777configs:- config_name: default data_files: - split: train path: data/train-* - split: test path: data/test-*---123version https://git-lfs.github.com/spec/v1oid sha256:f43f50be12dbc50a87a88f7cf78d32ed16651d402bb63b590b105cd2ec54f346size 1234829123version https://git-lfs.github.com/spec/v1oid sha256:9b0df9c3bc6b51f5ccb303f8e622b2a7a932b3d21c6f0d38a1e403e7b947d780size 185854381{"default": {"description": "AG is a collection of more than 1 million news articles. News articles have been\ngathered from more than 2000 news sources by ComeToMyHead in more than 1 year of\nactivity. ComeToMyHead is an academic news search engine which has been running\nsince July, 2004. The dataset is provided by the academic comunity for research\npurposes in data mining (clustering, classification, etc), information retrieval\n(ranking, search, etc), xml, data compression, data streaming, and any other\nnon-commercial activity. For more information, please refer to the link\nhttp://www.di.unipi.it/~gulli/AG_corpus_of_news_articles.html .\n\nThe AG's news topic classification dataset is constructed by Xiang Zhang\n(xiang.zhang@nyu.edu) from the dataset above. It is used as a text\nclassification benchmark in the following paper: Xiang Zhang, Junbo Zhao, Yann\nLeCun. Character-level Convolutional Networks for Text Classification. Advances\nin Neural Information Processing Systems 28 (NIPS 2015).\n", "citation": "@inproceedings{Zhang2015CharacterlevelCN,\n title={Character-level Convolutional Networks for Text Classification},\n author={Xiang Zhang and Junbo Jake Zhao and Yann LeCun},\n booktitle={NIPS},\n year={2015}\n}\n", "homepage": "http://groups.di.unipi.it/~gulli/AG_corpus_of_news_articles.html", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 4, "names": ["World", "Sports", "Business", "Sci/Tech"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "task_templates": [{"task": "text-classification", "text_column": "text", "label_column": "label", "labels": ["Business", "Sci/Tech", "Sports", "World"]}], "builder_name": "ag_news", "config_name": "default", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 29817351, "num_examples": 120000, "dataset_name": "ag_news"}, "test": {"name": "test", "num_bytes": 1879478, "num_examples": 7600, "dataset_name": "ag_news"}}, "download_checksums": {"https://raw.githubusercontent.com/mhjabreel/CharCnn_Keras/master/data/ag_news_csv/train.csv": {"num_bytes": 29470338, "checksum": "76a0a2d2f92b286371fe4d4044640910a04a803fdd2538e0f3f29a5c6f6b672e"}, "https://raw.githubusercontent.com/mhjabreel/CharCnn_Keras/master/data/ag_news_csv/test.csv": {"num_bytes": 1857427, "checksum": "521465c2428ed7f02f8d6db6ffdd4b5447c1c701962353eb2c40d548c3c85699"}}, "download_size": 31327765, "post_processing_size": null, "dataset_size": 31696829, "size_in_bytes": 63024594}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293# coding=utf-8# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
# Lint as: python3"""AG News topic classification dataset."""
import csv
import datasetsfrom datasets.tasks import TextClassification
_DESCRIPTION = """\AG is a collection of more than 1 million news articles. News articles have beengathered from more than 2000 news sources by ComeToMyHead in more than 1 year ofactivity. ComeToMyHead is an academic news search engine which has been runningsince July, 2004. The dataset is provided by the academic comunity for researchpurposes in data mining (clustering, classification, etc), information retrieval(ranking, search, etc), xml, data compression, data streaming, and any othernon-commercial activity. For more information, please refer to the linkhttp://www.di.unipi.it/~gulli/AG_corpus_of_news_articles.html .The AG's news topic classification dataset is constructed by Xiang Zhang(xiang.zhang@nyu.edu) from the dataset above. It is used as a textclassification benchmark in the following paper: Xiang Zhang, Junbo Zhao, YannLeCun. Character-level Convolutional Networks for Text Classification. Advancesin Neural Information Processing Systems 28 (NIPS 2015)."""
_CITATION = """\@inproceedings{Zhang2015CharacterlevelCN, title={Character-level Convolutional Networks for Text Classification}, author={Xiang Zhang and Junbo Jake Zhao and Yann LeCun}, booktitle={NIPS}, year={2015}}"""
_TRAIN_DOWNLOAD_URL = "https://raw.githubusercontent.com/mhjabreel/CharCnn_Keras/master/data/ag_news_csv/train.csv"_TEST_DOWNLOAD_URL = "https://raw.githubusercontent.com/mhjabreel/CharCnn_Keras/master/data/ag_news_csv/test.csv"
class AGNews(datasets.GeneratorBasedBuilder): """AG News topic classification dataset."""
def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=datasets.Features( { "text": datasets.Value("string"), "label": datasets.features.ClassLabel(names=["World", "Sports", "Business", "Sci/Tech"]), } ), homepage="http://groups.di.unipi.it/~gulli/AG_corpus_of_news_articles.html", citation=_CITATION, task_templates=[TextClassification(text_column="text", label_column="label")], )
def _split_generators(self, dl_manager): train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL) test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL) return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}), datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}), ]
def _generate_examples(self, filepath): """Generate AG News examples.""" with open(filepath, encoding="utf-8") as csv_file: csv_reader = csv.reader( csv_file, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True ) for id_, row in enumerate(csv_reader): label, title, description = row # Original labels are [1, 2, 3, 4] -> # ['World', 'Sports', 'Business', 'Sci/Tech'] # Re-map to [0, 1, 2, 3]. label = int(label) - 1 text = " ".join((title, description)) yield id_, {"text": text, "label": label}README.mdAdded+30
data/test-00000-of-00001.parquetAdded+3
data/train-00000-of-00001.parquetAdded+3
dataset_infos.jsonDeleted-1
labels.pyDeleted-93