mindee-lite 5.2.1 → 5.3.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/CHANGELOG.md +16 -0
- data/SKILL.md +172 -0
- data/bin/mindee.rb +20 -15
- data/bin/v2/parser.rb +27 -8
- data/lib/mindee/image/extracted_image.rb +1 -8
- data/lib/mindee/image/extracted_images.rb +20 -0
- data/lib/mindee/image/image_extractor.rb +26 -8
- data/lib/mindee/image/image_utils.rb +0 -17
- data/lib/mindee/image.rb +1 -0
- data/lib/mindee/input/sources/local_input_source.rb +24 -5
- data/lib/mindee/pdf/extracted_pdf.rb +1 -1
- data/lib/mindee/pdf/extracted_pdfs.rb +20 -0
- data/lib/mindee/pdf/pdf_extractor.rb +10 -10
- data/lib/mindee/pdf.rb +1 -0
- data/lib/mindee/v2/file_operations/crop.rb +7 -6
- data/lib/mindee/v2/file_operations/split.rb +2 -2
- data/lib/mindee/v2/file_operations.rb +0 -2
- data/lib/mindee/v2/parsing/failed_inference_response.rb +34 -0
- data/lib/mindee/v2/parsing/search/search_response.rb +8 -5
- data/lib/mindee/v2/parsing.rb +1 -0
- data/lib/mindee/v2/product/crop/crop_item.rb +1 -1
- data/lib/mindee/v2/product/crop/crop_response.rb +0 -8
- data/lib/mindee/v2/product/crop/crop_result.rb +8 -0
- data/lib/mindee/v2/product/split/split_range.rb +1 -1
- data/lib/mindee/v2/product/split/split_response.rb +0 -8
- data/lib/mindee/v2/product/split/split_result.rb +7 -0
- data/lib/mindee/version.rb +1 -1
- data/sig/mindee/image/extracted_image.rbs +0 -1
- data/sig/mindee/image/extracted_images.rbs +8 -0
- data/sig/mindee/image/image_extractor.rbs +3 -2
- data/sig/mindee/image/image_utils.rbs +0 -1
- data/sig/mindee/input/sources/local_input_source.rbs +6 -0
- data/sig/mindee/pdf/extracted_pdfs.rbs +8 -0
- data/sig/mindee/pdf/pdf_extractor.rbs +2 -2
- data/sig/mindee/v2/file_operation/crop.rbs +1 -1
- data/sig/mindee/v2/file_operation/split.rbs +1 -1
- data/sig/mindee/v2/parsing/failed_inference_response.rbs +15 -0
- data/sig/mindee/v2/parsing/search/search_models.rbs +13 -0
- data/sig/mindee/v2/parsing/search/search_response.rbs +1 -0
- data/sig/mindee/v2/product/crop/crop_item.rbs +1 -1
- data/sig/mindee/v2/product/crop/crop_response.rbs +0 -2
- data/sig/mindee/v2/product/crop/crop_result.rbs +1 -0
- data/sig/mindee/v2/product/split/split_range.rbs +1 -1
- data/sig/mindee/v2/product/split/split_response.rbs +0 -2
- data/sig/mindee/v2/product/split/split_result.rbs +3 -0
- metadata +11 -7
- data/lib/mindee/v2/file_operations/crop_files.rb +0 -25
- data/lib/mindee/v2/file_operations/split_files.rb +0 -25
- data/sig/mindee/v2/file_operation/crop_files.rbs +0 -9
- data/sig/mindee/v2/file_operation/split_files.rbs +0 -9
|
@@ -21,7 +21,7 @@ module Mindee
|
|
|
21
21
|
#
|
|
22
22
|
# @param input_source [LocalInputSource] Local Input Source to extract sub-receipts from.
|
|
23
23
|
# @param crops [Array<CropItem>] List of crops.
|
|
24
|
-
# @return [
|
|
24
|
+
# @return [Image::ExtractedImages] Individual extracted zones as an array of ExtractedImage.
|
|
25
25
|
# @raise [MindeeError] if the crops array is empty.
|
|
26
26
|
def self.extract_crops(input_source, crops)
|
|
27
27
|
if crops.nil? || crops.empty?
|
|
@@ -35,15 +35,16 @@ module Mindee
|
|
|
35
35
|
polygons[crop.location.page] << crop.location.polygon
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
images =
|
|
38
|
+
images = Mindee::Image::ExtractedImages.new
|
|
39
39
|
polygons.each_with_index do |page_polygons, page_index|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
images.concat(
|
|
41
|
+
Mindee::Image::ImageExtractor.extract_multiple_images_from_source(
|
|
42
|
+
input_source, page_index, page_polygons
|
|
43
|
+
)
|
|
42
44
|
)
|
|
43
|
-
images.concat(extracted)
|
|
44
45
|
end
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
images
|
|
47
48
|
end
|
|
48
49
|
end
|
|
49
50
|
end
|
|
@@ -18,7 +18,7 @@ module Mindee
|
|
|
18
18
|
#
|
|
19
19
|
# @param input_source [LocalInputSource] Input source to split.
|
|
20
20
|
# @param splits [Array<Array<Integer>>] List of sub-lists of pages to keep.
|
|
21
|
-
# @return [
|
|
21
|
+
# @return [PDF::ExtractedPDFs] A list of extracted invoices.
|
|
22
22
|
# @raise [MindeeError] if no indexes are provided.
|
|
23
23
|
def self.extract_splits(input_source, splits)
|
|
24
24
|
raise Mindee::Error::MindeeError, 'No indexes provided.' if splits.nil? || splits.empty?
|
|
@@ -29,7 +29,7 @@ module Mindee
|
|
|
29
29
|
(split[0]..split[1]).to_a
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
pdf_extractor.extract_sub_documents(page_groups)
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Parsing
|
|
6
|
+
# "Webhook payload returned when an inference fails before producing a result.
|
|
7
|
+
class FailedInferenceResponse < Mindee::V2::Parsing::CommonResponse
|
|
8
|
+
# @return [String] UUID of the failed inference.
|
|
9
|
+
attr_reader :inference_id
|
|
10
|
+
# @return [String] UUID of the model used.
|
|
11
|
+
attr_reader :model_id
|
|
12
|
+
# @return [String] Name of the input file.
|
|
13
|
+
attr_reader :file_name
|
|
14
|
+
# @return [String, Nil] Alias sent for the file, if any.
|
|
15
|
+
attr_reader :file_alias
|
|
16
|
+
# @return [Mindee::V2::Parsing::ErrorResponse] Problem details for the failure, if available.
|
|
17
|
+
attr_reader :error
|
|
18
|
+
# @return [Time] Date and time when the inference was started.
|
|
19
|
+
attr_reader :created_at
|
|
20
|
+
|
|
21
|
+
def initialize(server_response)
|
|
22
|
+
super
|
|
23
|
+
|
|
24
|
+
@inference_id = server_response['inference_id']
|
|
25
|
+
@model_id = server_response['model_id']
|
|
26
|
+
@file_name = server_response['file_name']
|
|
27
|
+
@file_alias = server_response['file_alias']
|
|
28
|
+
@error = ErrorResponse.new(server_response['error'])
|
|
29
|
+
@created_at = Time.iso8601(server_response['created_at'])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -6,16 +6,19 @@ module Mindee
|
|
|
6
6
|
module Search
|
|
7
7
|
# Models search response.
|
|
8
8
|
class SearchResponse < CommonResponse
|
|
9
|
-
# @return [Search::
|
|
9
|
+
# @return [Search::SearchModels] Parsed search payload.
|
|
10
10
|
attr_reader :models
|
|
11
|
-
# @return [Search::
|
|
11
|
+
# @return [Search::PaginationMetadata] Pagination metadata.
|
|
12
|
+
attr_reader :pagination
|
|
13
|
+
# @return [Search::PaginationMetadata] Pagination metadata.
|
|
12
14
|
attr_reader :pagination_metadata
|
|
13
15
|
|
|
14
16
|
def initialize(server_response)
|
|
15
17
|
super
|
|
16
18
|
|
|
17
|
-
@models =
|
|
18
|
-
@
|
|
19
|
+
@models = SearchModels.new(server_response['models'])
|
|
20
|
+
@pagination = PaginationMetadata.new(server_response['pagination'])
|
|
21
|
+
@pagination_metadata = @pagination
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
# String representation.
|
|
@@ -27,7 +30,7 @@ module Mindee
|
|
|
27
30
|
@models.to_s,
|
|
28
31
|
'Pagination Metadata',
|
|
29
32
|
'###################',
|
|
30
|
-
@
|
|
33
|
+
@pagination.to_s,
|
|
31
34
|
'',
|
|
32
35
|
].join("\n")
|
|
33
36
|
end
|
data/lib/mindee/v2/parsing.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Mindee
|
|
|
33
33
|
#
|
|
34
34
|
# @param input_source [Mindee::Input::Source::LocalInputSource] Local file to extract from
|
|
35
35
|
# @return [ExtractedImage]
|
|
36
|
-
def
|
|
36
|
+
def extract_from_input_source(input_source)
|
|
37
37
|
Image::ImageExtractor.extract_multiple_images_from_source(
|
|
38
38
|
input_source, @location.page, [@location.polygon]
|
|
39
39
|
)[0]
|
|
@@ -25,14 +25,6 @@ module Mindee
|
|
|
25
25
|
def to_s
|
|
26
26
|
@inference.to_s
|
|
27
27
|
end
|
|
28
|
-
|
|
29
|
-
# Apply the crop inference to a file and return a list of extracted images.
|
|
30
|
-
#
|
|
31
|
-
# @param input_source [Mindee::Input::Source::LocalInputSource] Local file to extract from
|
|
32
|
-
# @return [FileOperation::CropFiles] List of extracted PDFs
|
|
33
|
-
def extract_from_file(input_source)
|
|
34
|
-
FileOperation::Crop.extract_crops(input_source, @inference.result.crops)
|
|
35
|
-
end
|
|
36
28
|
end
|
|
37
29
|
end
|
|
38
30
|
end
|
|
@@ -20,6 +20,14 @@ module Mindee
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Apply the crop inference to a file and return a list of extracted images.
|
|
24
|
+
#
|
|
25
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource] Local file to extract from
|
|
26
|
+
# @return [Image::ExtractedImages] List of extracted images
|
|
27
|
+
def extract_from_input_source(input_source)
|
|
28
|
+
FileOperation::Crop.extract_crops(input_source, @crops)
|
|
29
|
+
end
|
|
30
|
+
|
|
23
31
|
# String representation.
|
|
24
32
|
# @return [String]
|
|
25
33
|
def to_s
|
|
@@ -34,7 +34,7 @@ module Mindee
|
|
|
34
34
|
#
|
|
35
35
|
# @param input_source [Mindee::Input::Source::LocalInputSource] Local file to extract from
|
|
36
36
|
# @return [PDF::ExtractedPDF]
|
|
37
|
-
def
|
|
37
|
+
def extract_from_input_source(input_source)
|
|
38
38
|
FileOperation::Split.extract_single_split(input_source, @page_range)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -25,14 +25,6 @@ module Mindee
|
|
|
25
25
|
def to_s
|
|
26
26
|
@inference.to_s
|
|
27
27
|
end
|
|
28
|
-
|
|
29
|
-
# Splits the input PDF.
|
|
30
|
-
# @param input_source [Mindee::Input::Source::LocalInputSource] Path to the file or a File object.
|
|
31
|
-
# @return [FileOperation::SplitFiles]
|
|
32
|
-
def extract_from_file(input_source)
|
|
33
|
-
splits = @inference.result.splits.map(&:page_range)
|
|
34
|
-
FileOperation::Split.extract_splits(input_source, splits)
|
|
35
|
-
end
|
|
36
28
|
end
|
|
37
29
|
end
|
|
38
30
|
end
|
|
@@ -20,6 +20,13 @@ module Mindee
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Splits the input PDF.
|
|
24
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource] Path to the file or a File object.
|
|
25
|
+
# @return [PDF::ExtractedPDFs]
|
|
26
|
+
def extract_from_input_source(input_source)
|
|
27
|
+
FileOperation::Split.extract_splits(input_source, splits.map(&:page_range))
|
|
28
|
+
end
|
|
29
|
+
|
|
23
30
|
# String representation.
|
|
24
31
|
# @return [String]
|
|
25
32
|
def to_s
|
data/lib/mindee/version.rb
CHANGED
|
@@ -4,9 +4,10 @@ module Mindee
|
|
|
4
4
|
module ImageExtractor
|
|
5
5
|
def self.attach_image_as_new_file: (StringIO | File, ?format: String) -> Origami::PDF
|
|
6
6
|
def self.to_blob: () -> String
|
|
7
|
-
def self.extract_multiple_images_from_source: (Input::Source::LocalInputSource, Integer, Array[Array[Geometry::Point] |Geometry::Polygon | Geometry::Quadrilateral]) ->
|
|
8
|
-
def self.extract_images_from_polygons: (Input::Source::LocalInputSource, Integer, Array[Array[Geometry::Point] | Geometry::Polygon | Geometry::Quadrilateral]) ->
|
|
7
|
+
def self.extract_multiple_images_from_source: (Input::Source::LocalInputSource, Integer, Array[Array[Geometry::Point] |Geometry::Polygon | Geometry::Quadrilateral]) -> ExtractedImages
|
|
8
|
+
def self.extract_images_from_polygons: (Input::Source::LocalInputSource, Integer, Array[Array[Geometry::Point] | Geometry::Polygon | Geometry::Quadrilateral]) -> ExtractedImages
|
|
9
9
|
def self.create_extracted_image: (StringIO | File, String, Integer, Integer) -> ExtractedImage
|
|
10
|
+
def self.crop_image: (MiniMagick::Image, Geometry::MinMax, Geometry::MinMax) -> (MiniMagick::Image)
|
|
10
11
|
def self.load_input_source_pdf_page_as_stringio: (Input::Source::LocalInputSource, Integer) -> (StringIO | File)
|
|
11
12
|
end
|
|
12
13
|
end
|
|
@@ -11,7 +11,6 @@ module Mindee
|
|
|
11
11
|
def self.pdf_to_magick_image: (StringIO | File, Integer) -> MiniMagick::Image
|
|
12
12
|
def self.normalize_polygon: (Geometry::Quadrilateral | Geometry::Polygon | Array[Geometry::Point]) -> Geometry::Quadrilateral
|
|
13
13
|
def self.read_page_content: (StringIO | File) -> (MiniMagick::Image)
|
|
14
|
-
def self.crop_image: (MiniMagick::Image, Geometry::MinMax, Geometry::MinMax) -> (MiniMagick::Image)
|
|
15
14
|
def self.write_image_to_buffer: (MiniMagick::Image, StringIO) -> void
|
|
16
15
|
def self.determine_file_extension: (Input::Source::LocalInputSource) -> String?
|
|
17
16
|
end
|
|
@@ -23,6 +23,12 @@ module Mindee
|
|
|
23
23
|
def write_to_file: (String?) -> void
|
|
24
24
|
def compress!: (?quality: Integer, ?max_width: Integer?, ?max_height: Integer?, ?force_source_text: bool, ?disable_source_text: bool) -> Integer
|
|
25
25
|
def source_text?: -> bool?
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def detect_mime_type: (bool) -> String
|
|
30
|
+
|
|
31
|
+
def heif_mimetype_from_extension: -> String?
|
|
26
32
|
end
|
|
27
33
|
def self.convert_to_unicode_escape: (String) -> String
|
|
28
34
|
end
|
|
@@ -11,9 +11,9 @@ module Mindee
|
|
|
11
11
|
|
|
12
12
|
def cut_pages: (Array[Integer]) -> StringIO
|
|
13
13
|
|
|
14
|
-
def extract_sub_documents: (Array[Array[Integer]]) ->
|
|
14
|
+
def extract_sub_documents: (Array[Array[Integer]]) -> ExtractedPDFs
|
|
15
15
|
|
|
16
|
-
def extract_invoices: (Array[Mindee::V1::Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroup] | Array[Array[Integer]], ?strict: bool) ->
|
|
16
|
+
def extract_invoices: (Array[Mindee::V1::Product::InvoiceSplitter::InvoiceSplitterV1InvoicePageGroup] | Array[Array[Integer]], ?strict: bool) -> ExtractedPDFs
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -3,7 +3,7 @@ module Mindee
|
|
|
3
3
|
module FileOperation
|
|
4
4
|
module Crop
|
|
5
5
|
def self.extract_single_crop: (Input::Source::LocalInputSource, Parsing::Field::FieldLocation) -> Image::ExtractedImage
|
|
6
|
-
def self.extract_crops: (Input::Source::LocalInputSource, Array[Product::Crop::CropItem]) ->
|
|
6
|
+
def self.extract_crops: (Input::Source::LocalInputSource, Array[Product::Crop::CropItem]) -> Image::ExtractedImages
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -4,7 +4,7 @@ module Mindee
|
|
|
4
4
|
module Split
|
|
5
5
|
def self.extract_single_split: (Input::Source::LocalInputSource, Array[Integer]) -> PDF::ExtractedPDF
|
|
6
6
|
|
|
7
|
-
def self.extract_splits: (Input::Source::LocalInputSource, Array[Array[Integer]]) ->
|
|
7
|
+
def self.extract_splits: (Input::Source::LocalInputSource, Array[Array[Integer]]) -> PDF::ExtractedPDFs
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Mindee
|
|
2
|
+
module V2
|
|
3
|
+
module Parsing
|
|
4
|
+
class FailedInferenceResponse
|
|
5
|
+
def initialize: (Hash[String | Symbol, untyped]) -> void
|
|
6
|
+
attr_reader created_at: Time
|
|
7
|
+
attr_reader error: ::Mindee::V2::Parsing::ErrorResponse
|
|
8
|
+
attr_reader file_alias: String
|
|
9
|
+
attr_reader file_name: String
|
|
10
|
+
attr_reader inference_id: String
|
|
11
|
+
attr_reader model_id: String
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -9,7 +9,7 @@ module Mindee
|
|
|
9
9
|
|
|
10
10
|
def initialize: (Hash[String | Symbol, untyped]) -> void
|
|
11
11
|
|
|
12
|
-
def
|
|
12
|
+
def extract_from_input_source: (Input::Source::LocalInputSource) -> Image::ExtractedImage
|
|
13
13
|
|
|
14
14
|
def to_s: -> String
|
|
15
15
|
end
|
|
@@ -13,8 +13,6 @@ module Mindee
|
|
|
13
13
|
|
|
14
14
|
def _params_type: -> singleton(Params::CropParameters)
|
|
15
15
|
|
|
16
|
-
def extract_from_file: (Input::Source::LocalInputSource) -> FileOperation::CropFiles
|
|
17
|
-
|
|
18
16
|
def to_s: -> String
|
|
19
17
|
def self._params_type: () -> singleton(Params::CropParameters)
|
|
20
18
|
def self.slug: () -> String
|
|
@@ -9,7 +9,7 @@ module Mindee
|
|
|
9
9
|
|
|
10
10
|
def initialize: (Hash[String | Symbol, untyped]) -> void
|
|
11
11
|
|
|
12
|
-
def
|
|
12
|
+
def extract_from_input_source: (Input::Source::LocalInputSource) -> PDF::ExtractedPDF
|
|
13
13
|
|
|
14
14
|
def to_s: -> String
|
|
15
15
|
end
|
|
@@ -13,8 +13,6 @@ module Mindee
|
|
|
13
13
|
|
|
14
14
|
def _params_type: -> singleton(Params::SplitParameters)
|
|
15
15
|
|
|
16
|
-
def extract_from_file: (Mindee::Input::Source::LocalInputSource) -> FileOperation::SplitFiles
|
|
17
|
-
|
|
18
16
|
def to_s: -> String
|
|
19
17
|
def self._params_type: () -> singleton(Params::SplitParameters)
|
|
20
18
|
def self.slug: () -> String
|
|
@@ -5,7 +5,10 @@ module Mindee
|
|
|
5
5
|
class SplitResult
|
|
6
6
|
attr_reader splits: Array[SplitRange]
|
|
7
7
|
|
|
8
|
+
def extract_from_input_source: (Mindee::Input::Source::LocalInputSource) -> PDF::ExtractedPDFs
|
|
9
|
+
|
|
8
10
|
def initialize: (Hash[String | Symbol, untyped]) -> void
|
|
11
|
+
|
|
9
12
|
def to_s: -> String
|
|
10
13
|
end
|
|
11
14
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mindee-lite
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mindee, SA
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -57,8 +57,8 @@ description: Quickly and easily connect to Mindee's API services using Ruby. Thi
|
|
|
57
57
|
email:
|
|
58
58
|
- opensource@mindee.co
|
|
59
59
|
executables:
|
|
60
|
-
- mindee.rb
|
|
61
60
|
- console
|
|
61
|
+
- mindee.rb
|
|
62
62
|
extensions: []
|
|
63
63
|
extra_rdoc_files: []
|
|
64
64
|
files:
|
|
@@ -76,6 +76,7 @@ files:
|
|
|
76
76
|
- LICENSE
|
|
77
77
|
- README.md
|
|
78
78
|
- Rakefile
|
|
79
|
+
- SKILL.md
|
|
79
80
|
- Steepfile
|
|
80
81
|
- bin/console
|
|
81
82
|
- bin/mindee.rb
|
|
@@ -133,6 +134,7 @@ files:
|
|
|
133
134
|
- lib/mindee/http/response_validation.rb
|
|
134
135
|
- lib/mindee/image.rb
|
|
135
136
|
- lib/mindee/image/extracted_image.rb
|
|
137
|
+
- lib/mindee/image/extracted_images.rb
|
|
136
138
|
- lib/mindee/image/image_compressor.rb
|
|
137
139
|
- lib/mindee/image/image_extractor.rb
|
|
138
140
|
- lib/mindee/image/image_utils.rb
|
|
@@ -152,6 +154,7 @@ files:
|
|
|
152
154
|
- lib/mindee/page_options.rb
|
|
153
155
|
- lib/mindee/pdf.rb
|
|
154
156
|
- lib/mindee/pdf/extracted_pdf.rb
|
|
157
|
+
- lib/mindee/pdf/extracted_pdfs.rb
|
|
155
158
|
- lib/mindee/pdf/pdf_compressor.rb
|
|
156
159
|
- lib/mindee/pdf/pdf_extractor.rb
|
|
157
160
|
- lib/mindee/pdf/pdf_processor.rb
|
|
@@ -281,9 +284,7 @@ files:
|
|
|
281
284
|
- lib/mindee/v2/client.rb
|
|
282
285
|
- lib/mindee/v2/file_operations.rb
|
|
283
286
|
- lib/mindee/v2/file_operations/crop.rb
|
|
284
|
-
- lib/mindee/v2/file_operations/crop_files.rb
|
|
285
287
|
- lib/mindee/v2/file_operations/split.rb
|
|
286
|
-
- lib/mindee/v2/file_operations/split_files.rb
|
|
287
288
|
- lib/mindee/v2/http.rb
|
|
288
289
|
- lib/mindee/v2/http/.rubocop.yml
|
|
289
290
|
- lib/mindee/v2/http/api_v2_settings.rb
|
|
@@ -294,6 +295,7 @@ files:
|
|
|
294
295
|
- lib/mindee/v2/parsing/common_response.rb
|
|
295
296
|
- lib/mindee/v2/parsing/error_item.rb
|
|
296
297
|
- lib/mindee/v2/parsing/error_response.rb
|
|
298
|
+
- lib/mindee/v2/parsing/failed_inference_response.rb
|
|
297
299
|
- lib/mindee/v2/parsing/field.rb
|
|
298
300
|
- lib/mindee/v2/parsing/field/base_field.rb
|
|
299
301
|
- lib/mindee/v2/parsing/field/field_confidence.rb
|
|
@@ -375,6 +377,7 @@ files:
|
|
|
375
377
|
- sig/mindee/http/http_error_handler.rbs
|
|
376
378
|
- sig/mindee/http/response_validation.rbs
|
|
377
379
|
- sig/mindee/image/extracted_image.rbs
|
|
380
|
+
- sig/mindee/image/extracted_images.rbs
|
|
378
381
|
- sig/mindee/image/image_compressor.rbs
|
|
379
382
|
- sig/mindee/image/image_extractor.rbs
|
|
380
383
|
- sig/mindee/image/image_utils.rbs
|
|
@@ -390,6 +393,7 @@ files:
|
|
|
390
393
|
- sig/mindee/logging/logger.rbs
|
|
391
394
|
- sig/mindee/page_options.rbs
|
|
392
395
|
- sig/mindee/pdf/extracted_pdf.rbs
|
|
396
|
+
- sig/mindee/pdf/extracted_pdfs.rbs
|
|
393
397
|
- sig/mindee/pdf/pdf_compressor.rbs
|
|
394
398
|
- sig/mindee/pdf/pdf_extractor.rbs
|
|
395
399
|
- sig/mindee/pdf/pdf_processor.rbs
|
|
@@ -505,9 +509,7 @@ files:
|
|
|
505
509
|
- sig/mindee/v1/product/universal/universal_prediction.rbs
|
|
506
510
|
- sig/mindee/v2/client.rbs
|
|
507
511
|
- sig/mindee/v2/file_operation/crop.rbs
|
|
508
|
-
- sig/mindee/v2/file_operation/crop_files.rbs
|
|
509
512
|
- sig/mindee/v2/file_operation/split.rbs
|
|
510
|
-
- sig/mindee/v2/file_operation/split_files.rbs
|
|
511
513
|
- sig/mindee/v2/http/api_v2_settings.rbs
|
|
512
514
|
- sig/mindee/v2/http/mindee_api_v2.rbs
|
|
513
515
|
- sig/mindee/v2/parsing/base_inference.rbs
|
|
@@ -515,6 +517,7 @@ files:
|
|
|
515
517
|
- sig/mindee/v2/parsing/common_response.rbs
|
|
516
518
|
- sig/mindee/v2/parsing/error_item.rbs
|
|
517
519
|
- sig/mindee/v2/parsing/error_response.rbs
|
|
520
|
+
- sig/mindee/v2/parsing/failed_inference_response.rbs
|
|
518
521
|
- sig/mindee/v2/parsing/field/base_field.rbs
|
|
519
522
|
- sig/mindee/v2/parsing/field/field_confidence.rbs
|
|
520
523
|
- sig/mindee/v2/parsing/field/field_location.rbs
|
|
@@ -535,6 +538,7 @@ files:
|
|
|
535
538
|
- sig/mindee/v2/parsing/search/model_webhook.rbs
|
|
536
539
|
- sig/mindee/v2/parsing/search/pagination_metadata.rbs
|
|
537
540
|
- sig/mindee/v2/parsing/search/search_model.rbs
|
|
541
|
+
- sig/mindee/v2/parsing/search/search_models.rbs
|
|
538
542
|
- sig/mindee/v2/parsing/search/search_response.rbs
|
|
539
543
|
- sig/mindee/v2/parsing/search_models.rbs
|
|
540
544
|
- sig/mindee/v2/product/base_product.rbs
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Mindee
|
|
4
|
-
module V2
|
|
5
|
-
module FileOperation
|
|
6
|
-
# Collection of cropped files.
|
|
7
|
-
class CropFiles < Array
|
|
8
|
-
# Save all extracted crops to disk.
|
|
9
|
-
#
|
|
10
|
-
# @param path [String, Pathname] Path to save the extracted crops to.
|
|
11
|
-
# @param prefix [String] Prefix to add to the filename, defaults to 'crop'.
|
|
12
|
-
# @param file_format [String, nil] File format to save the crops as, defaults to jpg if nil.]
|
|
13
|
-
def save_all_to_disk(path, prefix: 'crop', file_format: nil)
|
|
14
|
-
FileUtils.mkdir_p(path)
|
|
15
|
-
each.with_index(1) do |crop, idx|
|
|
16
|
-
filename = "#{prefix}_#{format('%03d', idx)}.jpg"
|
|
17
|
-
file_path = File.join(path.to_s, filename)
|
|
18
|
-
|
|
19
|
-
crop.write_to_file(file_path, file_format)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Mindee
|
|
4
|
-
module V2
|
|
5
|
-
module FileOperation
|
|
6
|
-
# Collection of split files.
|
|
7
|
-
class SplitFiles < Array
|
|
8
|
-
# Save all extracted splits to disk.
|
|
9
|
-
#
|
|
10
|
-
# @param path [String, Pathname] Path to save the extracted splits to.
|
|
11
|
-
# @param prefix [String] Prefix to add to the filename, defaults to 'split'.
|
|
12
|
-
def save_all_to_disk(path, prefix: 'split')
|
|
13
|
-
FileUtils.mkdir_p(path)
|
|
14
|
-
|
|
15
|
-
each.with_index(1) do |split, idx|
|
|
16
|
-
filename = "#{prefix}_#{format('%03d', idx)}.pdf"
|
|
17
|
-
file_path = File.join(path.to_s, filename)
|
|
18
|
-
|
|
19
|
-
split.write_to_file(file_path)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|