mindee 3.11.0 → 3.13.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +27 -0
- data/README.md +23 -23
- data/Rakefile +5 -0
- data/bin/mindee.rb +7 -1
- data/docs/bank_account_details_v2.md +5 -1
- data/docs/bank_check_v1.md +6 -2
- data/docs/bank_statement_fr_v1.md +3 -0
- data/docs/barcode_reader_v1.md +5 -1
- data/docs/bill_of_lading_v1.md +202 -0
- data/docs/carte_grise_v1.md +5 -1
- data/docs/carte_vitale_v1.md +5 -1
- data/docs/code_samples/bill_of_lading_v1_async.txt +19 -0
- data/docs/code_samples/energy_bill_fra_v1_async.txt +19 -0
- data/docs/code_samples/financial_document_v1_async.txt +19 -0
- data/docs/code_samples/invoices_v4_async.txt +19 -0
- data/docs/code_samples/nutrition_facts_v1_async.txt +19 -0
- data/docs/code_samples/payslip_fra_v2_async.txt +19 -0
- data/docs/code_samples/us_healthcare_cards_v1_async.txt +19 -0
- data/docs/cropper_v1.md +6 -2
- data/docs/custom_v1.md +5 -3
- data/docs/energy_bill_fra_v1.md +249 -0
- data/docs/eu_driver_license_v1.md +6 -2
- data/docs/expense_receipts_v5.md +38 -11
- data/docs/financial_document_v1.md +80 -23
- data/docs/generated_v1.md +3 -0
- data/docs/getting_started.md +3 -0
- data/docs/idcard_fr_v2.md +15 -2
- data/docs/international_id_v2.md +13 -1
- data/docs/invoice_splitter_v1.md +16 -13
- data/docs/invoices_v4.md +57 -23
- data/docs/license_plates_v1.md +5 -1
- data/docs/multi_receipts_detector_v1.md +5 -1
- data/docs/nutrition_facts_v1.md +295 -0
- data/docs/passport_v1.md +5 -1
- data/docs/payslip_fra_v2.md +218 -0
- data/docs/proof_of_address_v1.md +5 -1
- data/docs/resume_v1.md +24 -1
- data/docs/us_driver_license_v1.md +6 -2
- data/docs/us_healthcare_cards_v1.md +208 -0
- data/docs/us_mail_v2.md +5 -1
- data/docs/us_w9_v1.md +6 -2
- data/examples/auto_invoice_splitter_extraction.rb +43 -0
- data/lib/mindee/client.rb +20 -8
- data/lib/mindee/extraction/common/extracted_image.rb +73 -0
- data/lib/mindee/extraction/common/image_extractor.rb +189 -0
- data/lib/mindee/extraction/common.rb +4 -0
- data/lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb +26 -0
- data/lib/mindee/extraction/multi_receipts_extractor.rb +3 -0
- data/lib/mindee/extraction/pdf_extractor/extracted_pdf.rb +55 -0
- data/lib/mindee/extraction/pdf_extractor/pdf_extractor.rb +111 -0
- data/lib/mindee/extraction/pdf_extractor.rb +4 -0
- data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +322 -0
- data/lib/mindee/extraction/tax_extractor.rb +1 -320
- data/lib/mindee/extraction.rb +3 -0
- data/lib/mindee/http/endpoint.rb +18 -6
- data/lib/mindee/input/sources.rb +8 -0
- data/lib/mindee/parsing/common/api_response.rb +1 -1
- data/lib/mindee/parsing/common/document.rb +31 -1
- data/lib/mindee/parsing/common/extras/cropper_extra.rb +29 -0
- data/lib/mindee/parsing/common/extras/extras.rb +50 -0
- data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +32 -0
- data/lib/mindee/parsing/common/extras.rb +5 -0
- data/lib/mindee/parsing/common/page.rb +5 -0
- data/lib/mindee/parsing/standard/base_field.rb +1 -0
- data/lib/mindee/parsing/standard/company_registration_field.rb +17 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +39 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +52 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +95 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +58 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +136 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +58 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +32 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +58 -0
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +3 -1
- data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +22 -1
- data/lib/mindee/product/financial_document/financial_document_v1_page.rb +1 -1
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +4 -15
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +41 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +235 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +48 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +48 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +97 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +54 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +34 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +97 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +97 -0
- data/lib/mindee/product/fr/payslip/payslip_v2.rb +41 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +54 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +128 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +72 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +34 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +100 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +66 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +56 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +81 -0
- data/lib/mindee/product/international_id/international_id_v2_document.rb +1 -1
- data/lib/mindee/product/international_id/international_id_v2_page.rb +1 -1
- data/lib/mindee/product/invoice/invoice_v4_document.rb +3 -1
- data/lib/mindee/product/invoice/invoice_v4_line_item.rb +22 -1
- data/lib/mindee/product/invoice/invoice_v4_page.rb +1 -1
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +1 -1
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +1 -1
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +1 -1
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +39 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +173 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +87 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +32 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +46 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +58 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +52 -0
- data/lib/mindee/product/receipt/receipt_v5_document.rb +1 -1
- data/lib/mindee/product/receipt/receipt_v5_line_item.rb +11 -1
- data/lib/mindee/product/receipt/receipt_v5_page.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_certificate.rb +11 -1
- data/lib/mindee/product/resume/resume_v1_education.rb +14 -1
- data/lib/mindee/product/resume/resume_v1_language.rb +9 -1
- data/lib/mindee/product/resume/resume_v1_professional_experience.rb +15 -1
- data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +9 -1
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1.rb +41 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +65 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +127 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +34 -0
- data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +14 -1
- data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +5 -17
- data/lib/mindee/product.rb +6 -1
- data/lib/mindee/version.rb +1 -1
- data/mindee.gemspec +1 -0
- metadata +91 -3
- /data/lib/mindee/extraction/{ocr_extractor.rb → tax_extractor/ocr_extractor.rb} +0 -0
@@ -0,0 +1,173 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
require_relative 'nutrition_facts_label_v1_serving_size'
|
5
|
+
require_relative 'nutrition_facts_label_v1_calorie'
|
6
|
+
require_relative 'nutrition_facts_label_v1_total_fat'
|
7
|
+
require_relative 'nutrition_facts_label_v1_saturated_fat'
|
8
|
+
require_relative 'nutrition_facts_label_v1_trans_fat'
|
9
|
+
require_relative 'nutrition_facts_label_v1_cholesterol'
|
10
|
+
require_relative 'nutrition_facts_label_v1_total_carbohydrate'
|
11
|
+
require_relative 'nutrition_facts_label_v1_dietary_fiber'
|
12
|
+
require_relative 'nutrition_facts_label_v1_total_sugar'
|
13
|
+
require_relative 'nutrition_facts_label_v1_added_sugar'
|
14
|
+
require_relative 'nutrition_facts_label_v1_protein'
|
15
|
+
require_relative 'nutrition_facts_label_v1_sodium'
|
16
|
+
require_relative 'nutrition_facts_label_v1_nutrient'
|
17
|
+
|
18
|
+
module Mindee
|
19
|
+
module Product
|
20
|
+
module NutritionFactsLabel
|
21
|
+
# Nutrition Facts Label API version 1.0 document data.
|
22
|
+
class NutritionFactsLabelV1Document < Mindee::Parsing::Common::Prediction
|
23
|
+
include Mindee::Parsing::Standard
|
24
|
+
# The amount of added sugars in the product.
|
25
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1AddedSugar]
|
26
|
+
attr_reader :added_sugars
|
27
|
+
# The amount of calories in the product.
|
28
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1Calorie]
|
29
|
+
attr_reader :calories
|
30
|
+
# The amount of cholesterol in the product.
|
31
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1Cholesterol]
|
32
|
+
attr_reader :cholesterol
|
33
|
+
# The amount of dietary fiber in the product.
|
34
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1DietaryFiber]
|
35
|
+
attr_reader :dietary_fiber
|
36
|
+
# The amount of nutrients in the product.
|
37
|
+
# @return [Array<Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1Nutrient>]
|
38
|
+
attr_reader :nutrients
|
39
|
+
# The amount of protein in the product.
|
40
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1Protein]
|
41
|
+
attr_reader :protein
|
42
|
+
# The amount of saturated fat in the product.
|
43
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1SaturatedFat]
|
44
|
+
attr_reader :saturated_fat
|
45
|
+
# The number of servings in each box of the product.
|
46
|
+
# @return [Mindee::Parsing::Standard::AmountField]
|
47
|
+
attr_reader :serving_per_box
|
48
|
+
# The size of a single serving of the product.
|
49
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1ServingSize]
|
50
|
+
attr_reader :serving_size
|
51
|
+
# The amount of sodium in the product.
|
52
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1Sodium]
|
53
|
+
attr_reader :sodium
|
54
|
+
# The total amount of carbohydrates in the product.
|
55
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1TotalCarbohydrate]
|
56
|
+
attr_reader :total_carbohydrate
|
57
|
+
# The total amount of fat in the product.
|
58
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1TotalFat]
|
59
|
+
attr_reader :total_fat
|
60
|
+
# The total amount of sugars in the product.
|
61
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1TotalSugar]
|
62
|
+
attr_reader :total_sugars
|
63
|
+
# The amount of trans fat in the product.
|
64
|
+
# @return [Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1TransFat]
|
65
|
+
attr_reader :trans_fat
|
66
|
+
|
67
|
+
# @param prediction [Hash]
|
68
|
+
# @param page_id [Integer, nil]
|
69
|
+
def initialize(prediction, page_id)
|
70
|
+
super()
|
71
|
+
@added_sugars = NutritionFactsLabelV1AddedSugar.new(prediction['added_sugars'], page_id)
|
72
|
+
@calories = NutritionFactsLabelV1Calorie.new(prediction['calories'], page_id)
|
73
|
+
@cholesterol = NutritionFactsLabelV1Cholesterol.new(prediction['cholesterol'], page_id)
|
74
|
+
@dietary_fiber = NutritionFactsLabelV1DietaryFiber.new(prediction['dietary_fiber'], page_id)
|
75
|
+
@nutrients = []
|
76
|
+
prediction['nutrients'].each do |item|
|
77
|
+
@nutrients.push(NutritionFactsLabelV1Nutrient.new(item, page_id))
|
78
|
+
end
|
79
|
+
@protein = NutritionFactsLabelV1Protein.new(prediction['protein'], page_id)
|
80
|
+
@saturated_fat = NutritionFactsLabelV1SaturatedFat.new(prediction['saturated_fat'], page_id)
|
81
|
+
@serving_per_box = AmountField.new(prediction['serving_per_box'], page_id)
|
82
|
+
@serving_size = NutritionFactsLabelV1ServingSize.new(prediction['serving_size'], page_id)
|
83
|
+
@sodium = NutritionFactsLabelV1Sodium.new(prediction['sodium'], page_id)
|
84
|
+
@total_carbohydrate = NutritionFactsLabelV1TotalCarbohydrate.new(prediction['total_carbohydrate'], page_id)
|
85
|
+
@total_fat = NutritionFactsLabelV1TotalFat.new(prediction['total_fat'], page_id)
|
86
|
+
@total_sugars = NutritionFactsLabelV1TotalSugar.new(prediction['total_sugars'], page_id)
|
87
|
+
@trans_fat = NutritionFactsLabelV1TransFat.new(prediction['trans_fat'], page_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
# @return [String]
|
91
|
+
def to_s
|
92
|
+
serving_size = @serving_size.to_s
|
93
|
+
calories = @calories.to_s
|
94
|
+
total_fat = @total_fat.to_s
|
95
|
+
saturated_fat = @saturated_fat.to_s
|
96
|
+
trans_fat = @trans_fat.to_s
|
97
|
+
cholesterol = @cholesterol.to_s
|
98
|
+
total_carbohydrate = @total_carbohydrate.to_s
|
99
|
+
dietary_fiber = @dietary_fiber.to_s
|
100
|
+
total_sugars = @total_sugars.to_s
|
101
|
+
added_sugars = @added_sugars.to_s
|
102
|
+
protein = @protein.to_s
|
103
|
+
sodium = @sodium.to_s
|
104
|
+
nutrients = nutrients_to_s
|
105
|
+
out_str = String.new
|
106
|
+
out_str << "\n:Serving per Box: #{@serving_per_box}".rstrip
|
107
|
+
out_str << "\n:Serving Size:"
|
108
|
+
out_str << serving_size
|
109
|
+
out_str << "\n:Calories:"
|
110
|
+
out_str << calories
|
111
|
+
out_str << "\n:Total Fat:"
|
112
|
+
out_str << total_fat
|
113
|
+
out_str << "\n:Saturated Fat:"
|
114
|
+
out_str << saturated_fat
|
115
|
+
out_str << "\n:Trans Fat:"
|
116
|
+
out_str << trans_fat
|
117
|
+
out_str << "\n:Cholesterol:"
|
118
|
+
out_str << cholesterol
|
119
|
+
out_str << "\n:Total Carbohydrate:"
|
120
|
+
out_str << total_carbohydrate
|
121
|
+
out_str << "\n:Dietary Fiber:"
|
122
|
+
out_str << dietary_fiber
|
123
|
+
out_str << "\n:Total Sugars:"
|
124
|
+
out_str << total_sugars
|
125
|
+
out_str << "\n:Added Sugars:"
|
126
|
+
out_str << added_sugars
|
127
|
+
out_str << "\n:Protein:"
|
128
|
+
out_str << protein
|
129
|
+
out_str << "\n:sodium:"
|
130
|
+
out_str << sodium
|
131
|
+
out_str << "\n:nutrients:"
|
132
|
+
out_str << nutrients
|
133
|
+
out_str[1..].to_s
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
# @param char [String]
|
139
|
+
# @return [String]
|
140
|
+
def nutrients_separator(char)
|
141
|
+
out_str = String.new
|
142
|
+
out_str << ' '
|
143
|
+
out_str << "+#{char * 13}"
|
144
|
+
out_str << "+#{char * 22}"
|
145
|
+
out_str << "+#{char * 10}"
|
146
|
+
out_str << "+#{char * 13}"
|
147
|
+
out_str << "+#{char * 6}"
|
148
|
+
out_str << '+'
|
149
|
+
out_str
|
150
|
+
end
|
151
|
+
|
152
|
+
# @return [String]
|
153
|
+
def nutrients_to_s
|
154
|
+
return '' if @nutrients.empty?
|
155
|
+
|
156
|
+
line_items = @nutrients.map(&:to_table_line).join("\n#{nutrients_separator('-')}\n ")
|
157
|
+
out_str = String.new
|
158
|
+
out_str << "\n#{nutrients_separator('-')}"
|
159
|
+
out_str << "\n |"
|
160
|
+
out_str << ' Daily Value |'
|
161
|
+
out_str << ' Name |'
|
162
|
+
out_str << ' Per 100g |'
|
163
|
+
out_str << ' Per Serving |'
|
164
|
+
out_str << ' Unit |'
|
165
|
+
out_str << "\n#{nutrients_separator('=')}"
|
166
|
+
out_str << "\n #{line_items}"
|
167
|
+
out_str << "\n#{nutrients_separator('-')}"
|
168
|
+
out_str
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module NutritionFactsLabel
|
8
|
+
# The amount of nutrients in the product.
|
9
|
+
class NutritionFactsLabelV1Nutrient < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# DVs are the recommended amounts of nutrients to consume or not to exceed each day.
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :daily_value
|
14
|
+
# The name of nutrients of the product.
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :name
|
17
|
+
# The amount of nutrients per 100g of the product.
|
18
|
+
# @return [Float]
|
19
|
+
attr_reader :per_100g
|
20
|
+
# The amount of nutrients per serving of the product.
|
21
|
+
# @return [Float]
|
22
|
+
attr_reader :per_serving
|
23
|
+
# The unit of measurement for the amount of nutrients.
|
24
|
+
# @return [String]
|
25
|
+
attr_reader :unit
|
26
|
+
|
27
|
+
# @param prediction [Hash]
|
28
|
+
# @param page_id [Integer, nil]
|
29
|
+
def initialize(prediction, page_id)
|
30
|
+
super(prediction, page_id)
|
31
|
+
@daily_value = prediction['daily_value']
|
32
|
+
@name = prediction['name']
|
33
|
+
@per_100g = prediction['per_100g']
|
34
|
+
@per_serving = prediction['per_serving']
|
35
|
+
@unit = prediction['unit']
|
36
|
+
@page_id = page_id
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Hash]
|
40
|
+
def printable_values
|
41
|
+
printable = {}
|
42
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
43
|
+
printable[:name] = format_for_display(@name)
|
44
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
45
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
46
|
+
printable[:unit] = format_for_display(@unit)
|
47
|
+
printable
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Hash]
|
51
|
+
def table_printable_values
|
52
|
+
printable = {}
|
53
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
54
|
+
printable[:name] = format_for_display(@name, 20)
|
55
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
56
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
57
|
+
printable[:unit] = format_for_display(@unit, nil)
|
58
|
+
printable
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [String]
|
62
|
+
def to_table_line
|
63
|
+
printable = table_printable_values
|
64
|
+
out_str = String.new
|
65
|
+
out_str << format('| %- 12s', printable[:daily_value])
|
66
|
+
out_str << format('| %- 21s', printable[:name])
|
67
|
+
out_str << format('| %- 9s', printable[:per_100g])
|
68
|
+
out_str << format('| %- 12s', printable[:per_serving])
|
69
|
+
out_str << format('| %- 5s', printable[:unit])
|
70
|
+
out_str << '|'
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [String]
|
74
|
+
def to_s
|
75
|
+
printable = printable_values
|
76
|
+
out_str = String.new
|
77
|
+
out_str << "\n :Daily Value: #{printable[:daily_value]}"
|
78
|
+
out_str << "\n :Name: #{printable[:name]}"
|
79
|
+
out_str << "\n :Per 100g: #{printable[:per_100g]}"
|
80
|
+
out_str << "\n :Per Serving: #{printable[:per_serving]}"
|
81
|
+
out_str << "\n :Unit: #{printable[:unit]}"
|
82
|
+
out_str
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
require_relative 'nutrition_facts_label_v1_document'
|
5
|
+
|
6
|
+
module Mindee
|
7
|
+
module Product
|
8
|
+
module NutritionFactsLabel
|
9
|
+
# Nutrition Facts Label API version 1.0 page data.
|
10
|
+
class NutritionFactsLabelV1Page < Mindee::Parsing::Common::Page
|
11
|
+
# @param prediction [Hash]
|
12
|
+
def initialize(prediction)
|
13
|
+
super(prediction)
|
14
|
+
@prediction = NutritionFactsLabelV1PagePrediction.new(
|
15
|
+
prediction['prediction'],
|
16
|
+
prediction['id']
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Nutrition Facts Label V1 page prediction.
|
22
|
+
class NutritionFactsLabelV1PagePrediction < NutritionFactsLabelV1Document
|
23
|
+
# @return [String]
|
24
|
+
def to_s
|
25
|
+
out_str = String.new
|
26
|
+
out_str << "\n#{super}"
|
27
|
+
out_str
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module NutritionFactsLabel
|
8
|
+
# The amount of protein in the product.
|
9
|
+
class NutritionFactsLabelV1Protein < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# DVs are the recommended amounts of protein to consume or not to exceed each day.
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :daily_value
|
14
|
+
# The amount of protein per 100g of the product.
|
15
|
+
# @return [Float]
|
16
|
+
attr_reader :per_100g
|
17
|
+
# The amount of protein per serving of the product.
|
18
|
+
# @return [Float]
|
19
|
+
attr_reader :per_serving
|
20
|
+
|
21
|
+
# @param prediction [Hash]
|
22
|
+
# @param page_id [Integer, nil]
|
23
|
+
def initialize(prediction, page_id)
|
24
|
+
super(prediction, page_id)
|
25
|
+
@daily_value = prediction['daily_value']
|
26
|
+
@per_100g = prediction['per_100g']
|
27
|
+
@per_serving = prediction['per_serving']
|
28
|
+
@page_id = page_id
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash]
|
32
|
+
def printable_values
|
33
|
+
printable = {}
|
34
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
35
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
36
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
37
|
+
printable
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def to_s
|
42
|
+
printable = printable_values
|
43
|
+
out_str = String.new
|
44
|
+
out_str << "\n :Daily Value: #{printable[:daily_value]}"
|
45
|
+
out_str << "\n :Per 100g: #{printable[:per_100g]}"
|
46
|
+
out_str << "\n :Per Serving: #{printable[:per_serving]}"
|
47
|
+
out_str
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module NutritionFactsLabel
|
8
|
+
# The amount of saturated fat in the product.
|
9
|
+
class NutritionFactsLabelV1SaturatedFat < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# DVs are the recommended amounts of saturated fat to consume or not to exceed each day.
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :daily_value
|
14
|
+
# The amount of saturated fat per 100g of the product.
|
15
|
+
# @return [Float]
|
16
|
+
attr_reader :per_100g
|
17
|
+
# The amount of saturated fat per serving of the product.
|
18
|
+
# @return [Float]
|
19
|
+
attr_reader :per_serving
|
20
|
+
|
21
|
+
# @param prediction [Hash]
|
22
|
+
# @param page_id [Integer, nil]
|
23
|
+
def initialize(prediction, page_id)
|
24
|
+
super(prediction, page_id)
|
25
|
+
@daily_value = prediction['daily_value']
|
26
|
+
@per_100g = prediction['per_100g']
|
27
|
+
@per_serving = prediction['per_serving']
|
28
|
+
@page_id = page_id
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash]
|
32
|
+
def printable_values
|
33
|
+
printable = {}
|
34
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
35
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
36
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
37
|
+
printable
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def to_s
|
42
|
+
printable = printable_values
|
43
|
+
out_str = String.new
|
44
|
+
out_str << "\n :Daily Value: #{printable[:daily_value]}"
|
45
|
+
out_str << "\n :Per 100g: #{printable[:per_100g]}"
|
46
|
+
out_str << "\n :Per Serving: #{printable[:per_serving]}"
|
47
|
+
out_str
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module NutritionFactsLabel
|
8
|
+
# The size of a single serving of the product.
|
9
|
+
class NutritionFactsLabelV1ServingSize < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# The amount of a single serving.
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :amount
|
14
|
+
# The unit for the amount of a single serving.
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :unit
|
17
|
+
|
18
|
+
# @param prediction [Hash]
|
19
|
+
# @param page_id [Integer, nil]
|
20
|
+
def initialize(prediction, page_id)
|
21
|
+
super(prediction, page_id)
|
22
|
+
@amount = prediction['amount']
|
23
|
+
@unit = prediction['unit']
|
24
|
+
@page_id = page_id
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Hash]
|
28
|
+
def printable_values
|
29
|
+
printable = {}
|
30
|
+
printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount)
|
31
|
+
printable[:unit] = format_for_display(@unit)
|
32
|
+
printable
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String]
|
36
|
+
def to_s
|
37
|
+
printable = printable_values
|
38
|
+
out_str = String.new
|
39
|
+
out_str << "\n :Amount: #{printable[:amount]}"
|
40
|
+
out_str << "\n :Unit: #{printable[:unit]}"
|
41
|
+
out_str
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module NutritionFactsLabel
|
8
|
+
# The amount of sodium in the product.
|
9
|
+
class NutritionFactsLabelV1Sodium < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# DVs are the recommended amounts of sodium to consume or not to exceed each day.
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :daily_value
|
14
|
+
# The amount of sodium per 100g of the product.
|
15
|
+
# @return [Float]
|
16
|
+
attr_reader :per_100g
|
17
|
+
# The amount of sodium per serving of the product.
|
18
|
+
# @return [Float]
|
19
|
+
attr_reader :per_serving
|
20
|
+
# The unit of measurement for the amount of sodium.
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :unit
|
23
|
+
|
24
|
+
# @param prediction [Hash]
|
25
|
+
# @param page_id [Integer, nil]
|
26
|
+
def initialize(prediction, page_id)
|
27
|
+
super(prediction, page_id)
|
28
|
+
@daily_value = prediction['daily_value']
|
29
|
+
@per_100g = prediction['per_100g']
|
30
|
+
@per_serving = prediction['per_serving']
|
31
|
+
@unit = prediction['unit']
|
32
|
+
@page_id = page_id
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Hash]
|
36
|
+
def printable_values
|
37
|
+
printable = {}
|
38
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
39
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
40
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
41
|
+
printable[:unit] = format_for_display(@unit)
|
42
|
+
printable
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String]
|
46
|
+
def to_s
|
47
|
+
printable = printable_values
|
48
|
+
out_str = String.new
|
49
|
+
out_str << "\n :Daily Value: #{printable[:daily_value]}"
|
50
|
+
out_str << "\n :Per 100g: #{printable[:per_100g]}"
|
51
|
+
out_str << "\n :Per Serving: #{printable[:per_serving]}"
|
52
|
+
out_str << "\n :Unit: #{printable[:unit]}"
|
53
|
+
out_str
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module NutritionFactsLabel
|
8
|
+
# The total amount of carbohydrates in the product.
|
9
|
+
class NutritionFactsLabelV1TotalCarbohydrate < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# DVs are the recommended amounts of total carbohydrates to consume or not to exceed each day.
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :daily_value
|
14
|
+
# The amount of total carbohydrates per 100g of the product.
|
15
|
+
# @return [Float]
|
16
|
+
attr_reader :per_100g
|
17
|
+
# The amount of total carbohydrates per serving of the product.
|
18
|
+
# @return [Float]
|
19
|
+
attr_reader :per_serving
|
20
|
+
|
21
|
+
# @param prediction [Hash]
|
22
|
+
# @param page_id [Integer, nil]
|
23
|
+
def initialize(prediction, page_id)
|
24
|
+
super(prediction, page_id)
|
25
|
+
@daily_value = prediction['daily_value']
|
26
|
+
@per_100g = prediction['per_100g']
|
27
|
+
@per_serving = prediction['per_serving']
|
28
|
+
@page_id = page_id
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash]
|
32
|
+
def printable_values
|
33
|
+
printable = {}
|
34
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
35
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
36
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
37
|
+
printable
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def to_s
|
42
|
+
printable = printable_values
|
43
|
+
out_str = String.new
|
44
|
+
out_str << "\n :Daily Value: #{printable[:daily_value]}"
|
45
|
+
out_str << "\n :Per 100g: #{printable[:per_100g]}"
|
46
|
+
out_str << "\n :Per Serving: #{printable[:per_serving]}"
|
47
|
+
out_str
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module NutritionFactsLabel
|
8
|
+
# The total amount of fat in the product.
|
9
|
+
class NutritionFactsLabelV1TotalFat < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# DVs are the recommended amounts of total fat to consume or not to exceed each day.
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :daily_value
|
14
|
+
# The amount of total fat per 100g of the product.
|
15
|
+
# @return [Float]
|
16
|
+
attr_reader :per_100g
|
17
|
+
# The amount of total fat per serving of the product.
|
18
|
+
# @return [Float]
|
19
|
+
attr_reader :per_serving
|
20
|
+
|
21
|
+
# @param prediction [Hash]
|
22
|
+
# @param page_id [Integer, nil]
|
23
|
+
def initialize(prediction, page_id)
|
24
|
+
super(prediction, page_id)
|
25
|
+
@daily_value = prediction['daily_value']
|
26
|
+
@per_100g = prediction['per_100g']
|
27
|
+
@per_serving = prediction['per_serving']
|
28
|
+
@page_id = page_id
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash]
|
32
|
+
def printable_values
|
33
|
+
printable = {}
|
34
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
35
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
36
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
37
|
+
printable
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def to_s
|
42
|
+
printable = printable_values
|
43
|
+
out_str = String.new
|
44
|
+
out_str << "\n :Daily Value: #{printable[:daily_value]}"
|
45
|
+
out_str << "\n :Per 100g: #{printable[:per_100g]}"
|
46
|
+
out_str << "\n :Per Serving: #{printable[:per_serving]}"
|
47
|
+
out_str
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module NutritionFactsLabel
|
8
|
+
# The total amount of sugars in the product.
|
9
|
+
class NutritionFactsLabelV1TotalSugar < Mindee::Parsing::Standard::FeatureField
|
10
|
+
include Mindee::Parsing::Standard
|
11
|
+
# DVs are the recommended amounts of total sugars to consume or not to exceed each day.
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :daily_value
|
14
|
+
# The amount of total sugars per 100g of the product.
|
15
|
+
# @return [Float]
|
16
|
+
attr_reader :per_100g
|
17
|
+
# The amount of total sugars per serving of the product.
|
18
|
+
# @return [Float]
|
19
|
+
attr_reader :per_serving
|
20
|
+
|
21
|
+
# @param prediction [Hash]
|
22
|
+
# @param page_id [Integer, nil]
|
23
|
+
def initialize(prediction, page_id)
|
24
|
+
super(prediction, page_id)
|
25
|
+
@daily_value = prediction['daily_value']
|
26
|
+
@per_100g = prediction['per_100g']
|
27
|
+
@per_serving = prediction['per_serving']
|
28
|
+
@page_id = page_id
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash]
|
32
|
+
def printable_values
|
33
|
+
printable = {}
|
34
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
35
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
36
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
37
|
+
printable
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def to_s
|
42
|
+
printable = printable_values
|
43
|
+
out_str = String.new
|
44
|
+
out_str << "\n :Daily Value: #{printable[:daily_value]}"
|
45
|
+
out_str << "\n :Per 100g: #{printable[:per_100g]}"
|
46
|
+
out_str << "\n :Per Serving: #{printable[:per_serving]}"
|
47
|
+
out_str
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|