Class: Kreuzberg::Config::OCR

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backend: 'tesseract', language: 'eng', tesseract_config: nil, paddle_ocr_config: nil, element_config: nil) ⇒ OCR

Returns a new instance of OCR.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kreuzberg/config.rb', line 11

def initialize(
  backend: 'tesseract',
  language: 'eng',
  tesseract_config: nil,
  paddle_ocr_config: nil,
  element_config: nil
)
  @backend = backend.to_s
  @language = language.to_s
  @tesseract_config = normalize_tesseract_config(tesseract_config)
  @paddle_ocr_config = normalize_paddle_ocr_config(paddle_ocr_config)
  @element_config = normalize_element_config(element_config)
end

Instance Attribute Details

#backendObject (readonly)

Returns the value of attribute backend.



9
10
11
# File 'lib/kreuzberg/config.rb', line 9

def backend
  @backend
end

#element_configObject (readonly)

Returns the value of attribute element_config.



9
10
11
# File 'lib/kreuzberg/config.rb', line 9

def element_config
  @element_config
end

#languageObject (readonly)

Returns the value of attribute language.



9
10
11
# File 'lib/kreuzberg/config.rb', line 9

def language
  @language
end

#paddle_ocr_configObject (readonly)

Returns the value of attribute paddle_ocr_config.



9
10
11
# File 'lib/kreuzberg/config.rb', line 9

def paddle_ocr_config
  @paddle_ocr_config
end

#tesseract_configObject (readonly)

Returns the value of attribute tesseract_config.



9
10
11
# File 'lib/kreuzberg/config.rb', line 9

def tesseract_config
  @tesseract_config
end

Instance Method Details

#to_hObject



25
26
27
28
29
30
31
32
33
# File 'lib/kreuzberg/config.rb', line 25

def to_h
  {
    backend: @backend,
    language: @language,
    tesseract_config: @tesseract_config&.to_h,
    paddle_ocr_config: @paddle_ocr_config&.to_h,
    element_config: @element_config&.to_h
  }.compact
end