Datasets:

blnewman-uw commited on
Commit
6555e2a
·
verified ·
1 Parent(s): d5c28d5

Delete loading script

Browse files
Files changed (1) hide show
  1. housing_qa.py +0 -118
housing_qa.py DELETED
@@ -1,118 +0,0 @@
1
- import csv
2
-
3
- import datasets
4
- from datasets import Dataset, DatasetInfo, Features, ClassLabel, Value, Sequence, DatasetDict
5
- import json
6
- from io import StringIO
7
- from pathlib import Path
8
- import pandas as pd
9
-
10
- _CITATION = """"""
11
- _DESCRIPTION = """"""
12
- _HOMEPAGE = ""
13
- _URLS = {
14
- "questions": "data/questions.json.zip",
15
- "questions_aux": "data/questions_aux.json.zip",
16
- "statutes": "data/statutes.tsv.zip",
17
- }
18
-
19
- _CONFIGS = {}
20
-
21
- _CONFIGS["questions"] = {
22
- "description": "Questions about housing law.",
23
- "features" : Features({
24
- 'idx': Value('int32'),
25
- 'state': Value('string'),
26
- 'question': Value('string'),
27
- 'answer': Value('string'),
28
- 'question_group': Value('int32'),
29
- 'statutes': [{
30
- 'statute_idx': Value('int32'),
31
- 'citation': Value('string'),
32
- 'excerpt': Value('string'),
33
- }],
34
- 'original_question': Value('string'),
35
- 'caveats': Sequence(Value('string')),
36
- }),
37
- "license": None,
38
- }
39
-
40
- _CONFIGS["questions_aux"] = {
41
- "description": "An auxilliary set of larger questions about housing law, without statutory annotations.",
42
- "features" : Features({
43
- 'idx': Value('int32'),
44
- 'state': Value('string'),
45
- 'question': Value('string'),
46
- 'answer': Value('string'),
47
- 'question_group': Value('int32'),
48
- 'statutes': Sequence({
49
- 'citation': Value('string'),
50
- 'excerpt': Value('string'),
51
- }),
52
- 'original_question': Value('string'),
53
- 'caveats': Sequence(Value('string')),
54
- }),
55
- "license": None,
56
- }
57
-
58
- _CONFIGS["statutes"] = {
59
- "description": "Corpus of statutes",
60
- "features": Features({
61
- "citation": datasets.Value("string"),
62
- "path": datasets.Value("string"),
63
- "state": datasets.Value("string"),
64
- "text": datasets.Value("string"),
65
- "idx": datasets.Value("int32"),
66
- }),
67
- "license": None,
68
- }
69
-
70
-
71
- class HousingQA(datasets.GeneratorBasedBuilder):
72
- """TODO"""
73
-
74
- BUILDER_CONFIGS = [
75
- datasets.BuilderConfig(
76
- name=task, version=datasets.Version("1.0.0"), description=task,
77
- )
78
- for task in _CONFIGS
79
- ]
80
-
81
- def _info(self):
82
- features = _CONFIGS[self.config.name]["features"]
83
- return datasets.DatasetInfo(
84
- description=_DESCRIPTION,
85
- features=features,
86
- homepage=_HOMEPAGE,
87
- citation=_CITATION,
88
- license=_CONFIGS[self.config.name]["license"],
89
- )
90
-
91
- def _split_generators(self, dl_manager):
92
- """Returns SplitGenerators."""
93
- downloaded_file_dir = Path(dl_manager.download_and_extract(_URLS[self.config.name]))
94
- return [
95
- datasets.SplitGenerator(
96
- name="corpus" if self.config.name == "statutes" else "test",
97
- gen_kwargs={
98
- "downloaded_file_dir": downloaded_file_dir,
99
- "name": self.config.name,
100
- },
101
- ),
102
- ]
103
-
104
- def _generate_examples(self, downloaded_file_dir, name):
105
- """Yields examples as (key, example) tuples."""
106
-
107
- if name in ["questions", "questions_aux"]:
108
- fpath = downloaded_file_dir / f"{name}.json"
109
- data = json.loads(fpath.read_text())
110
- for id_line, data in enumerate(data):
111
- yield id_line, data
112
-
113
- if name in ["statutes"]:
114
- fpath = downloaded_file_dir / f"{name}.tsv"
115
- data = pd.read_csv(fpath, sep="\t", dtype={'index': 'int32'})
116
- data = data.to_dict(orient="records")
117
- for id_line, data in enumerate(data):
118
- yield id_line, data