-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from Erol/general-document-reader-using-yomu
Add a general document reader class using Yomu
- Loading branch information
Showing
6 changed files
with
24 additions
and
5 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
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,17 @@ | ||
require 'yomu' | ||
|
||
# This class is a wrapper for Yomu. | ||
# Yomu is a library for extracting text and metadata from files and documents | ||
# using the Apache Tika content analysis toolkit. | ||
class Treat::Workers::Formatters::Readers::Document | ||
# Extract the readable text from any document. | ||
# | ||
# Options: none. | ||
def self.read(document, options = {}) | ||
yomu = Yomu.new(document.file) | ||
|
||
document.value = yomu.text | ||
document.set :format, yomu.mimetype.extensions.first | ||
document | ||
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
Binary file not shown.
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