joemaatouk commited on
Commit
9776151
·
1 Parent(s): 6733fde

Upload EZPass-Dataset.py

Browse files
Files changed (1) hide show
  1. EZPass-Dataset.py +95 -0
EZPass-Dataset.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """
45
+
46
+ _URL = "https://huggingface.co/datasets/joemaatouk/EZPass-Dataset/resolve/main/EZPass-images.tar.gz"
47
+ descriptions =[{"text": "{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"127806097-1\", \"account_number\": \"5526331\", \"invoice_date\": \"08/21/2023\", \"license_plate\": \"PA-KMB5413\", \"payment_due\": \"$42.40\", \"payment_due_date\": \"09/11/2023\", \"invoice_no\": \"127806097\",\"amount_due\": \"$42.40\",\"invoice_date\": \"09/11/2023\",\"account_number\": \"5526331\",}}"},
48
+ {"text": "{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"mailing_number\": \"B1531128696669\", \"mailing_date\": \"06/29/2023\",\"NOTD_amount_due\": \"$6.00\",\"by\": \"07/31/2023\", \"toll_amount_due\": \"$6.00\", \"video_toll_transaction_number\": \"B1531128696669-00001\", \"state/license_plate\": \"PA/LSY0217\", \"location_toll\": \"Baltimore City I-95 Fort McHenry Tunnel\", \"exit_date_and_time_of_toll\": \"10/11/2022 05:40:51 PM\"}"},
49
+ {"text": "{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"mailing_number\": \"B1531123158574\", \"mailing_date\": \"09/21/2022\",\"NOTD_amount_due\": \"$6.00\",\"by\": \"08/31/2022\", \"toll_amount_due\": \"$6.00\", \"video_toll_transaction_number\": \"B1531123158574-00001\", \"state/license_plate\": \"PA/LDJ1110\", \"location_toll\": \"Baltimore City I-95 Fort McHenry Tunnel\", \"exit_date_and_time_of_toll\": \"02/09/2021 09:55:37 AM\"}"},
50
+ {"text": "{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"120691145-1\", \"account_number\": \"1214734\", \"invoice_date\": \"09/23/2022\", \"license_plate\": \"PA-LDJ1110\", \"payment_due\": \"$8.70\", \"payment_due_date\": \"10/13/2022\", \"invoice_no\": \"120691145-1\",\"amount_due\": \"$8.70\",\"invoice_date\": \"09/23/2022\",\"account_number\": \"1214737\",}}"},
51
+ {"text": "{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"120691145-1\", \"account_number\": \"1214734\", \"invoice_date\": \"09/23/2022\", \"license_plate\": \"PA-LDJ1110\", \"payment_due\": \"$8.70\", \"payment_due_date\": \"10/13/2022\", \"invoice_no\": \"120691145-1\",\"amount_due\": \"$8.70\",\"invoice_date\": \"09/23/2022\",\"account_number\": \"1214737\",}}"},
52
+ {"text": "{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"112580557-1\", \"account_number\": \"1214734\", \"license_plate\": \"PA-LSY0217\", \"invoice_date\": \"09/23/21\",\"toll_charges\": \"$0.00\", \"patments\": \"$0.00\",\"adjustments\": \"$0.00\",\"fees\": \"$0.00\",\"payment_due\": \"$6.00\", \"payment_due_date\": \"10/13/2021\", \"invoice_no\": \"112580557-1\",\"amount_due\": \"$6.00\",\"payment_due_date\": \"10/13/2021\",\"account_number\": \"1214734\",}}"},
53
+ ]
54
+
55
+ class EZPassTargz(datasets.GeneratorBasedBuilder):
56
+ """SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
57
+
58
+ def _info(self):
59
+ return datasets.DatasetInfo(
60
+ description=_DESCRIPTION,
61
+ features=datasets.Features(
62
+ {
63
+ "text": datasets.Value("string"),
64
+ "image": datasets.Image(),
65
+
66
+ }
67
+ ),
68
+ # No default supervised_keys (as we have to pass both question
69
+ # and context as input).
70
+ supervised_keys=None,
71
+ homepage="https://hugginface.co/datasets/joemaatouk/EZPass-Dataset/",
72
+ citation=_CITATION,
73
+ )
74
+
75
+ def _split_generators(self, dl_manager):
76
+ path = dl_manager.download(_URL)
77
+ image_iters = dl_manager.iter_archive(path)
78
+
79
+ return [
80
+ datasets.SplitGenerator(
81
+ name=datasets.Split.TRAIN,
82
+ gen_kwargs={"images": image_iters}),
83
+ ]
84
+
85
+ def _generate_examples(self, images):
86
+ """This function returns the examples in the raw (text) form."""
87
+ idx = 0
88
+ #iterate through the images
89
+ for filepath, image in images:
90
+ #extract the text from the filename
91
+ yield idx,{
92
+ "image":{"filepath": filepath,"image":image.read()},
93
+ "ground_truth": descriptions[idx]
94
+ }
95
+ idx+=1