-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpayslip_v2.py
More file actions
39 lines (32 loc) · 1.18 KB
/
payslip_v2.py
File metadata and controls
39 lines (32 loc) · 1.18 KB
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
from typing import List
from mindee.parsing.common.inference import Inference
from mindee.parsing.common.page import Page
from mindee.parsing.common.string_dict import StringDict
from mindee.product.fr.payslip.payslip_v2_document import (
PayslipV2Document,
)
class PayslipV2(Inference):
"""Payslip API version 2 inference prediction."""
prediction: PayslipV2Document
"""Document-level prediction."""
pages: List[Page[PayslipV2Document]]
"""Page-level prediction(s)."""
endpoint_name = "payslip_fra"
"""Name of the endpoint."""
endpoint_version = "2"
"""Version of the endpoint."""
def __init__(self, raw_prediction: StringDict):
"""
Payslip v2 inference.
:param raw_prediction: Raw prediction from the HTTP response.
"""
super().__init__(raw_prediction)
self.prediction = PayslipV2Document(raw_prediction["prediction"])
self.pages = []
for page in raw_prediction["pages"]:
try:
page_prediction = page["prediction"]
except KeyError:
continue
if page_prediction:
self.pages.append(Page(PayslipV2Document, page))