Datasets:

Modalities:
Text
Libraries:
Datasets
License:
Sean MacAvaney commited on
Commit
a4663dc
1 Parent(s): c43d495

dataset loading script

Browse files
Files changed (1) hide show
  1. csl.py +40 -0
csl.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gzip
2
+ import json
3
+ import datasets
4
+
5
+ _URLS = {
6
+ "csl": "https://huggingface.co/datasets/neuclir/neumarco/resolve/main/data/csl.jsonl.gz"
7
+ }
8
+
9
+ class Csl(datasets.GeneratorBasedBuilder):
10
+ VERSION = datasets.Version("1.0.0")
11
+
12
+ def _info(self):
13
+ return datasets.DatasetInfo(
14
+ features=datasets.Features({
15
+ "doc_id": datasets.Value("string"),
16
+ "title": datasets.Value("string"),
17
+ "abstract": datasets.Value("string"),
18
+ "keywords": datasets.Sequence(feature=datasets.Value("string"), length=-1),
19
+ "category": datasets.Value("string"),
20
+ "category_zho": datasets.Value("string"),
21
+ "discipline": datasets.Value("string"),
22
+ "discipline_zho": datasets.Value("string"),
23
+ }),
24
+ )
25
+
26
+ def _split_generators(self, dl_manager):
27
+ paths = dl_manager.download(_URLS)
28
+ return [
29
+ datasets.SplitGenerator(
30
+ name='csl',
31
+ gen_kwargs={
32
+ "filepath": paths['csl'],
33
+ })
34
+ ]
35
+
36
+ def _generate_examples(self, filepath):
37
+ with gzip.open(filepath) as f:
38
+ for key, row in enumerate(f):
39
+ data = json.loads(row)
40
+ yield key, data