Class: Mindee::V2::Product::OCR::OCRPage

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/v2/product/ocr/ocr_page.rb

Overview

OCR result for a single page.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ OCRPage

Returns a new instance of OCRPage.

Parameters:

  • server_response (Hash)

    Hash representation of the JSON returned by the service.



17
18
19
20
# File 'lib/mindee/v2/product/ocr/ocr_page.rb', line 17

def initialize(server_response)
  @words = server_response['words'].map { |word| OCRWord.new(word) }
  @content = server_response['content']
end

Instance Attribute Details

#contentString (readonly)

Returns Full text content extracted from the document page.

Returns:

  • (String)

    Full text content extracted from the document page.



14
15
16
# File 'lib/mindee/v2/product/ocr/ocr_page.rb', line 14

def content
  @content
end

#wordsArray<OCRWord> (readonly)

Returns List of words extracted from the document page.

Returns:

  • (Array<OCRWord>)

    List of words extracted from the document page.



12
13
14
# File 'lib/mindee/v2/product/ocr/ocr_page.rb', line 12

def words
  @words
end

Instance Method Details

#to_sString

String representation.

Returns:

  • (String)


24
25
26
27
28
# File 'lib/mindee/v2/product/ocr/ocr_page.rb', line 24

def to_s
  ocr_words = "\n"
  ocr_words += @words.join("\n\n") if @words&.any?
  "OCR Words\n======#{ocr_words}\n\n:Content: #{@content}"
end