Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
165 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI | ||
on: [push] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
ruby: | ||
- '2.5.x' | ||
- '2.6.x' | ||
- '2.7.x' | ||
steps: | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install tesseract-ocr | ||
run: | | ||
sudo add-apt-repository ppa:alex-p/tesseract-ocr -y | ||
sudo apt-get update -q | ||
sudo apt-get install tesseract-ocr tesseract-ocr-eng ghostscript -y | ||
- name: Setup Ruby | ||
uses: actions/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
- name: Bundle | ||
env: | ||
MTSR_RAILS_VERSION: ${{ matrix.rails }} | ||
run: | | ||
gem uninstall -aIx bundler | ||
gem install bundler | ||
bundle install --jobs 4 --retry 3 | ||
- name: Test | ||
run: bundle exec rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RTesseract::Text do | ||
let(:path) { Pathname.new(File.dirname(__FILE__)).join('..') } | ||
let(:image_path) { path.join('resources', 'test.tif').to_s } | ||
let(:pdf_path) { path.join('resources', 'test.tif').to_s } | ||
|
||
let(:words_image) { path.join('resources', 'test_words.png').to_s } | ||
|
||
it 'translate image to text' do | ||
expect(RTesseract.new(image_path).to_s_without_spaces).to eql('43XF') | ||
end | ||
|
||
it 'translate tif image to text' do | ||
expect(RTesseract.new(path.join('resources', 'test1.tif').to_s).to_s_without_spaces).to eql('V2V4') | ||
end | ||
|
||
it 'translate tif image with spaces to text' do | ||
expect(RTesseract.new(path.join('resources', 'test with spaces.tif').to_s).to_s_without_spaces).to eql('V2V4') | ||
end | ||
|
||
it 'translate png image with spaces to text' do | ||
expect(RTesseract.new(path.join('resources', 'test.png').to_s).to_s_without_spaces).to eql('HW9W') | ||
end | ||
|
||
it 'translate jpg image with spaces to text' do | ||
expect(RTesseract.new(path.join('resources', 'test.jpg').to_s).to_s_without_spaces).to eql('3R8F') | ||
end | ||
|
||
it 'translate image to text with options' do | ||
expect(RTesseract.new(image_path, psm: 7, oem: 1).to_s_without_spaces).to eql('43XF') | ||
end | ||
|
||
it 'tests output text' do | ||
expect(RTesseract.new(words_image).to_s).to eql("If you are a friend,\nyou speak the password,\nand the doors will open.\n\f") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'csv' | ||
|
||
RSpec.describe RTesseract::Tsv do | ||
let(:path) { Pathname.new(File.dirname(__FILE__)).join('..') } | ||
let(:words_image) { path.join('resources', 'test_words.png').to_s } | ||
let(:file) { RTesseract.new(words_image).to_tsv } | ||
|
||
it ' support tsv output mode' do | ||
tsv_ocr = RTesseract.new(words_image).to_tsv | ||
after do | ||
file.close | ||
File.unlink(file) | ||
end | ||
|
||
expect(File.extname(tsv_ocr.path)).to eql('.tsv') | ||
expect(tsv_ocr.read).to include('level page_num block_num par_num line_num word_num left top width height conf text') | ||
it 'returns a file with extension .tsv' do | ||
expect(File.extname(file.path)).to eql('.tsv') | ||
end | ||
|
||
tsv_ocr.close | ||
File.unlink(tsv_ocr) | ||
it ' support tsv output mode' do | ||
expect(file.read).to include('level page_num block_num par_num line_num word_num left top width height conf text') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
c.syntax = :expect | ||
end | ||
|
||
config.before(:each) do | ||
config.before do | ||
RTesseract.reset_config! | ||
end | ||
end |