Class: Kreuzberg::Result::OcrElement

Inherits:
Object
  • Object
show all
Defined in:
lib/kreuzberg/result.rb

Overview

OCR text element with geometry and metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, geometry: nil, confidence: nil, level: nil, rotation: nil, page_number: nil, parent_id: nil, backend_metadata: nil) ⇒ OcrElement

Returns a new instance of OcrElement.



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/kreuzberg/result.rb', line 306

def initialize(
  text:,
  geometry: nil,
  confidence: nil,
  level: nil,
  rotation: nil,
  page_number: nil,
  parent_id: nil,
  backend_metadata: nil
)
  @text = text.to_s
  @geometry = geometry
  @confidence = confidence
  @level = level&.to_s
  @rotation = rotation
  @page_number = page_number&.to_i
  @parent_id = parent_id&.to_s
  @backend_metadata = 
end

Instance Attribute Details

#backend_metadataObject (readonly)

Returns the value of attribute backend_metadata.



303
304
305
# File 'lib/kreuzberg/result.rb', line 303

def 
  @backend_metadata
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



303
304
305
# File 'lib/kreuzberg/result.rb', line 303

def confidence
  @confidence
end

#geometryObject (readonly)

Returns the value of attribute geometry.



303
304
305
# File 'lib/kreuzberg/result.rb', line 303

def geometry
  @geometry
end

#levelObject (readonly)

Returns the value of attribute level.



303
304
305
# File 'lib/kreuzberg/result.rb', line 303

def level
  @level
end

#page_numberObject (readonly)

Returns the value of attribute page_number.



303
304
305
# File 'lib/kreuzberg/result.rb', line 303

def page_number
  @page_number
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



303
304
305
# File 'lib/kreuzberg/result.rb', line 303

def parent_id
  @parent_id
end

#rotationObject (readonly)

Returns the value of attribute rotation.



303
304
305
# File 'lib/kreuzberg/result.rb', line 303

def rotation
  @rotation
end

#textObject (readonly)

Returns the value of attribute text.



303
304
305
# File 'lib/kreuzberg/result.rb', line 303

def text
  @text
end

Instance Method Details

#to_hObject



326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/kreuzberg/result.rb', line 326

def to_h
  {
    text: @text,
    geometry: @geometry&.to_h,
    confidence: @confidence&.to_h,
    level: @level,
    rotation: @rotation&.to_h,
    page_number: @page_number,
    parent_id: @parent_id,
    backend_metadata: @backend_metadata
  }.compact
end