flexsds 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flexsds/__init__.py +4 -0
- flexsds/assets/ptit_logo.png +0 -0
- flexsds/cli/__init__.py +1 -0
- flexsds/cli/banner.py +84 -0
- flexsds/cli/main.py +330 -0
- flexsds/cli/output.py +69 -0
- flexsds/cli/task_runner.py +171 -0
- flexsds/cli/wizard.py +360 -0
- flexsds/client/__init__.py +4 -0
- flexsds/client/chat.py +137 -0
- flexsds/client/client.py +107 -0
- flexsds/client/monitor.py +95 -0
- flexsds/core/__init__.py +44 -0
- flexsds/core/compatibility.py +442 -0
- flexsds/core/controller.py +502 -0
- flexsds/core/cost_model.py +530 -0
- flexsds/core/credentials.py +111 -0
- flexsds/core/hardware.py +77 -0
- flexsds/core/tree_topology.py +296 -0
- flexsds/profiles/profile_sm75_t4.json +62 -0
- flexsds/profiles/profile_sm89_l4.json +194 -0
- flexsds/server/__init__.py +1 -0
- flexsds/server/colab_runner.py +62 -0
- flexsds/server/local_runner.py +208 -0
- flexsds/server/modal_app.py +50 -0
- flexsds/server/modal_runner.py +98 -0
- flexsds/server/vscode_cli.py +82 -0
- flexsds-0.2.0.dist-info/METADATA +204 -0
- flexsds-0.2.0.dist-info/RECORD +62 -0
- flexsds-0.2.0.dist-info/WHEEL +5 -0
- flexsds-0.2.0.dist-info/entry_points.txt +2 -0
- flexsds-0.2.0.dist-info/top_level.txt +4 -0
- pipeline/entity_eval.py +171 -0
- pipeline/examples/node1_extractor_input_m0_04_001.txt +9 -0
- pipeline/examples/node1_extractor_output_m0_04_001.json +90 -0
- pipeline/extractor.py +502 -0
- pipeline/invoice_models.py +163 -0
- pipeline/node2_questions.py +30 -0
- pipeline/openai_compatible.py +87 -0
- pipeline/prompts/README.md +18 -0
- pipeline/prompts/node1_extractor_system.md +92 -0
- pipeline/prompts/node3_report_user.md +5 -0
- pipeline/report_writer.py +143 -0
- pipeline/schemas/invoice_extraction.schema.json +469 -0
- pipeline/sql_guard.py +140 -0
- pipeline/sqlite/schema.sql +219 -0
- pipeline/text_to_sql.py +170 -0
- pipeline/validation.py +166 -0
- pipeline/w1_workload.py +139 -0
- proposer/__init__.py +31 -0
- proposer/adapter.py +153 -0
- proposer/controller.py +460 -0
- proposer/cost_model.py +216 -0
- proposer/tree_adaptive.py +466 -0
- server/__init__.py +3 -0
- server/adaptive_scheduler.py +215 -0
- server/budget_planner.py +287 -0
- server/lineage.py +290 -0
- server/lineage_diagnostics.py +38 -0
- server/lineage_executor.py +129 -0
- server/lineage_startup.py +47 -0
- server/t4_rowwise_attention.py +262 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
flexsds/__init__.py,sha256=LY5oq3VR6dlnmIKINJOIV-g4ue2PMlfxeNMqLVghi5s,153
|
|
2
|
+
flexsds/assets/ptit_logo.png,sha256=fbrHXSc47XCHmbRC8ToaHxWlMX2UL-xD5i9b1G1Bqvs,62492
|
|
3
|
+
flexsds/cli/__init__.py,sha256=JFfrOxMcdYOUynLcNQPrwCT2-CKnG3xT4YedfdqD1sQ,26
|
|
4
|
+
flexsds/cli/banner.py,sha256=ZYdhX7E-H492RaxF3_xQQnUKv3huKShgy_VyMgkM5fo,10511
|
|
5
|
+
flexsds/cli/main.py,sha256=95PPnJ1ixixFtRkbjH9YUl7NA5-PiGc1lka0Z6Xo6kU,14660
|
|
6
|
+
flexsds/cli/output.py,sha256=o3WKyflVAC1Mwq33euNc5bq7KjM91YsKOjpeXvsYoBk,2428
|
|
7
|
+
flexsds/cli/task_runner.py,sha256=owACv_kEo68IUHRMpYp-Bfsu377eZQ_VCFklNrpiU7A,6856
|
|
8
|
+
flexsds/cli/wizard.py,sha256=rST0fBs0s5FMw-jeh78Cw18h3F2Yh8QxBA712bmLyAI,14069
|
|
9
|
+
flexsds/client/__init__.py,sha256=PaoITiZuGbOeQbsbpuOHgi_0lSE9RhZGjIAR3yzpEY0,161
|
|
10
|
+
flexsds/client/chat.py,sha256=lDHT4CvbgDiOKC3-sKfkrgCtMKpf6UHNHG8juvw8u18,5451
|
|
11
|
+
flexsds/client/client.py,sha256=NtMLjT81ek_VnwNp6JYb7TbkYhOukMC_cySTm-Q_EZ0,4021
|
|
12
|
+
flexsds/client/monitor.py,sha256=AHO9Hf0TPAR0xddp-ekTNtFAnnIuhvSvG_8BfrhNwaQ,3500
|
|
13
|
+
flexsds/core/__init__.py,sha256=d5m5JnSqFjdPHwik9nZ875Scv_lsnAoCB1Ohq2XKUl4,1131
|
|
14
|
+
flexsds/core/compatibility.py,sha256=AFQK3WzyU4HjzRcJcLGudGWsgke0-9J92d27S6wG0Zw,17770
|
|
15
|
+
flexsds/core/controller.py,sha256=UwwyIIAFezs3dS4aDIygWRrvAHSa7NLZP0M1rl96PmU,20464
|
|
16
|
+
flexsds/core/cost_model.py,sha256=5ux4E0yNxFPD6_mPPVrSmQfnkWVYhpjaxKDoAV29f0Q,19980
|
|
17
|
+
flexsds/core/credentials.py,sha256=yOXij3IxEKvFYD8niMl-FiFpmbF-C8Mse-7PI5PvXNQ,3875
|
|
18
|
+
flexsds/core/hardware.py,sha256=nx9JDt7hSe4fGrAT-QyxOIG4nxCH7ITMisDAeKhFww4,2403
|
|
19
|
+
flexsds/core/tree_topology.py,sha256=L3bIlVfIojsAlk1C1qdT07MxiHgK15Q7szr1qWsI7Zo,11819
|
|
20
|
+
flexsds/profiles/profile_sm75_t4.json,sha256=XlpWNoGAcbFK_xwgsHEVaP06KXKHkaTYM-4r2IXvszo,1189
|
|
21
|
+
flexsds/profiles/profile_sm89_l4.json,sha256=hlx7UwPCoZhlOJPDXEBXABzdzcF_37nue4DJE8Ypwho,3800
|
|
22
|
+
flexsds/server/__init__.py,sha256=kW9BF2b8C1_yETUHLVQL5oaqxzXeVy6hW1GkoEWY_r8,39
|
|
23
|
+
flexsds/server/colab_runner.py,sha256=lBixbSlMA9bGcze0swosAVjLMexUIpH-0T5jsOmFoUI,2773
|
|
24
|
+
flexsds/server/local_runner.py,sha256=haWHq6cKMZzR36ziPAoTw78dhlPTaZ0IUAHRPSFbP5Y,8246
|
|
25
|
+
flexsds/server/modal_app.py,sha256=TND6RN1gk7NNS8_sSp1zJ3xzqkrPtZPi9JiEDzt4UdM,2030
|
|
26
|
+
flexsds/server/modal_runner.py,sha256=FcODz7kPdxWT4GyE_cwKcx-GjQT6iHOfLI2UxkUeRls,4251
|
|
27
|
+
flexsds/server/vscode_cli.py,sha256=7gRwGgOzVWedVsZ979ceG38DAIkt5iBiPM16uvlCUoo,2651
|
|
28
|
+
pipeline/entity_eval.py,sha256=ZgLm4M-PaOiBRemPjQAj7pfrKqNXBjyxB2o3aVQDJ_M,6527
|
|
29
|
+
pipeline/extractor.py,sha256=kRei_v2v2an0imK0xsJ5BEgtMIzT3JuVTQv1S0sb-Iw,16780
|
|
30
|
+
pipeline/invoice_models.py,sha256=H1E_0H86ilkfZQ4oBgmFAN9-ri4fjU1K5yxqNQPsp1I,5735
|
|
31
|
+
pipeline/node2_questions.py,sha256=VjHeynO3__xiMf2mH507vE24nntmuT-8uf83V0INlLY,1104
|
|
32
|
+
pipeline/openai_compatible.py,sha256=Im73HHegCn1Emw0JbQ-CaO-_tS1G5yLHiAqtS-97Ha4,3453
|
|
33
|
+
pipeline/report_writer.py,sha256=iWsPd6Lcckz6mAbkMGCUtBzHlpOcIRL5m9AyhnsRb9Q,4957
|
|
34
|
+
pipeline/sql_guard.py,sha256=ka9DZbfjUqJQtUS2AN0LzFKeFJvh3lEh9C7dZ6dOOgA,4604
|
|
35
|
+
pipeline/text_to_sql.py,sha256=AV1xAtfORXuRgORt8vVWlHFZiWmeP-1cl-i05EyQT-U,6096
|
|
36
|
+
pipeline/validation.py,sha256=Gz_8AQ3Yiqqd3i-odc9MguOfkhitkjAgJJ8BccCVSLk,6039
|
|
37
|
+
pipeline/w1_workload.py,sha256=WLmmSbonHULVFB5l37DKeaZAe4ijq9DBr4vpR7Rlrfs,5010
|
|
38
|
+
pipeline/examples/node1_extractor_input_m0_04_001.txt,sha256=4YfzAXu3jXRx2tduxrOz3XCDB28deMVyyjg056PuraY,277
|
|
39
|
+
pipeline/examples/node1_extractor_output_m0_04_001.json,sha256=crjsgtARRAJevQcUNSSfUJchblUZ1HzHoUj-5jJ2054,2187
|
|
40
|
+
pipeline/prompts/README.md,sha256=DvVum2XkuMBU68SPK4lHzwXsKZVkjCnXsK4YXW_JEUg,598
|
|
41
|
+
pipeline/prompts/node1_extractor_system.md,sha256=NFLHfaOmSFyOkuNx8oYayrnsZCS75SR3pXk0Wn6Q-Nk,5268
|
|
42
|
+
pipeline/prompts/node3_report_user.md,sha256=YllCauv2bPe1j7Ys1KQOJoea0hp10yv8usoidbx5_y0,868
|
|
43
|
+
pipeline/schemas/invoice_extraction.schema.json,sha256=C68Buy2YrkCqCedZXlyfRA4Ni-wLnM3dgL6aSna2Drc,10338
|
|
44
|
+
pipeline/sqlite/schema.sql,sha256=D1AqWxEK-EohAIcOPC1PXv9bAqQzd9ZMQFgUv3NbQ6k,7677
|
|
45
|
+
proposer/__init__.py,sha256=exgaB2YP_lK93JfidC1SVKWAfeO8SHPGyfKT4LZS1eU,861
|
|
46
|
+
proposer/adapter.py,sha256=Ujcst09HBLE_nqM_yUXh-re_rMIHt7GBLhwvDqJNLGc,5452
|
|
47
|
+
proposer/controller.py,sha256=smZiI6W08izdsVtCK0nHtwsSy6u8W49MduTeusoiHfQ,18225
|
|
48
|
+
proposer/cost_model.py,sha256=5QUFVzNCZ6UiBbss35qXFZE1MrVAcdE-sto0-ehTzl8,8948
|
|
49
|
+
proposer/tree_adaptive.py,sha256=4Laii_GXnJCCczTISX1uXg30yXaFPwN1gkVwkvj6DKE,20318
|
|
50
|
+
server/__init__.py,sha256=oUqQ_TNccSlKk5Bbi5vzKL-YmiFJ0dUczT3dp6rS0J4,119
|
|
51
|
+
server/adaptive_scheduler.py,sha256=IP73o_jRcHwJl2dv2xnyH_EWRkVkbg8jCvb51I5o5wU,10392
|
|
52
|
+
server/budget_planner.py,sha256=K_yqvdLzm24f7JVwuswuGtmFTeEBZEMsFwBzly6fua0,14347
|
|
53
|
+
server/lineage.py,sha256=kB7ktIcGZVoEmwluCzl220mIo6eziN7UOJT7SuOzaIk,12851
|
|
54
|
+
server/lineage_diagnostics.py,sha256=yCP865wpMeGl-XO9nBwoPols4bBFpUs-weQUOnVEq9Q,1543
|
|
55
|
+
server/lineage_executor.py,sha256=AARPigIbx8m2HOnPo1Q7rgc--AzwUsbkX83rva3U7R0,5765
|
|
56
|
+
server/lineage_startup.py,sha256=7kXF7K1O0LEfABlcOU4MBxHPcDnfMvRhCY1Xm4IOsYw,2117
|
|
57
|
+
server/t4_rowwise_attention.py,sha256=Igj-r6hedHmnjyHUE8DgZcbpQ03KFi33kDwY8taslDE,12797
|
|
58
|
+
flexsds-0.2.0.dist-info/METADATA,sha256=mwoPE_geVssQXacIINr5oGL6jqFAcaoqa-7u-bGZ-Hk,15378
|
|
59
|
+
flexsds-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
60
|
+
flexsds-0.2.0.dist-info/entry_points.txt,sha256=m3RMvP8YOCji5scZOk7Vab9jyHzsN_qvq4lxYNWrHsM,50
|
|
61
|
+
flexsds-0.2.0.dist-info/top_level.txt,sha256=0Ik-D3Sl3y_ivoDNekA8NuC8awlYnOVis9Fbx-wFAgk,33
|
|
62
|
+
flexsds-0.2.0.dist-info/RECORD,,
|
pipeline/entity_eval.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"""Score Node 1 JSON against MC-OCR labels (pure functions, no file access).
|
|
2
|
+
|
|
3
|
+
Labels come from ``key_text_pairs`` in the M0-04 dev-set. They stay outside the
|
|
4
|
+
model prompt (see src/pipeline/README.md) and are used here for evaluation only.
|
|
5
|
+
The labels are raw receipt text, so each field is normalized before comparison:
|
|
6
|
+
|
|
7
|
+
SELLER <-> seller.name
|
|
8
|
+
ADDRESS <-> seller.address
|
|
9
|
+
TIMESTAMPS <-> invoice.issued_date (and issued_time when the label has a time)
|
|
10
|
+
TOTAL_COST <-> totals.total_amount.value
|
|
11
|
+
|
|
12
|
+
Vietnamese diacritics are kept on purpose: removing them would hide real errors.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
import unicodedata
|
|
19
|
+
from collections import Counter
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from datetime import date
|
|
22
|
+
from typing import Any
|
|
23
|
+
|
|
24
|
+
MATCH = "match"
|
|
25
|
+
MISMATCH = "mismatch"
|
|
26
|
+
BLANK = "blank" # labelled field, but the model returned nothing
|
|
27
|
+
UNSCORED = "unscored" # the label itself could not be parsed
|
|
28
|
+
NO_LABEL = "no_label" # the sample has no label for this field
|
|
29
|
+
|
|
30
|
+
FIELDS = ("SELLER", "ADDRESS", "TIMESTAMPS", "TOTAL_COST")
|
|
31
|
+
AMOUNT_TOLERANCE = 0.5
|
|
32
|
+
|
|
33
|
+
_ADDRESS_PREFIX_RE = re.compile(r"^(?:đc|đ/c|địa chỉ)\s*:\s*", re.IGNORECASE)
|
|
34
|
+
_DATE_RE = re.compile(r"(?<!\d)(\d{1,2})[/.\-](\d{1,2})[/.\-](\d{4})(?!\d)")
|
|
35
|
+
_TIME_RE = re.compile(r"(?<![\d.:])(\d{1,2})[:.](\d{2})(?!\d)")
|
|
36
|
+
_AMOUNT_RE = re.compile(r"\d+(?:[.,\s]\d{3})*(?:[.,]\d{2})?")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass(frozen=True)
|
|
40
|
+
class FieldScore:
|
|
41
|
+
status: str
|
|
42
|
+
f1: float | None = None
|
|
43
|
+
date_ok: bool | None = None
|
|
44
|
+
time_ok: bool | None = None
|
|
45
|
+
gold: str | None = None
|
|
46
|
+
predicted: Any = None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def normalize_text(text: str | None) -> str:
|
|
50
|
+
"""NFC, lower case, punctuation to spaces, single spaces; diacritics kept."""
|
|
51
|
+
folded = unicodedata.normalize("NFC", text or "").lower()
|
|
52
|
+
return " ".join(re.sub(r"[^\w\s]", " ", folded).split())
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def token_f1(gold: str | None, predicted: str | None) -> float:
|
|
56
|
+
gold_tokens = normalize_text(gold).split()
|
|
57
|
+
predicted_tokens = normalize_text(predicted).split()
|
|
58
|
+
if not gold_tokens or not predicted_tokens:
|
|
59
|
+
return 0.0
|
|
60
|
+
common = sum((Counter(gold_tokens) & Counter(predicted_tokens)).values())
|
|
61
|
+
if common == 0:
|
|
62
|
+
return 0.0
|
|
63
|
+
precision = common / len(predicted_tokens)
|
|
64
|
+
recall = common / len(gold_tokens)
|
|
65
|
+
return 2 * precision * recall / (precision + recall)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def parse_date(text: str) -> str | None:
|
|
69
|
+
"""First real ``dd/mm/yyyy`` (also ``-`` or ``.``) as ``YYYY-MM-DD``."""
|
|
70
|
+
for day, month, year in _DATE_RE.findall(text):
|
|
71
|
+
try:
|
|
72
|
+
return date(int(year), int(month), int(day)).isoformat()
|
|
73
|
+
except ValueError:
|
|
74
|
+
continue
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def parse_time(text: str) -> str | None:
|
|
79
|
+
"""First real ``HH:MM`` (also ``HH.MM``) outside a date, as ``HH:MM``."""
|
|
80
|
+
for hour, minute in _TIME_RE.findall(_DATE_RE.sub(" ", text)):
|
|
81
|
+
if int(hour) < 24 and int(minute) < 60:
|
|
82
|
+
return f"{int(hour):02d}:{minute}"
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _amount_value(token: str) -> float:
|
|
87
|
+
integer, decimals = token, "0"
|
|
88
|
+
if len(token) > 3 and token[-3] in ".,":
|
|
89
|
+
integer, decimals = token[:-3], token[-2:]
|
|
90
|
+
digits = re.sub(r"\D", "", integer)
|
|
91
|
+
return float(f"{digits}.{decimals}")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def parse_amounts(text: str) -> list[float]:
|
|
95
|
+
"""Every amount in one label line; thousands use ``,`` ``.`` or a space."""
|
|
96
|
+
return [_amount_value(token) for token in _AMOUNT_RE.findall(text)]
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _strip_address_prefix(text: str) -> str:
|
|
100
|
+
return _ADDRESS_PREFIX_RE.sub("", unicodedata.normalize("NFC", text).strip())
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _score_text(lines: list[str], predicted: Any, *, address: bool = False) -> FieldScore:
|
|
104
|
+
if not lines:
|
|
105
|
+
return FieldScore(NO_LABEL)
|
|
106
|
+
gold = " ".join(lines)
|
|
107
|
+
if not isinstance(predicted, str) or not predicted.strip():
|
|
108
|
+
return FieldScore(BLANK, f1=0.0, gold=gold, predicted=predicted)
|
|
109
|
+
gold_text = _strip_address_prefix(gold) if address else gold
|
|
110
|
+
predicted_text = _strip_address_prefix(predicted) if address else predicted
|
|
111
|
+
exact = normalize_text(gold_text) == normalize_text(predicted_text)
|
|
112
|
+
return FieldScore(
|
|
113
|
+
MATCH if exact else MISMATCH,
|
|
114
|
+
f1=token_f1(gold_text, predicted_text),
|
|
115
|
+
gold=gold,
|
|
116
|
+
predicted=predicted,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _score_timestamps(lines: list[str], issued_date: Any, issued_time: Any) -> FieldScore:
|
|
121
|
+
if not lines:
|
|
122
|
+
return FieldScore(NO_LABEL)
|
|
123
|
+
gold = " ".join(lines)
|
|
124
|
+
gold_date = parse_date(gold)
|
|
125
|
+
if gold_date is None:
|
|
126
|
+
return FieldScore(UNSCORED, gold=gold, predicted=issued_date)
|
|
127
|
+
if not issued_date:
|
|
128
|
+
return FieldScore(BLANK, gold=gold, predicted=issued_date)
|
|
129
|
+
date_ok = issued_date == gold_date
|
|
130
|
+
gold_time = parse_time(gold)
|
|
131
|
+
time_ok = None if gold_time is None else str(issued_time or "").startswith(gold_time)
|
|
132
|
+
return FieldScore(
|
|
133
|
+
MATCH if date_ok and time_ok is not False else MISMATCH,
|
|
134
|
+
date_ok=date_ok,
|
|
135
|
+
time_ok=time_ok,
|
|
136
|
+
gold=gold,
|
|
137
|
+
predicted=f"{issued_date} {issued_time}",
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _score_total(lines: list[str], predicted: Any) -> FieldScore:
|
|
142
|
+
if not lines:
|
|
143
|
+
return FieldScore(NO_LABEL)
|
|
144
|
+
gold = " ".join(lines)
|
|
145
|
+
amounts = [amount for line in lines for amount in parse_amounts(line)]
|
|
146
|
+
if not amounts:
|
|
147
|
+
return FieldScore(UNSCORED, gold=gold, predicted=predicted)
|
|
148
|
+
if predicted is None:
|
|
149
|
+
return FieldScore(BLANK, gold=gold, predicted=predicted)
|
|
150
|
+
matched = any(abs(float(predicted) - amount) <= AMOUNT_TOLERANCE for amount in amounts)
|
|
151
|
+
return FieldScore(MATCH if matched else MISMATCH, gold=gold, predicted=predicted)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _lines(pairs: list[dict[str, str]], label: str) -> list[str]:
|
|
155
|
+
return [pair["text"] for pair in pairs if pair.get("label") == label and pair.get("text")]
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def score_sample(payload: dict[str, Any] | None, pairs: list[dict[str, str]]) -> dict[str, FieldScore]:
|
|
159
|
+
"""Score one sample; ``payload=None`` means the run has no valid JSON for it."""
|
|
160
|
+
data = payload or {}
|
|
161
|
+
seller = data.get("seller") or {}
|
|
162
|
+
invoice = data.get("invoice") or {}
|
|
163
|
+
total = (data.get("totals") or {}).get("total_amount") or {}
|
|
164
|
+
return {
|
|
165
|
+
"SELLER": _score_text(_lines(pairs, "SELLER"), seller.get("name")),
|
|
166
|
+
"ADDRESS": _score_text(_lines(pairs, "ADDRESS"), seller.get("address"), address=True),
|
|
167
|
+
"TIMESTAMPS": _score_timestamps(
|
|
168
|
+
_lines(pairs, "TIMESTAMPS"), invoice.get("issued_date"), invoice.get("issued_time")
|
|
169
|
+
),
|
|
170
|
+
"TOTAL_COST": _score_total(_lines(pairs, "TOTAL_COST"), total.get("value")),
|
|
171
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
SOURCE_METADATA:
|
|
2
|
+
{"sample_id": "m0_04_001", "img_id": "mcocr_public_145013tlipr.jpg", "image_path": "data/processed/m0_04_mcocr_devset/images/mcocr_public_145013tlipr.jpg"}
|
|
3
|
+
|
|
4
|
+
OCR_TEXT:
|
|
5
|
+
MINIMART ANAN
|
|
6
|
+
Chợ Sủi Phú Thị Gia Lâm
|
|
7
|
+
Ngày: 10/08/2020 - 17:12
|
|
8
|
+
Tổng tiền
|
|
9
|
+
42,000
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "invoice_extraction.v1",
|
|
3
|
+
"document_type": "retail_receipt",
|
|
4
|
+
"source": {
|
|
5
|
+
"sample_id": "m0_04_001",
|
|
6
|
+
"img_id": "mcocr_public_145013tlipr.jpg",
|
|
7
|
+
"image_path": "data/processed/m0_04_mcocr_devset/images/mcocr_public_145013tlipr.jpg",
|
|
8
|
+
"raw_text": "MINIMART ANAN\nChợ Sủi Phú Thị Gia Lâm\nNgày: 10/08/2020 - 17:12\nTổng tiền\n42,000"
|
|
9
|
+
},
|
|
10
|
+
"seller": {
|
|
11
|
+
"name": "MINIMART ANAN",
|
|
12
|
+
"address": "Chợ Sủi Phú Thị Gia Lâm",
|
|
13
|
+
"tax_code": null,
|
|
14
|
+
"phone": null
|
|
15
|
+
},
|
|
16
|
+
"buyer": {
|
|
17
|
+
"name": null,
|
|
18
|
+
"address": null,
|
|
19
|
+
"tax_code": null,
|
|
20
|
+
"phone": null
|
|
21
|
+
},
|
|
22
|
+
"invoice": {
|
|
23
|
+
"invoice_number": null,
|
|
24
|
+
"invoice_series": null,
|
|
25
|
+
"issued_at": "2020-08-10T17:12:00",
|
|
26
|
+
"issued_date": "2020-08-10",
|
|
27
|
+
"issued_time": "17:12:00",
|
|
28
|
+
"currency": "VND",
|
|
29
|
+
"payment_method": null
|
|
30
|
+
},
|
|
31
|
+
"totals": {
|
|
32
|
+
"subtotal": {
|
|
33
|
+
"raw": null,
|
|
34
|
+
"value": null,
|
|
35
|
+
"currency": "VND"
|
|
36
|
+
},
|
|
37
|
+
"discount": {
|
|
38
|
+
"raw": null,
|
|
39
|
+
"value": null,
|
|
40
|
+
"currency": "VND"
|
|
41
|
+
},
|
|
42
|
+
"vat_amount": {
|
|
43
|
+
"raw": null,
|
|
44
|
+
"value": null,
|
|
45
|
+
"currency": "VND"
|
|
46
|
+
},
|
|
47
|
+
"total_amount": {
|
|
48
|
+
"raw": "42,000",
|
|
49
|
+
"value": 42000,
|
|
50
|
+
"currency": "VND"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"taxes": [],
|
|
54
|
+
"items": [],
|
|
55
|
+
"extraction": {
|
|
56
|
+
"status": "partial",
|
|
57
|
+
"confidence": 0.82,
|
|
58
|
+
"missing_fields": [
|
|
59
|
+
"seller.tax_code",
|
|
60
|
+
"invoice.invoice_number",
|
|
61
|
+
"taxes",
|
|
62
|
+
"items"
|
|
63
|
+
],
|
|
64
|
+
"warnings": [
|
|
65
|
+
"MC-OCR annotation exposes key receipt fields only; item rows and VAT details are unavailable for this sample."
|
|
66
|
+
],
|
|
67
|
+
"field_evidence": [
|
|
68
|
+
{
|
|
69
|
+
"field_path": "seller.name",
|
|
70
|
+
"raw_text": "MINIMART ANAN",
|
|
71
|
+
"source_label": "SELLER"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"field_path": "seller.address",
|
|
75
|
+
"raw_text": "Chợ Sủi Phú Thị Gia Lâm",
|
|
76
|
+
"source_label": "ADDRESS"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"field_path": "invoice.issued_at",
|
|
80
|
+
"raw_text": "Ngày: 10/08/2020 - 17:12",
|
|
81
|
+
"source_label": "TIMESTAMPS"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"field_path": "totals.total_amount",
|
|
85
|
+
"raw_text": "Tổng tiền\n42,000",
|
|
86
|
+
"source_label": "TOTAL_COST"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|