Class: Mindee::Product::InvoiceSplitter::InvoiceSplitterV1Document

Inherits:
Mindee::Parsing::Common::Prediction show all
Defined in:
lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb

Overview

Invoice Splitter V1 document prediction.

Direct Known Subclasses

InvoiceSplitterV1PagePrediction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction, _page_id) ⇒ InvoiceSplitterV1Document

Returns a new instance of InvoiceSplitterV1Document.

Parameters:

  • prediction (Hash)
  • _page_id (Integer, nil)


37
38
39
40
# File 'lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb', line 37

def initialize(prediction, _page_id)
  super()
  construct_invoice_page_groups_from_prediction(prediction)
end

Instance Attribute Details

#invoice_page_groupsObject (readonly)



33
34
35
# File 'lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb', line 33

def invoice_page_groups
  @invoice_page_groups
end

Instance Method Details

#construct_invoice_page_groups_from_prediction(prediction) ⇒ Object

Reconstructs the page groups of a prediction

Parameters:

  • prediction (hash)


44
45
46
47
48
49
50
51
# File 'lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb', line 44

def construct_invoice_page_groups_from_prediction(prediction)
  @invoice_page_groups = []
  return unless prediction.key?('invoice_page_groups') && prediction['invoice_page_groups'].any?

  prediction['invoice_page_groups'].each do |page_group_prediction|
    @invoice_page_groups.append(InvoiceSplitterV1PageGroup.new(page_group_prediction))
  end
end

#to_sString

Returns:

  • (String)


54
55
56
57
58
59
60
61
62
63
# File 'lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb', line 54

def to_s
  out_str = String.new
  out_str << "\n:Invoice Page Groups:"
  if !@invoice_page_groups.nil? && @invoice_page_groups.any?
    @invoice_page_groups.map do |page|
      out_str << "\n  #{page}"
    end
  end
  out_str[1..].to_s
end