mindee 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
|
|
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
|
|
@@ -174,8 +174,8 @@ description: Quickly and easily connect to Mindee's API services using Ruby.
|
|
|
174
174
|
email:
|
|
175
175
|
- opensource@mindee.co
|
|
176
176
|
executables:
|
|
177
|
-
- mindee.rb
|
|
178
177
|
- console
|
|
178
|
+
- mindee.rb
|
|
179
179
|
extensions: []
|
|
180
180
|
extra_rdoc_files: []
|
|
181
181
|
files:
|
|
@@ -193,6 +193,7 @@ files:
|
|
|
193
193
|
- LICENSE
|
|
194
194
|
- README.md
|
|
195
195
|
- Rakefile
|
|
196
|
+
- SKILL.md
|
|
196
197
|
- Steepfile
|
|
197
198
|
- bin/console
|
|
198
199
|
- bin/mindee.rb
|
|
@@ -250,6 +251,7 @@ files:
|
|
|
250
251
|
- lib/mindee/http/response_validation.rb
|
|
251
252
|
- lib/mindee/image.rb
|
|
252
253
|
- lib/mindee/image/extracted_image.rb
|
|
254
|
+
- lib/mindee/image/extracted_images.rb
|
|
253
255
|
- lib/mindee/image/image_compressor.rb
|
|
254
256
|
- lib/mindee/image/image_extractor.rb
|
|
255
257
|
- lib/mindee/image/image_utils.rb
|
|
@@ -269,6 +271,7 @@ files:
|
|
|
269
271
|
- lib/mindee/page_options.rb
|
|
270
272
|
- lib/mindee/pdf.rb
|
|
271
273
|
- lib/mindee/pdf/extracted_pdf.rb
|
|
274
|
+
- lib/mindee/pdf/extracted_pdfs.rb
|
|
272
275
|
- lib/mindee/pdf/pdf_compressor.rb
|
|
273
276
|
- lib/mindee/pdf/pdf_extractor.rb
|
|
274
277
|
- lib/mindee/pdf/pdf_processor.rb
|
|
@@ -398,9 +401,7 @@ files:
|
|
|
398
401
|
- lib/mindee/v2/client.rb
|
|
399
402
|
- lib/mindee/v2/file_operations.rb
|
|
400
403
|
- lib/mindee/v2/file_operations/crop.rb
|
|
401
|
-
- lib/mindee/v2/file_operations/crop_files.rb
|
|
402
404
|
- lib/mindee/v2/file_operations/split.rb
|
|
403
|
-
- lib/mindee/v2/file_operations/split_files.rb
|
|
404
405
|
- lib/mindee/v2/http.rb
|
|
405
406
|
- lib/mindee/v2/http/.rubocop.yml
|
|
406
407
|
- lib/mindee/v2/http/api_v2_settings.rb
|
|
@@ -411,6 +412,7 @@ files:
|
|
|
411
412
|
- lib/mindee/v2/parsing/common_response.rb
|
|
412
413
|
- lib/mindee/v2/parsing/error_item.rb
|
|
413
414
|
- lib/mindee/v2/parsing/error_response.rb
|
|
415
|
+
- lib/mindee/v2/parsing/failed_inference_response.rb
|
|
414
416
|
- lib/mindee/v2/parsing/field.rb
|
|
415
417
|
- lib/mindee/v2/parsing/field/base_field.rb
|
|
416
418
|
- lib/mindee/v2/parsing/field/field_confidence.rb
|
|
@@ -492,6 +494,7 @@ files:
|
|
|
492
494
|
- sig/mindee/http/http_error_handler.rbs
|
|
493
495
|
- sig/mindee/http/response_validation.rbs
|
|
494
496
|
- sig/mindee/image/extracted_image.rbs
|
|
497
|
+
- sig/mindee/image/extracted_images.rbs
|
|
495
498
|
- sig/mindee/image/image_compressor.rbs
|
|
496
499
|
- sig/mindee/image/image_extractor.rbs
|
|
497
500
|
- sig/mindee/image/image_utils.rbs
|
|
@@ -507,6 +510,7 @@ files:
|
|
|
507
510
|
- sig/mindee/logging/logger.rbs
|
|
508
511
|
- sig/mindee/page_options.rbs
|
|
509
512
|
- sig/mindee/pdf/extracted_pdf.rbs
|
|
513
|
+
- sig/mindee/pdf/extracted_pdfs.rbs
|
|
510
514
|
- sig/mindee/pdf/pdf_compressor.rbs
|
|
511
515
|
- sig/mindee/pdf/pdf_extractor.rbs
|
|
512
516
|
- sig/mindee/pdf/pdf_processor.rbs
|
|
@@ -622,9 +626,7 @@ files:
|
|
|
622
626
|
- sig/mindee/v1/product/universal/universal_prediction.rbs
|
|
623
627
|
- sig/mindee/v2/client.rbs
|
|
624
628
|
- sig/mindee/v2/file_operation/crop.rbs
|
|
625
|
-
- sig/mindee/v2/file_operation/crop_files.rbs
|
|
626
629
|
- sig/mindee/v2/file_operation/split.rbs
|
|
627
|
-
- sig/mindee/v2/file_operation/split_files.rbs
|
|
628
630
|
- sig/mindee/v2/http/api_v2_settings.rbs
|
|
629
631
|
- sig/mindee/v2/http/mindee_api_v2.rbs
|
|
630
632
|
- sig/mindee/v2/parsing/base_inference.rbs
|
|
@@ -632,6 +634,7 @@ files:
|
|
|
632
634
|
- sig/mindee/v2/parsing/common_response.rbs
|
|
633
635
|
- sig/mindee/v2/parsing/error_item.rbs
|
|
634
636
|
- sig/mindee/v2/parsing/error_response.rbs
|
|
637
|
+
- sig/mindee/v2/parsing/failed_inference_response.rbs
|
|
635
638
|
- sig/mindee/v2/parsing/field/base_field.rbs
|
|
636
639
|
- sig/mindee/v2/parsing/field/field_confidence.rbs
|
|
637
640
|
- sig/mindee/v2/parsing/field/field_location.rbs
|
|
@@ -652,6 +655,7 @@ files:
|
|
|
652
655
|
- sig/mindee/v2/parsing/search/model_webhook.rbs
|
|
653
656
|
- sig/mindee/v2/parsing/search/pagination_metadata.rbs
|
|
654
657
|
- sig/mindee/v2/parsing/search/search_model.rbs
|
|
658
|
+
- sig/mindee/v2/parsing/search/search_models.rbs
|
|
655
659
|
- sig/mindee/v2/parsing/search/search_response.rbs
|
|
656
660
|
- sig/mindee/v2/parsing/search_models.rbs
|
|
657
661
|
- 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
|