TenzinGayche commited on
Commit
da37256
·
1 Parent(s): 996a0d9
Files changed (6) hide show
  1. .gitattributes +2 -0
  2. Demo-dataset.py +134 -0
  3. init.py +24 -0
  4. splits/test.csv +3 -0
  5. splits/train.csv +3 -0
  6. splits/valid.csv +3 -0
.gitattributes CHANGED
@@ -52,3 +52,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ *.tar filter=lfs diff=lfs merge=lfs -text
56
+ *.csv filter=lfs diff=lfs merge=lfs -text
Demo-dataset.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """SQUAD: The Stanford Question Answering Dataset."""
18
+
19
+
20
+ import json
21
+
22
+ import datasets
23
+ from datasets.tasks import QuestionAnsweringExtractive
24
+
25
+
26
+ logger = datasets.logging.get_logger(__name__)
27
+
28
+
29
+ _CITATION = """\
30
+ @article{2016arXiv160605250R,
31
+ author = {{Rajpurkar}, Pranav and {Zhang}, Jian and {Lopyrev},
32
+ Konstantin and {Liang}, Percy},
33
+ title = "{SQuAD: 100,000+ Questions for Machine Comprehension of Text}",
34
+ journal = {arXiv e-prints},
35
+ year = 2016,
36
+ eid = {arXiv:1606.05250},
37
+ pages = {arXiv:1606.05250},
38
+ archivePrefix = {arXiv},
39
+ eprint = {1606.05250},
40
+ }
41
+ """
42
+
43
+ _DESCRIPTION = """\
44
+ Stanford Question Answering Dataset (SQuAD) is a reading comprehension \
45
+ dataset, consisting of questions posed by crowdworkers on a set of Wikipedia \
46
+ articles, where the answer to every question is a segment of text, or span, \
47
+ from the corresponding reading passage, or the question might be unanswerable.
48
+ """
49
+
50
+ _URL = "https://rajpurkar.github.io/SQuAD-explorer/dataset/"
51
+ _URLS = {
52
+ "train": _URL + "train-v1.1.json",
53
+ "dev": _URL + "dev-v1.1.json",
54
+ }
55
+
56
+
57
+ class SquadConfig(datasets.BuilderConfig):
58
+ """BuilderConfig for SQUAD."""
59
+
60
+ def __init__(self, **kwargs):
61
+ """BuilderConfig for SQUAD.
62
+
63
+ Args:
64
+ **kwargs: keyword arguments forwarded to super.
65
+ """
66
+ super(SquadConfig, self).__init__(**kwargs)
67
+
68
+
69
+ class Squad(datasets.GeneratorBasedBuilder):
70
+ """SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
71
+
72
+ BUILDER_CONFIGS = [
73
+ SquadConfig(
74
+ name="tibetan_voice",
75
+ version=datasets.Version("1.0.0", ""),
76
+ description="The dataset comprises 6.5 hours of validated transcribed speech data from 9 audio book ",
77
+ ),
78
+ ]
79
+
80
+ def _info(self):
81
+ return datasets.DatasetInfo(
82
+ description=_DESCRIPTION,
83
+ features=datasets.Features(
84
+ {
85
+ "path": datasets.Value("string"),
86
+ "sentence": datasets.Value("string"),
87
+ }
88
+ ),
89
+ # No default supervised_keys (as we have to pass both question
90
+ # and context as input).
91
+ supervised_keys=None,
92
+ homepage="https://rajpurkar.github.io/SQuAD-explorer/",
93
+ citation=_CITATION,
94
+ task_templates=[
95
+ QuestionAnsweringExtractive(
96
+ question_column="question", context_column="context", answers_column="answers"
97
+ )
98
+ ],
99
+ )
100
+
101
+ def _split_generators(self, dl_manager):
102
+ downloaded_files = dl_manager.download_and_extract(_URLS)
103
+
104
+ return [
105
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
106
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
107
+ ]
108
+
109
+ def _generate_examples(self, filepath):
110
+ """This function returns the examples in the raw (text) form."""
111
+ logger.info("generating examples from = %s", filepath)
112
+ key = 0
113
+ with open(filepath, encoding="utf-8") as f:
114
+ squad = json.load(f)
115
+ for article in squad["data"]:
116
+ title = article.get("title", "")
117
+ for paragraph in article["paragraphs"]:
118
+ context = paragraph["context"] # do not strip leading blank spaces GH-2585
119
+ for qa in paragraph["qas"]:
120
+ answer_starts = [answer["answer_start"] for answer in qa["answers"]]
121
+ answers = [answer["text"] for answer in qa["answers"]]
122
+ # Features currently used are "context", "question", and "answers".
123
+ # Others are extracted here for the ease of future expansions.
124
+ yield key, {
125
+ "title": title,
126
+ "context": context,
127
+ "question": qa["question"],
128
+ "id": qa["id"],
129
+ "answers": {
130
+ "answer_start": answer_starts,
131
+ "text": answers,
132
+ },
133
+ }
134
+ key += 1
init.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # ziping wav file to wav.tar.gz
3
+
4
+
5
+ import tarfile
6
+ import os.path
7
+ from datasets import DownloadManager
8
+
9
+ source_dir = '/Users/tenzingayche/Downloads/wav 2'
10
+ output_filename = 'wav.tar'
11
+ def make_tarfile(output_filename, source_dir):
12
+ with tarfile.open(output_filename, "w:gz") as tar:
13
+ tar.add(source_dir, arcname=os.path.basename(source_dir))
14
+
15
+ #extracting wav.tar.gz to wav file
16
+ def extract_tarfile(output_filename, source_dir):
17
+ with tarfile.open(output_filename, "r:gz") as tar:
18
+ tar.extractall(source_dir)
19
+ _url='https://github.com/TenzinGayche/Demo-dataset/raw/master/wav.tar.gz'
20
+ # dl_manager = DownloadManager()
21
+ # a=dl_manager.download_and_extract(_url)
22
+ # print(a)
23
+ # os.listdir(a)
24
+ make_tarfile(output_filename, source_dir)
splits/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6da4477b62c374b78e9c99a6a061966773d83a33eb6afec17b71f9c99b7c0374
3
+ size 1261
splits/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c18b17fa11796fef513610c895539f81e1badf043f52033bbb6772e70fadbae
3
+ size 2721
splits/valid.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6da4477b62c374b78e9c99a6a061966773d83a33eb6afec17b71f9c99b7c0374
3
+ size 1261