Class: Libera::Parser
- Inherits:
-
Object
- Object
- Libera::Parser
- Defined in:
- lib/libera.rb
Instance Method Summary collapse
Instance Method Details
#generate_tei(page_list) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# 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 ⇒ Object
84 85 86 87 |
# 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) ⇒ Object
65 66 67 68 69 |
# 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 |