Fix language and task array

#1
by albertvillanova HF staff - opened
README.md CHANGED
@@ -1,90 +1,12 @@
1
  ---
2
- language: en
3
- size_categories: 10K<n<100K
4
- task_categories:
5
- - text-classification
6
  task_ids:
7
  - multi-class-classification
8
  - topic-classification
9
- tags:
10
- - long context
11
- dataset_info:
12
- - config_name: abstract
13
- features:
14
- - name: text
15
- dtype: string
16
- - name: label
17
- dtype:
18
- class_label:
19
- names:
20
- '0': Human Necessities
21
- '1': Performing Operations; Transporting
22
- '2': Chemistry; Metallurgy
23
- '3': Textiles; Paper
24
- '4': Fixed Constructions
25
- '5': Mechanical Engineering; Lightning; Heating; Weapons; Blasting
26
- '6': Physics
27
- '7': Electricity
28
- '8': General tagging of new or cross-sectional technology
29
- splits:
30
- - name: train
31
- num_bytes: 17225101
32
- num_examples: 25000
33
- - name: validation
34
- num_bytes: 3472854
35
- num_examples: 5000
36
- - name: test
37
- num_bytes: 3456733
38
- num_examples: 5000
39
- download_size: 12067953
40
- dataset_size: 24154688
41
- - config_name: patent
42
- features:
43
- - name: text
44
- dtype: string
45
- - name: label
46
- dtype:
47
- class_label:
48
- names:
49
- '0': Human Necessities
50
- '1': Performing Operations; Transporting
51
- '2': Chemistry; Metallurgy
52
- '3': Textiles; Paper
53
- '4': Fixed Constructions
54
- '5': Mechanical Engineering; Lightning; Heating; Weapons; Blasting
55
- '6': Physics
56
- '7': Electricity
57
- '8': General tagging of new or cross-sectional technology
58
- splits:
59
- - name: train
60
- num_bytes: 466788625
61
- num_examples: 25000
62
- - name: validation
63
- num_bytes: 95315107
64
- num_examples: 5000
65
- - name: test
66
- num_bytes: 93844869
67
- num_examples: 5000
68
- download_size: 272966251
69
- dataset_size: 655948601
70
- configs:
71
- - config_name: abstract
72
- data_files:
73
- - split: train
74
- path: abstract/train-*
75
- - split: validation
76
- path: abstract/validation-*
77
- - split: test
78
- path: abstract/test-*
79
- - config_name: patent
80
- data_files:
81
- - split: train
82
- path: patent/train-*
83
- - split: validation
84
- path: patent/validation-*
85
- - split: test
86
- path: patent/test-*
87
- default: true
88
  ---
89
 
90
  **Patent Classification: a classification of Patents and abstracts (9 classes).**
 
1
  ---
2
+ languages: en
3
+ task_categories: text-classification
4
+ tags:
5
+ - long context
6
  task_ids:
7
  - multi-class-classification
8
  - topic-classification
9
+ size_categories: 10K<n<100K
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ---
11
 
12
  **Patent Classification: a classification of Patents and abstracts (9 classes).**
