File size: 8,113 Bytes
9776151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61481e2
9776151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61481e2
9776151
 
61481e2
9776151
1ee0dc6
a6e8ca7
6016e2c
1ee0dc6
197892c
1ee0dc6
6016e2c
 
 
 
 
 
 
529fd57
bbdd86b
9776151
61481e2
9776151
 
 
 
 
 
 
 
 
 
 
 
61481e2
9776151
 
 
 
 
 
 
 
 
 
 
 
 
ee9ab1e
9776151
 
 
ee9ab1e
61481e2
9776151
529fd57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# coding=utf-8
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Lint as: python3
"""SQUAD: The Stanford Question Answering Dataset."""


import json
import datasets

logger = datasets.logging.get_logger(__name__)

#credited for developing sample script
_CITATION = """\
@article{2016arXiv160605250R,
       author = {{Rajpurkar}, Pranav and {Zhang}, Jian and {Lopyrev},
                 Konstantin and {Liang}, Percy},
        title = "{SQuAD: 100,000+ Questions for Machine Comprehension of Text}",
      journal = {arXiv e-prints},
         year = 2016,
          eid = {arXiv:1606.05250},
        pages = {arXiv:1606.05250},
archivePrefix = {arXiv},
       eprint = {1606.05250},
}
"""

_DESCRIPTION = """\
    Dataset featuring key metadata from EZ-Pass invoices
"""

#url that downloads the tar.gz file that contains the images in it 
_URL = "https://huggingface.co/datasets/joemaatouk/EZPass-Dataset/resolve/main/EZPass-images.tar.gz"

descriptions = [
    '{\"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\", \"due_date\": \"09/11/2023\",,\"invoice_number\": \"127806097-1\", \"amount_due\": \"$42.40\",\"invoice_date\": \"09/11/2022\", \"account_number\": \"5526331\",\"amount_paid\": \"$\"}}',
    '{\"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\"}}',
    '{\"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\"}}',
    '{\"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\"}}',
    '{\"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\", \"due_date\": \"10/13/2022\",\"invoice_number\": \"120691145-1\", \"amount_due\": \"$8.70\",\"invoice_date\": \"09/23/2022\", \"account_number\": \"1214734\",\"amount_paid\": \"$\"}}',
    '{\"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\", \"payments\": \"$0.00\",\"adjustments\": \"$0.00\",\"fees\": \"$0.00\",\"payment_due\": \"$6.00\", \"payment_due_date\": \"10/13/2021\", \"amount_due\": \"$6.00\"}}',
    '{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"122740015-1\", \"account_number\": \"5526331\", \"invoice_date\": \"12/23/2022\", \"license_plate\": \"PA-KMB5413\", \"payment_due\": \"$29.70\", \"due_date\": \"01/12/2023\",\"invoice_number\": \"122740015-1\", \"amount_due\": \"$29.70\",\"invoice_date\": \"12/23/2022\", \"account_number\": \"5526331\",\"amount_paid\": \"$\"}}',
    '{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"123701388-1\", \"account_number\": \"5526331\", \"invoice_date\": \"02/10/2023\", \"license_plate\": \"PA-KMB5413\", \"payment_due\": \"$9.20\", \"due_date\": \"03/02/2023\",\"invoice_number\": \"123701388-1\", \"amount_due\": \"$9.20\",\"invoice_date\": \"02/10/2022\", \"account_number\": \"5526331\",\"amount_paid\": \"$\"}}',
    '{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"124233968-1\", \"account_number\": \"5526331\", \"invoice_date\": \"03/13/2023\", \"license_plate\": \"PA-KMB5413\", \"payment_due\": \"$53.60\", \"due_date\": \"04/13/2023\",\"invoice_number\": \"124233968-1\", \"amount_due\": \"$53.60\",\"invoice_date\": \"03/13/2023\", \"account_number\": \"5526331\",\"amount_paid\": \"$\"}}',
    '{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"122041295-1\", \"account_number\": \"5526331\", \"invoice_date\": \"11/21/2022\", \"license_plate\": \"PA-KMB5413\", \"payment_due\": \"$52.80\", \"due_date\": \"12/12/2022\",\"invoice_number\": \"122041295-1\", \"amount_due\": \"$52.80\",\"invoice_date\": \"12/21/2023\", \"account_number\": \"5526331\",\"amount_paid\": \"$\"}}',
    '{\"header\": {\"to\": \"FEITH SYSTEMS AND SOFTWARE\",\"billing_address\": \"425 MARYLAND DR FT WASHINGTON PA 19034-2501\",\"invoice_number\": \"121314515-1\", \"account_number\": \"5526331\", \"invoice_date\": \"10/19/2022\", \"license_plate\": \"PA-KMB5413\", \"payment_due\": \"$8.70\", \"due_date\": \"11/08/2022\",\"invoice_number\": \"121314515-1\", \"amount_due\": \"$8.70\",\"invoice_date\": \"10/19/2022\", \"account_number\": \"5526331\",\"amount_paid\": \"$\"}}',
]

class EZPassTargz(datasets.GeneratorBasedBuilder):
    """ Builder script for the EZ-Pass Dataset"""
    
    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "text": datasets.Value("string"),
                    "image": datasets.Image(),
                }
            ),
            supervised_keys=None,
            homepage="https://hugginface.co/datasets/joemaatouk/EZPass-Dataset/",
            citation=_CITATION
        )

    def _split_generators(self, dl_manager):
        path = dl_manager.download(_URL)
        image_iters = dl_manager.iter_archive(path)

        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN, 
                gen_kwargs={"images": image_iters}),
        ]

    def _generate_examples(self, images):
        """This function returns the examples in the raw (text) form."""
        idx = 0
        for filepath, image in images:
            yield idx,{
                "text": descriptions[idx], 
                "image":{"path": filepath,"bytes":image.read()},     
            }
            idx += 1