-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #247 Test
- Loading branch information
Showing
6 changed files
with
103 additions
and
0 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
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<properties> | ||
<parsers> | ||
<!-- https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=109454096#TikaOCR-OverridingDefaultConfiguration --> | ||
<parser class="org.apache.tika.parser.DefaultParser"> | ||
<parser-exclude class="org.apache.tika.parser.ocr.TesseractOCRParser"/> | ||
</parser> | ||
<parser class="org.apache.tika.parser.ocr.TesseractOCRParser"> | ||
<params> | ||
<param name="language" type="string">eng+ara+spa+fra+por</param> | ||
</params> | ||
</parser> | ||
</parsers> | ||
</properties> |
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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Heathen | ||
class Processor | ||
def detect_language | ||
expect_mime_type 'application/pdf' | ||
|
||
executioner.execute( | ||
Colore::C_.tika_path, | ||
"--config=#{File.expand_path('../../config/tika.yml', __dir__)}", | ||
'--language', | ||
job.content_file, | ||
binary: true | ||
) | ||
|
||
job.content = executioner.stdout | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe Heathen::Processor do | ||
let(:content) { File.read(fixture('heathen/quickfox.pdf')) } | ||
let(:job) { Heathen::Job.new 'foo', content, 'en' } | ||
let(:processor) { described_class.new job: job, logger: Logger.new($stderr) } | ||
|
||
after do | ||
processor.clean_up | ||
end | ||
|
||
context '#detect_language' do | ||
it 'detects input file language' do | ||
processor.detect_language | ||
expect(job.content).to eq 'en' | ||
end | ||
end | ||
end |