Datasets:

nguha commited on
Commit
c8460c9
·
1 Parent(s): 167e070

Adding data

Browse files
data/knowledge_questions.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:30f2312e1681f964b4e850962ef48c7cb80e79c1e9e2889d80710eb9ca7462e8
3
+ size 30186420
data/knowledge_questions.json.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a33c0f7a33823ba145b4b1f1de2de7c91fcee8853b771a42517d4c4cc25c769
3
+ size 1297779
data/rc_questions.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f6eb35e1b865a6c5cfd0cf73a0b514a86bd1d8306bf6719f2b4fb94793c7e4b
3
+ size 22753840
data/rc_questions.json.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90e1f354374ac7378021c4d30ce9a8b089191ba6f74c0535879271eaaeb8afb7
3
+ size 986933
data/statutes.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d974d2878a059dcaa41584a967ccc608bd6efaf91d78253100de7a187c06ac3a
3
+ size 3357422356
data/statutes.tsv.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7d4382875edc40b54de5889a21d7ddebe6fae5629fd54bfa53b3d82c20eb04ae
3
+ size 731952596
housing_qa.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import csv
2
+
3
+ import datasets
4
+ import json
5
+ from io import StringIO
6
+ from pathlib import Path
7
+ import pandas as pd
8
+
9
+ _CITATION = """"""
10
+ _DESCRIPTION = """"""
11
+ _HOMEPAGE = ""
12
+ _URLS = {
13
+ "knowledge_questions": "data/knowledge_questions.json.zip",
14
+ "rc_questions": "data/rc_questions.json.zip",
15
+ "statutes": "data/statutes.tsv.zip",
16
+ }
17
+
18
+
19
+
20
+ _CONFIGS = {}
21
+
22
+ _CONFIGS["knowledge_questions"] = {
23
+ "description": "Answer knowledge questions about housing law in the different states.",
24
+ "features": {
25
+ "idx": datasets.Value("int32"),
26
+ "state": datasets.Value("string"),
27
+ "question": datasets.Value("string"),
28
+ "answer": datasets.Value("string"),
29
+ "question_group": datasets.Value("int32"),
30
+ "statutes": datasets.Sequence(
31
+ {
32
+ "citation": datasets.Value("string"),
33
+ "excerpt": datasets.Value("string"),
34
+ }
35
+ ),
36
+ "original_question": datasets.Value("string"),
37
+ "caveats": datasets.Sequence([datasets.Value("string")]),
38
+ },
39
+ "license": None,
40
+ }
41
+
42
+ _CONFIGS["rc_questions"] = {
43
+ "description": "Answer RC questions about housing law in the different states.",
44
+ "features": {
45
+ "idx": datasets.Value("int32"),
46
+ "state": datasets.Value("string"),
47
+ "question": datasets.Value("string"),
48
+ "answer": datasets.Value("string"),
49
+ "question_group": datasets.Value("int32"),
50
+ "statutes": datasets.Sequence(
51
+ {
52
+ "statute_idx": datasets.Value("int32"),
53
+ "citation": datasets.Value("string"),
54
+ "excerpt": datasets.Value("string"),
55
+ }
56
+ ),
57
+ "original_question": datasets.Value("string"),
58
+ "caveats": datasets.Sequence([datasets.Value("string")]),
59
+ },
60
+ "license": None,
61
+ }
62
+
63
+ _CONFIGS["statutes"] = {
64
+ "description": "Corpus of statutes",
65
+ "features": {
66
+ "citation": datasets.Value("string"),
67
+ "path": datasets.Value("string"),
68
+ "state": datasets.Value("string"),
69
+ "text": datasets.Value("string"),
70
+ "idx": datasets.Value("int32"),
71
+ },
72
+ "license": None,
73
+ }
74
+
75
+
76
+ class HousingQA(datasets.GeneratorBasedBuilder):
77
+ """TODO"""
78
+
79
+ BUILDER_CONFIGS = [
80
+ datasets.BuilderConfig(
81
+ name=task, version=datasets.Version("1.0.0"), description=task,
82
+ )
83
+ for task in _CONFIGS
84
+ ]
85
+
86
+ def _info(self):
87
+ features = _CONFIGS[self.config.name]["features"]
88
+ return datasets.DatasetInfo(
89
+ description=_DESCRIPTION,
90
+ features=datasets.Features(features),
91
+ homepage=_HOMEPAGE,
92
+ citation=_CITATION,
93
+ license=_CONFIGS[self.config.name]["license"],
94
+ )
95
+
96
+ def _split_generators(self, dl_manager):
97
+ """Returns SplitGenerators."""
98
+ downloaded_file_dir = Path(dl_manager.download_and_extract(_URLS[self.config.name]))
99
+ return [
100
+ datasets.SplitGenerator(
101
+ name=datasets.Split.TEST,
102
+ gen_kwargs={
103
+ "downloaded_file_dir": downloaded_file_dir,
104
+ "name": self.config.name,
105
+ },
106
+ ),
107
+ ]
108
+
109
+ def _generate_examples(self, downloaded_file_dir, name):
110
+ """Yields examples as (key, example) tuples."""
111
+
112
+ if name in ["knowledge_questions"]:
113
+ fpath = downloaded_file_dir / f"{name}.json"
114
+ data = json.loads(fpath.read_text())
115
+ for id_line, data in enumerate(data):
116
+ yield id_line, data
117
+
118
+ if name in ["rc_questions"]:
119
+ fpath = downloaded_file_dir / f"{name}.json"
120
+ data = json.loads(fpath.read_text())
121
+ for id_line, data in enumerate(data):
122
+ yield id_line, data
123
+
124
+ if name in ["statutes"]:
125
+ fpath = downloaded_file_dir / f"{name}.tsv"
126
+ data = pd.read_csv(fpath, sep="\t", dtype={'index': 'int32'})
127
+ data = data.to_dict(orient="records")
128
+ for id_line, data in enumerate(data):
129
+ yield id_line, data