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.



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/kreuzberg/result.rb', line 282

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.



279
280
281
# File 'lib/kreuzberg/result.rb', line 279

def 
  @backend_metadata
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



279
280
281
# File 'lib/kreuzberg/result.rb', line 279

def confidence
  @confidence
end

#geometryObject (readonly)

Returns the value of attribute geometry.



279
280
281
# File 'lib/kreuzberg/result.rb', line 279

def geometry
  @geometry
end

#levelObject (readonly)

Returns the value of attribute level.



279
280
281
# File 'lib/kreuzberg/result.rb', line 279

def level
  @level
end

#page_numberObject (readonly)

Returns the value of attribute page_number.



279
280
281
# File 'lib/kreuzberg/result.rb', line 279

def page_number
  @page_number
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



279
280
281
# File 'lib/kreuzberg/result.rb', line 279

def parent_id
  @parent_id
end

#rotationObject (readonly)

Returns the value of attribute rotation.



279
280
281
# File 'lib/kreuzberg/result.rb', line 279

def rotation
  @rotation
end

#textObject (readonly)

Returns the value of attribute text.



279
280
281
# File 'lib/kreuzberg/result.rb', line 279

def text
  @text
end

Instance Method Details

#to_hObject



302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/kreuzberg/result.rb', line 302

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