百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
Y

yomu

> 编程语言
开源

从文件和文档(.doc、.docx、.pages、.odt、.rtf、.pdf)中读取文本和元数据

505 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

从文件和文档(.doc、.docx、.pages、.odt、.rtf、.pdf)中读取文本和元数据

Yomu 読む

Yomu is a library for extracting text and metadata from files and documents using the Apache Tika content analysis toolkit.

Here are some of the formats supported:

  • Microsoft Office OLE 2 and Office Open XML Formats (.doc, .docx, .xls, .xlsx, .ppt, .pptx)
  • OpenOffice.org OpenDocument Formats (.odt, .ods, .odp)
  • Apple iWorks Formats
  • Rich Text Format (.rtf)
  • Portable Document Format (.pdf)

For the complete list of supported formats, please visit the Apache Tika Supported Document Formats page.

Usage

Text, metadata and MIME type information can be extracted by calling Yomu.read directly:

ruby
require 'yomu'

data = File.read 'sample.pages'
text = Yomu.read :text, data
metadata = Yomu.read :metadata, data
mimetype = Yomu.read :mimetype, data

Reading text from a given filename

Create a new instance of Yomu and pass a filename.

ruby
yomu = Yomu.new 'sample.pages'
text = yomu.text

Reading text from a given URL

This is useful for reading remote files, like documents hosted on Amazon S3.

ruby
yomu = Yomu.new 'http://svn.apache.org/repos/asf/poi/trunk/test-data/document/sample.docx'
text = yomu.text

Reading text from a stream

Yomu can also read from a stream or any object that responds to read, including file uploads from Ruby on Rails or Sinatra.

ruby
post '/:name/:filename' do
  yomu = Yomu.new params[:data][:tempfile]
  yomu.text
end

Reading metadata

Metadata is returned as a hash.

ruby
yomu = Yomu.new 'sample.pages'
yomu.metadata['Content-Type'] #=> "application/vnd.apple.pages"

Reading MIME types

MIME type is returned as a MIME::Type object.

ruby
yomu = Yomu.new 'sample.docx'
yomu.mimetype.content_type #=> "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
yomu.mimetype.extensions #=> ['docx']

Installation and Dependencies

Java Runtime

Yomu packages the Apache Tika application jar and requires a working JRE for it to work.

Gem

Add this line to your application's Gemfile:

gem 'yomu'

And then execute:

$ bundle

Or install it yourself as:

$ gem install yomu

Contributing

  1. Fork it
  2. Create your feature branch ( git checkout -b my-new-feature )
  3. Create tests and make them pass ( rake test )
  4. Commit your changes ( git commit -am 'Added some feature' )
  5. Push to the branch ( git push origin my-new-feature )
  6. Create a new Pull Request

Issues· 27 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言