Datasets:

Modalities:
Text
Formats:
parquet
Languages:
English
ArXiv:
Libraries:
Datasets
pandas
License:
davebulaval commited on
Commit
382c310
1 Parent(s): b622e61

Upload riscbac.py

Browse files
Files changed (1) hide show
  1. riscbac.py +115 -0
riscbac.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """RISCBAC: a synthetic bilingual automotive insurance contract dataset"""
15
+
16
+
17
+ import csv
18
+ import json
19
+ import os
20
+
21
+ import datasets
22
+
23
+
24
+ _CITATION = """\
25
+ @misc{beaucheminrisc,
26
+ title={{RISC: Generating Realistic Synthetic Bilingual Insurance
27
+ Contract}},
28
+ author={David Beauchemin and Richard Khoury},
29
+ year={2023},
30
+ eprint={2304.04212},
31
+ archivePrefix={arXiv}
32
+ }
33
+ """
34
+
35
+ # You can copy an official description
36
+ _DESCRIPTION = """\
37
+ RISCBAC was created using [RISC](https://github.com/GRAAL-Research/risc), an open-source Python package data
38
+ generator. RISC generates look-alike automobile insurance contracts based on the Quebec regulatory insurance
39
+ form in French and English.
40
+
41
+ It contains 10,000 English and French insurance contracts generated using the same seed. Thus, contracts share
42
+ the same deterministic synthetic data (RISCBAC can be used as an aligned dataset). RISC can be used to generate
43
+ more data for RISCBAC.
44
+ """
45
+
46
+ _HOMEPAGE = "https://huggingface.co/datasets/davebulaval/RISCBAC"
47
+
48
+ _LICENSE = "Attribution 4.0 International (CC BY 4.0)"
49
+
50
+ _URLS = {
51
+ "en": "https://huggingface.co/datasets/davebulaval/RISCBAC/blob/main/en.zip",
52
+ "fr": "https://huggingface.co/datasets/davebulaval/RISCBAC/blob/main/fr.zip",
53
+ }
54
+
55
+
56
+ class RISCBAC(datasets.GeneratorBasedBuilder):
57
+ """RISCBAC: a synthetic bilingual automotive insurance contract dataset"""
58
+
59
+ VERSION = datasets.Version("1.0.0")
60
+
61
+ BUILDER_CONFIGS = [
62
+ datasets.BuilderConfig(
63
+ name="en", version=VERSION, description="This part of the dataset are automobile contract in English."
64
+ ),
65
+ datasets.BuilderConfig(
66
+ name="fr", version=VERSION, description="This part of the dataset are automobile contract in French."
67
+ ),
68
+ ]
69
+
70
+ def _info(self):
71
+ features = datasets.Features(
72
+ {
73
+ "text": datasets.Value("string"),
74
+ }
75
+ )
76
+ return datasets.DatasetInfo(
77
+ description=_DESCRIPTION,
78
+ features=features,
79
+ supervised_keys=None,
80
+ homepage=_HOMEPAGE,
81
+ license=_LICENSE,
82
+ citation=_CITATION,
83
+ )
84
+
85
+ def _split_generators(self, dl_manager):
86
+ urls = _URLS[self.config.name]
87
+ data_dir = dl_manager.download_and_extract(urls)
88
+ if self.config.name == "en":
89
+ return [
90
+ datasets.SplitGenerator(
91
+ name=datasets.Split.TRAIN,
92
+ gen_kwargs={
93
+ "filepath": os.path.join(data_dir, "en", "en.jsonl"),
94
+ "split": "full",
95
+ },
96
+ )
97
+ ]
98
+ elif self.config.name == "Ffr":
99
+ return [
100
+ datasets.SplitGenerator(
101
+ name=datasets.Split.TRAIN,
102
+ gen_kwargs={
103
+ "filepath": os.path.join(data_dir, "fr", "fr.jsonl"),
104
+ "split": "full",
105
+ },
106
+ ),
107
+ ]
108
+ else:
109
+ raise ValueError(f"The config name {self.config.name} is not supported. Please use " "'en' or 'fr'.")
110
+
111
+ def _generate_examples(self, filepath, split):
112
+ with open(filepath, "r", encoding="utf-8") as f:
113
+ for key, line in enumerate(f):
114
+ d = json.loads(line)
115
+ yield key, {"text": d}