FR Energy Bill OCR Python
The Python OCR SDK supports the Energy Bill API.
The sample below can be used for testing purposes.
Quick-Start
from mindee import Client, product, AsyncPredictResponse
# Init a new client
mindee_client = Client(api_key="my-api-key")
# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
# Load a file from disk and enqueue it.
result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
product.fr.EnergyBillV1,
input_doc,
)
# Print a brief summary of the parsed data
print(result.document)
Field Types
Standard Fields
These fields are generic and used in several products.
BaseField
Each prediction object contains a set of fields that inherit from the generic BaseField
class.
A typical BaseField
object will have the following attributes:
- value (
Union[float, str]
): corresponds to the field value. Can beNone
if no value was extracted. - confidence (
float
): the confidence score of the field prediction. - bounding_box (
[Point, Point, Point, Point]
): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. - polygon (
List[Point]
): contains the relative vertices coordinates (Point
) of a polygon containing the field in the image. - page_id (
int
): the ID of the page, alwaysNone
when at document-level. - reconstructed (
bool
): indicates whether an object was reconstructed (not extracted as the API gave it).
Note: A
Point
simply refers to a List of two numbers ([float, float]
).
Aside from the previous attributes, all basic fields have access to a custom __str__
method that can be used to print their value as a string.
AmountField
The amount field AmountField
only has one constraint: its value is an Optional[float]
.
DateField
Aside from the basic BaseField
attributes, the date field DateField
also implements the following:
- date_object (
Date
): an accessible representation of the value as a python object. Can beNone
.
StringField
The text field StringField
only has one constraint: its value is an Optional[str]
.
Specific Fields
Fields which are specific to this product; they are not used in any other product.
Energy Consumer Field
The entity that consumes the energy.
A EnergyBillV1EnergyConsumer
implements the following attributes:
- address (
str
): The address of the energy consumer. - name (
str
): The name of the energy consumer.
Fields which are specific to this product; they are not used in any other product.
Energy Supplier Field
The company that supplies the energy.
A EnergyBillV1EnergySupplier
implements the following attributes:
- address (
str
): The address of the energy supplier. - name (
str
): The name of the energy supplier.
Fields which are specific to this product; they are not used in any other product.
Energy Usage Field
Details of energy consumption.
A EnergyBillV1EnergyUsage
implements the following attributes:
- description (
str
): Description or details of the energy usage. - end_date (
str
): The end date of the energy usage. - start_date (
str
): The start date of the energy usage. - tax_rate (
float
): The rate of tax applied to the total cost. - total (
float
): The total cost of energy consumed. - unit_price (
float
): The price per unit of energy consumed.
Fields which are specific to this product; they are not used in any other product.
Meter Details Field
Information about the energy meter.
A EnergyBillV1MeterDetail
implements the following attributes:
- meter_number (
str
): The unique identifier of the energy meter. - meter_type (
str
): The type of energy meter.
Possible values include:
- electricity
- gas
- water
- None
- unit (
str
): The unit of measurement for energy consumption, which can be kW, m³, or L.
Fields which are specific to this product; they are not used in any other product.
Subscription Field
The subscription details fee for the energy service.
A EnergyBillV1Subscription
implements the following attributes:
- description (
str
): Description or details of the subscription. - end_date (
str
): The end date of the subscription. - start_date (
str
): The start date of the subscription. - tax_rate (
float
): The rate of tax applied to the total cost. - total (
float
): The total cost of subscription. - unit_price (
float
): The price per unit of subscription.
Fields which are specific to this product; they are not used in any other product.
Taxes and Contributions Field
Details of Taxes and Contributions.
A EnergyBillV1TaxesAndContribution
implements the following attributes:
- description (
str
): Description or details of the Taxes and Contributions. - end_date (
str
): The end date of the Taxes and Contributions. - start_date (
str
): The start date of the Taxes and Contributions. - tax_rate (
float
): The rate of tax applied to the total cost. - total (
float
): The total cost of Taxes and Contributions. - unit_price (
float
): The price per unit of Taxes and Contributions.
Attributes
The following fields are extracted for Energy Bill V1:
Contract ID
contract_id (StringField): The unique identifier associated with a specific contract.
print(result.document.inference.prediction.contract_id.value)
Delivery Point
delivery_point (StringField): The unique identifier assigned to each electricity or gas consumption point. It specifies the exact location where the energy is delivered.
print(result.document.inference.prediction.delivery_point.value)
Due Date
due_date (DateField): The date by which the payment for the energy invoice is due.
print(result.document.inference.prediction.due_date.value)
Energy Consumer
energy_consumer (EnergyBillV1EnergyConsumer): The entity that consumes the energy.
print(result.document.inference.prediction.energy_consumer.value)
Energy Supplier
energy_supplier (EnergyBillV1EnergySupplier): The company that supplies the energy.
print(result.document.inference.prediction.energy_supplier.value)
Energy Usage
energy_usage (List[EnergyBillV1EnergyUsage]): Details of energy consumption.
for energy_usage_elem in result.document.inference.prediction.energy_usage:
print(energy_usage_elem.value)
Invoice Date
invoice_date (DateField): The date when the energy invoice was issued.
print(result.document.inference.prediction.invoice_date.value)
Invoice Number
invoice_number (StringField): The unique identifier of the energy invoice.
print(result.document.inference.prediction.invoice_number.value)
Meter Details
meter_details (EnergyBillV1MeterDetail): Information about the energy meter.
print(result.document.inference.prediction.meter_details.value)
Subscription
subscription (List[EnergyBillV1Subscription]): The subscription details fee for the energy service.
for subscription_elem in result.document.inference.prediction.subscription:
print(subscription_elem.value)
Taxes and Contributions
taxes_and_contributions (List[EnergyBillV1TaxesAndContribution]): Details of Taxes and Contributions.
for taxes_and_contributions_elem in result.document.inference.prediction.taxes_and_contributions:
print(taxes_and_contributions_elem.value)
Total Amount
total_amount (AmountField): The total amount to be paid for the energy invoice.
print(result.document.inference.prediction.total_amount.value)
Total Before Taxes
total_before_taxes (AmountField): The total amount to be paid for the energy invoice before taxes.
print(result.document.inference.prediction.total_before_taxes.value)
Total Taxes
total_taxes (AmountField): Total of taxes applied to the invoice.
print(result.document.inference.prediction.total_taxes.value)
Questions?
Updated 22 days ago