Download tinydoc/schema.py from harryfrz/tinydoc-5m: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/harryfrz/tinydoc-5m/resolve/main/tinydoc/schema.py
- Command line
-
hf download hf://harryfrz/tinydoc-5m/tinydoc/schema.py
-
curl -L -o schema.py https://huggingface.co/harryfrz/tinydoc-5m/resolve/main/tinydoc/schema.py
1.6 kB
| """Label sets shared by the synthetic data generator, the extraction model and JSON assembly.""" | |
| FIELD_LABELS = [ | |
| "other", # decorative / irrelevant text | |
| "key", # a label such as "Total:" or "Invoice No." whose value is a separate segment | |
| "merchant_name", "merchant_address", "merchant_phone", "merchant_tax_id", | |
| "customer", # bill-to block on invoices | |
| "invoice_number", "date", "due_date", "time", | |
| "item_desc", "item_qty", "item_unit_price", "item_amount", | |
| "subtotal", "tax", "discount", "total", "amount_paid", "change", | |
| "heading", "paragraph", "list_item", "table_cell", | |
| "formula", # display maths: detected and skipped (not transcribed) | |
| ] | |
| LABEL_ID = {n: i for i, n in enumerate(FIELD_LABELS)} | |
| DOC_TYPES = ["receipt", "invoice", "general"] | |
| DOC_ID = {n: i for i, n in enumerate(DOC_TYPES)} | |
| # Pairwise relations between segments. | |
| # same_row: both segments belong to the same line item / table row (symmetric) | |
| # key_value: segment i is the key whose value is segment j (directed) | |
| # same_block: both segments belong to the same layout block (paragraph, list item, table, caption...) | |
| # New labels and relations are appended so older checkpoints load into the matching rows (train --init). | |
| REL_TYPES = ["same_row", "key_value", "same_block"] | |
| MONEY_FIELDS = {"item_unit_price", "item_amount", "subtotal", "tax", "discount", "total", "amount_paid", "change"} | |
| ITEM_FIELDS = {"item_desc", "item_qty", "item_unit_price", "item_amount"} | |
| STRUCTURE_LABELS = {"heading", "paragraph", "list_item", "table_cell", "formula"} | |