patent-classification.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+
4
+ import datasets
5
+ from datasets.tasks import TextClassification
6
+
7
+ _CITATION = None
8
+
9
+
10
+ _DESCRIPTION = """
11
+ Patent Classification Dataset: a classification of Patents (9 classes).
12
+ It contains 9 unbalanced classes, 35k Patents and summaries divided into 3 splits: train (25k), val (5k) and test (5k).
13
+ Data are sampled from "BIGPATENT: A Large-Scale Dataset for Abstractive and Coherent Summarization." by Eva Sharma, Chen Li and Lu Wang
14
+ See: https://aclanthology.org/P19-1212.pdf
15
+ See: https://evasharma.github.io/bigpatent/
16
+ """
17
+
18
+ _LABELS = [
19
+ "Human Necessities",
20
+ "Performing Operations; Transporting",
21
+ "Chemistry; Metallurgy",
22
+ "Textiles; Paper",
23
+ "Fixed Constructions",
24
+ "Mechanical Engineering; Lightning; Heating; Weapons; Blasting",
25
+ "Physics",
26
+ "Electricity",
27
+ "General tagging of new or cross-sectional technology",
28
+ ]
29
+
30
+ class PatentClassificationConfig(datasets.BuilderConfig):
31
+ """BuilderConfig for PatentClassification."""
32
+
33
+ def __init__(self, **kwargs):
34
+ """BuilderConfig for PatentClassification.
35
+ Args:
36
+ **kwargs: keyword arguments forwarded to super.
37
+ """
38
+ super(PatentClassificationConfig, self).__init__(**kwargs)
39
+
40
+
41
+ class PatentClassificationDataset(datasets.GeneratorBasedBuilder):
42
+ """PatentClassification Dataset: classification of Patents (9 classes)."""
43
+
44
+ _DOWNLOAD_URL = "https://huggingface.co/datasets/ccdv/patent-classification/resolve/main/"
45
+ _TRAIN_FILE = "train_data.txt"
46
+ _VAL_FILE = "val_data.txt"
47
+ _TEST_FILE = "test_data.txt"
48
+ _LABELS_DICT = {label: i for i, label in enumerate(_LABELS)}
49
+
50
+ BUILDER_CONFIGS = [
51
+ PatentClassificationConfig(
52
+ name="patent",
53
+ version=datasets.Version("1.0.0"),
54
+ description="Patent Classification Dataset: A classification task of Patents (9 classes)",
55
+ ),
56
+
57
+ PatentClassificationConfig(
58
+ name="abstract",
59
+ version=datasets.Version("1.0.0"),
60
+ description="Patent Classification Dataset: A classification task of Patents with abstracts (9 classes)",
61
+ ),
62
+ ]
63
+
64
+ DEFAULT_CONFIG_NAME = "patent"
65
+
66
+ def _info(self):
67
+ return datasets.DatasetInfo(
68
+ description=_DESCRIPTION,
69
+ features=datasets.Features(
70
+ {
71
+ "text": datasets.Value("string"),
72
+ "label": datasets.features.ClassLabel(names=_LABELS),
73
+ }
74
+ ),
75
+ supervised_keys=None,
76
+ citation=_CITATION,
77
+ task_templates=[TextClassification(
78
+ text_column="text", label_column="label")],
79
+ )
80
+
81
+ def _split_generators(self, dl_manager):
82
+ train_path = dl_manager.download_and_extract(self._TRAIN_FILE)
83
+ val_path = dl_manager.download_and_extract(self._VAL_FILE)
84
+ test_path = dl_manager.download_and_extract(self._TEST_FILE)
85
+
86
+ return [
87
+ datasets.SplitGenerator(
88
+ name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}
89
+ ),
90
+ datasets.SplitGenerator(
91
+ name=datasets.Split.VALIDATION, gen_kwargs={"filepath": val_path}
92
+ ),
93
+ datasets.SplitGenerator(
94
+ name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}
95
+ ),
96
+ ]
97
+
98
+ def _generate_examples(self, filepath):
99
+ """Generate PatentClassification examples."""
100
+ with open(filepath, encoding="utf-8") as f:
101
+ for id_, row in enumerate(f):
102
+ data = json.loads(row)
103
+ label = self._LABELS_DICT[data["label"]]
104
+
105
+ if self.config.name == "abstract":
106
+ text = data["abstract"]
107
+ else:
108
+ text = data["description"]
109
+ yield id_, {"text": text, "label": label}
patent/test-00000-of-00001.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d52a3aa7829e35a1da254c5e849ebf4275602a03aeecb37ea174f6e7f988f4fc
3
- size 39091297
 
 
 
 
patent/train-00000-of-00001.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:104e2188980f4a104ab3920b58da17b3d039cde551489a1e29179fac813e04a9
3
- size 194413762
 
 
 
 
patent/validation-00000-of-00001.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:71e0515ecbb4e990b86d8c4b16f275c32493f885965dc54c527b9926e15c2922
3
- size 39461192
 
 
 
 
abstract/test-00000-of-00001.parquet → test_data.txt RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:193794903aa2c7a5a23b34b01b5ac51514afd658f61424024aed74f25fd200d3
3
- size 1720512
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6624a83224d868e575d8c8c210a89135b00ab3ccb563fb0b5ab5f9268e569ca5
3
+ size 97938986
abstract/validation-00000-of-00001.parquet → train_data.txt RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:61a4282d20a6623db135489039b09a5fd541d6158d8f2378ac3098c532ae4671
3
- size 1735855
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:32a8220d7b12b1705f44b0004d6a7ba984fc6038b236cfa63f51563c5f57e8b2
3
+ size 487201907
abstract/train-00000-of-00001.parquet → val_data.txt RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a0c0bb843b324a631735e6f916c5fcbb739f91c15307747b4cf62c67ae313617
3
- size 8611586
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:687787fffcaece738e823508382617abfb0fbbf82917e593600894917e78d1b2
3
+ size 99425708