class Libera::Parser

Public Instance Methods

generate_tei(page_list) click to toggle source
# File lib/libera.rb, line 71
def generate_tei(page_list)
  tei_path = "#{Libera.configuration.working_dir}/tei.xml"
  tei_xml = Libera::Tei.new
  
  page_list.each do |k, v|
    tei_xml.add_page_break(k)
    tei_xml.add_anon_block(v)
  end
  
  # write out xml to file
  IO.write(tei_path, tei_xml.to_xml)
end
mk_working_dir() click to toggle source
# File lib/libera.rb, line 84
def mk_working_dir
  # Check if working dir exists - If not, make it
  FileUtils.mkdir_p("#{Libera.configuration.working_dir}") unless File.exists? "#{Libera.configuration.working_dir}"
end
parse_image(image_path, i) click to toggle source
# File lib/libera.rb, line 65
def parse_image(image_path, i)
  file_path = "#{Libera.configuration.working_dir}/pdf-page-#{i}"
  `tesseract #{image_path} #{file_path} >> /dev/null 2>&1`
  return File.read(file_path + ".txt")
end