Datasets:

Modalities:
Text
Libraries:
Datasets
License:
File size: 1,282 Bytes
a4663dc
 
 
 
 
721c732
a4663dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gzip
import json
import datasets

_URLS = {
  "csl": "https://huggingface.co/datasets/neuclir/csl/resolve/main/data/csl.jsonl.gz"
}

class Csl(datasets.GeneratorBasedBuilder):
    VERSION = datasets.Version("1.0.0")

    def _info(self):
        return datasets.DatasetInfo(
            features=datasets.Features({
              "doc_id": datasets.Value("string"),
              "title": datasets.Value("string"),
              "abstract": datasets.Value("string"),
              "keywords": datasets.Sequence(feature=datasets.Value("string"), length=-1),
              "category": datasets.Value("string"),
              "category_zho": datasets.Value("string"),
              "discipline": datasets.Value("string"),
              "discipline_zho": datasets.Value("string"),
            }),
        )

    def _split_generators(self, dl_manager):
        paths = dl_manager.download(_URLS)
        return [
            datasets.SplitGenerator(
                name='csl',
                gen_kwargs={
                    "filepath": paths['csl'],
                })
        ]

    def _generate_examples(self, filepath):
        with gzip.open(filepath) as f:
            for key, row in enumerate(f):
                data = json.loads(row)
                yield key, data