YuanPJ commited on
Commit
5c004d8
1 Parent(s): b234f47

add loading script

Browse files
Files changed (1) hide show
  1. icsi_summ.py +105 -0
icsi_summ.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ #
3
+ """ICSI summary dataset."""
4
+
5
+
6
+ import json
7
+
8
+ import datasets
9
+
10
+ _CITATION = """\
11
+
12
+ """
13
+
14
+ _DESCRIPTION = """\
15
+
16
+ """
17
+
18
+ _HOMEPAGE = "https://groups.inf.ed.ac.uk/ami/icsi/"
19
+
20
+ _LICENSE = "CC BY 4.0"
21
+
22
+ _BASE_DATA_URL = "https://huggingface.co/datasets/yuanpj/icsi_summ/resolve/main/data/"
23
+
24
+ _SPLIT_URL = _BASE_DATA_URL + "{split}.json"
25
+
26
+ logger = datasets.utils.logging.get_logger(__name__)
27
+
28
+
29
+ class IcsisummConfig(datasets.BuilderConfig):
30
+ """BuilderConfig for the summary subset of ICSI Corpus."""
31
+
32
+ def __init__(self, name, *args, **kwargs):
33
+ """BuilderConfig for the summary subset of ICSI Corpus"""
34
+ super().__init__(name=name, *args, **kwargs)
35
+
36
+
37
+ class Icsisumm(datasets.GeneratorBasedBuilder):
38
+ """ICSI summary dataset."""
39
+
40
+ VERSION = datasets.Version("1.0.0")
41
+
42
+ BUILDER_CONFIGS = [IcsisummConfig(name="icsi_summ")]
43
+
44
+ def _info(self):
45
+ features = datasets.Features(
46
+ {
47
+ "sample_id": datasets.Value("string"),
48
+ "dialogue": [
49
+ {
50
+ "id": datasets.Value("string"),
51
+ "speaker": datasets.Value("string"),
52
+ "starttime": datasets.Value("string"),
53
+ "startwordid": datasets.Value("string"),
54
+ "endtime": datasets.Value("string"),
55
+ "endwordid": datasets.Value("string"),
56
+ "text": datasets.Value("string"),
57
+ "label": datasets.Value("string"),
58
+ "original_label": datasets.Value("string"),
59
+ "attributes": datasets.Value("string"),
60
+ }
61
+ ],
62
+ "summary": [
63
+ {
64
+ "id": datasets.Value("string"),
65
+ "text": datasets.Value("string"),
66
+ "type": datasets.Value("string"),
67
+ }
68
+ ],
69
+ }
70
+ )
71
+ return datasets.DatasetInfo(
72
+ description=_DESCRIPTION,
73
+ features=features,
74
+ supervised_keys=None,
75
+ homepage=_HOMEPAGE,
76
+ license=_LICENSE,
77
+ citation=_CITATION,
78
+ )
79
+
80
+ def _split_generators(self, dl_manager):
81
+ """Returns SplitGenerators."""
82
+ split_urls = {}
83
+ for split in ["dev", "test"]:
84
+ split_urls[split] = _SPLIT_URL.format(split=split)
85
+ file_paths = dl_manager.download(split_urls)
86
+ return [
87
+ datasets.SplitGenerator(
88
+ name=datasets.Split.TRAIN,
89
+ gen_kwargs={
90
+ "path": file_paths["dev"],
91
+ },
92
+ ),
93
+ datasets.SplitGenerator(
94
+ name=datasets.Split.TEST,
95
+ gen_kwargs={
96
+ "path": file_paths["test"],
97
+ },
98
+ ),
99
+ ]
100
+
101
+ def _generate_examples(self, path):
102
+ """Yields examples."""
103
+ data = json.load(open(path, "r", encoding="utf-8"))
104
+ for example in data:
105
+ yield example["sample_id"], example