rtesseract 2.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.document +1 -2
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +13 -10
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -17
- data/Gemfile.lock +40 -85
- data/LICENSE.txt +18 -17
- data/README.md +137 -0
- data/Rakefile +4 -48
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rtesseract.rb +22 -220
- data/lib/rtesseract/box.rb +15 -60
- data/lib/rtesseract/check.rb +14 -0
- data/lib/rtesseract/command.rb +41 -0
- data/lib/rtesseract/configuration.rb +15 -64
- data/lib/rtesseract/pdf.rb +18 -0
- data/lib/rtesseract/text.rb +9 -0
- data/lib/rtesseract/tsv.rb +18 -0
- data/lib/rtesseract/version.rb +3 -0
- data/rtesseract.gemspec +27 -98
- metadata +36 -85
- data/README.rdoc +0 -156
- data/VERSION +0 -1
- data/lib/processors/mini_magick.rb +0 -43
- data/lib/processors/none.rb +0 -34
- data/lib/processors/rmagick.rb +0 -46
- data/lib/rtesseract/blob.rb +0 -34
- data/lib/rtesseract/box_char.rb +0 -31
- data/lib/rtesseract/errors.rb +0 -21
- data/lib/rtesseract/mixed.rb +0 -54
- data/lib/rtesseract/processor.rb +0 -19
- data/lib/rtesseract/utils.rb +0 -44
- data/lib/rtesseract/uzn.rb +0 -47
- data/spec/configs/eng.user-words.txt +0 -13
- data/spec/images/README.pdf +0 -0
- data/spec/images/blank.tif +0 -0
- data/spec/images/mixed.tif +0 -0
- data/spec/images/orientation_reverse.png +0 -0
- data/spec/images/test with spaces.tif +0 -0
- data/spec/images/test-pdf.png +0 -0
- data/spec/images/test.bmp +0 -0
- data/spec/images/test.jpg +0 -0
- data/spec/images/test.png +0 -0
- data/spec/images/test.tif +0 -0
- data/spec/images/test1.tif +0 -0
- data/spec/images/test_words.png +0 -0
- data/spec/rtesseract_box_char_spec.rb +0 -82
- data/spec/rtesseract_box_spec.rb +0 -36
- data/spec/rtesseract_mixed_spec.rb +0 -49
- data/spec/rtesseract_spec.rb +0 -282
- data/spec/rtesseract_uzn_spec.rb +0 -56
- data/spec/spec_helper.rb +0 -21
data/spec/rtesseract_uzn_spec.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
3
|
-
|
4
|
-
describe 'Rtesseract::Uzn' do
|
5
|
-
before do
|
6
|
-
@path = Pathname.new(__FILE__.gsub('rtesseract_uzn_spec.rb', '')).expand_path
|
7
|
-
@image_tif = @path.join('images', 'mixed.tif').to_s
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should be instantiable' do
|
11
|
-
expect(RTesseract::Uzn.new.class).to eql(RTesseract::Uzn)
|
12
|
-
expect(RTesseract::Uzn.new(@image_tif).class).to eql(RTesseract::Uzn)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should translate parts of the image to text from a block' do
|
16
|
-
uzn_block = RTesseract::Uzn.new(@image_tif) do |image|
|
17
|
-
image.area(x: 28, y: 19, w: 25, h: 25) # position of 4
|
18
|
-
image.area(x: 180, y: 22, w: 20, h: 28) # position of 3
|
19
|
-
image.area(x: 218, y: 22, w: 24, h: 28) # position of F
|
20
|
-
image.area(x: 248, y: 24, w: 22, h: 22) # position of F
|
21
|
-
end
|
22
|
-
|
23
|
-
expect(uzn_block.to_s_without_spaces).to eql('43FF')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should translate parts of the image to text from initializer options' do
|
27
|
-
@areas = []
|
28
|
-
@areas << { x: 28, y: 19, w: 25, h: 25 } # position of 4
|
29
|
-
@areas << { x: 180, y: 22, w: 20, h: 28 } # position of 3
|
30
|
-
@areas << { x: 218, y: 22, w: 24, h: 28 } # position of f
|
31
|
-
@areas << { x: 248, y: 24, w: 22, h: 22 } # position of f
|
32
|
-
|
33
|
-
uzn_block = RTesseract::Uzn.new(@image_tif, areas: @areas)
|
34
|
-
expect(uzn_block.to_s_without_spaces).to eql('43FF')
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should handle a blank image' do
|
38
|
-
@areas = []
|
39
|
-
@areas << { x: 28, y: 19, w: 25, h: 25 } # position of 4
|
40
|
-
@areas << { x: 180, y: 22, w: 20, h: 28 } # position of 3
|
41
|
-
@areas << { x: 218, y: 22, w: 24, h: 28 } # position of f
|
42
|
-
@areas << { x: 248, y: 24, w: 22, h: 22 } # position of f
|
43
|
-
uzn_block = RTesseract::Uzn.new(@path.join('images', 'blank.tif').to_s, areas: @areas)
|
44
|
-
expect(uzn_block.to_s_without_spaces).to eql('')
|
45
|
-
end
|
46
|
-
|
47
|
-
it ' get a error' do
|
48
|
-
@areas = [{ x: 28, y: 19, w: 25, h: 25 }]
|
49
|
-
|
50
|
-
uzn_block = RTesseract::Uzn.new(@path.join('images', 'test_not_exists.png').to_s, areas: @areas, psm: 7)
|
51
|
-
expect { uzn_block.to_s_without_spaces }.to raise_error(RTesseract::ImageNotSelectedError)
|
52
|
-
|
53
|
-
uzn_block = RTesseract::Uzn.new(@image_tif, areas: @areas, psm: 7, command: 'tesseract_error')
|
54
|
-
expect { uzn_block.to_s }.to raise_error(RTesseract::ConversionError)
|
55
|
-
end
|
56
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
-
require 'rspec'
|
5
|
-
require 'coveralls'
|
6
|
-
require 'simplecov'
|
7
|
-
SimpleCov.start do
|
8
|
-
add_filter '/spec/'
|
9
|
-
end
|
10
|
-
Coveralls.wear!
|
11
|
-
|
12
|
-
require 'rtesseract'
|
13
|
-
# Requires supporting files with custom matchers and macros, etc,
|
14
|
-
# in ./support/ and its subdirectories.
|
15
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
16
|
-
|
17
|
-
RSpec.configure do |config|
|
18
|
-
config.after(:each) do
|
19
|
-
RTesseract.configuration = RTesseract::Configuration.new
|
20
|
-
end
|
21
|
-
end
|