转载:http://cloudera.iteye.com/blog/737629
apache 是个伟大的组织。
在lucene 检索 如火如荼时, apache不忘继续努力,近期提供了对各种格式文件进行解析的解决方案 -- apache旗下的tika. 虽然还没有1.0版 , 但已经很好用:
-
-
-
-
-
-
public static String parse(String path) {
-
String result = "";
- TikaConfig tikaConfig = TikaConfig.getDefaultConfig();
-
try {
-
result = ParseUtils.getStringContent(new File(path), tikaConfig);
-
}catch (Exception e) {
-
log.debug("[by ninja.hzw]" + e);
- }
-
return result;
- }
/**
* 解析各种类型文件
* @param 文件路径
* @return 文件内容字符串
*/
public static String parse(String path) {
String result = "";
TikaConfig tikaConfig = TikaConfig.getDefaultConfig();
try {
result = ParseUtils.getStringContent(new File(path), tikaConfig);
}catch (Exception e) {
log.debug("[by ninja.hzw]" + e);
}
return result;
}
很简单,可以解析各种文件,返回文档内容字符串, word2003/2007 、 pdf 、 txt 都经过测试,均能解析且无乱码问题。
oh, Great Apach
Tika 的下载和打包:
下载不用多说,google 一下“apache tika” 找到其官网下载即可。
- To build Tika from sources you first need to either download a source release or checkout the latest sources from version control.
-
-
Once you have the sources, you can build them using the Maven 2 build system. Executing the following command in the base directory will build the sources and install the resulting artifacts in your local Maven repository.
-
- mvn install
To build Tika from sources you first need to either download a source release or checkout the latest sources from version control.
Once you have the sources, you can build them using the Maven 2 build system. Executing the following command in the base directory will build the sources and install the resulting artifacts in your local Maven repository.
mvn install
apache 已经说得很清楚,进入下载后的tika 目录 ,然后执行maven install 即可。(当然这里需要您懂得maven2的使用。当然不会的朋友可以联系我^^ . 还需注意,必须为jdk1.5 + 才能成功编译打包。)
打包完后产生以下 jar:
- tika-core/target/tika-core-0.7.jar
-
Tika core library. Contains the core interfaces and classes of Tika, but none of the parser implementations. Depends only on Java 5.
-
tika-parsers/target/tika-parsers-0.7.jar
-
Tika parsers. Collection of classes that implement the Tika Parser interface based on various external parser libraries.
-
tika-app/target/tika-app-0.7.jar
-
Tika application. Combines the above libraries and all the external parser libraries into a single runnable jar with a GUI and a command line interface.
-
tika-bundle/target/tika-bundle-0.7.jar
- Tika bundle. An OSGi bundle that includes everything you need to use all Tika functionality in an OSGi environment.
tika-core/target/tika-core-0.7.jar
Tika core library. Contains the core interfaces and classes of Tika, but none of the parser implementations. Depends only on Java 5.
tika-parsers/target/tika-parsers-0.7.jar
Tika parsers. Collection of classes that implement the Tika Parser interface based on various external parser libraries.
tika-app/target/tika-app-0.7.jar
Tika application. Combines the above libraries and all the external parser libraries into a single runnable jar with a GUI and a command line interface.
tika-bundle/target/tika-bundle-0.7.jar
Tika bundle. An OSGi bundle that includes everything you need to use all Tika functionality in an OSGi environment.
我们要想做文档解析,只需引入tika-core 和 tika-parsers 即可。
当然如果您的项目是maven 构建的,那更好了。在pom里加上依赖:
- <dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-core</artifactId>
-
<version>0.7</version>
- </dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>0.7</version>
</dependency>
以及
- <dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-parsers</artifactId>
-
<version>0.7</version>
- </dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>0.7</version>
</dependency>
maven 会自动下载。(感谢maven官方的支持。)
分享到:
相关推荐
apache-tika-0.8-src.jar 源码
tika-python 绑定到 Apache Tika REST 服务 Python binding to the Apache Tika REST services Apache Tika 库的 Python 端口,可使用 Tika REST 服务器使 Tika 可用。这使得 Apache Tika 可作为 Python 库使用,可...
apache-tika-1.0-src.zip,tika 1.0版本 源码包,看孔浩的搜索引擎视频用到的。
tika 1.2 内容收集,包含了poi等工具,可处理word、pdf等文档
Tika是Apache下开源的文档内容解析工具,支持上千种文档格式(如PPT、XLS、PDF)。Tika使用统一的方法对各种类型文件进行内容解析,封装了各种格式解析的内部实现,可用于搜索引擎索引、内容分析、转换等场景。
Apache Tika 利用现有的解析类库,从不同格式的文档中(例如HTML, PDF, Doc),侦测和提取出元数据和结构化内容。 功能包括: 侦测文档的类型,字符编码,语言,等其他现有文档的属性。 提取结构化的文字内容。...
Apache Tika本产品包括在以下位置开发的软件Apache软件基金会。版权所有1993-2010大学大气研究公司/ Unidata该软件包含源自UCAR / Unidata的NetCDF库的代码。Tika服务器组件使用CDDL许可的依赖项
apache-tika-1.2-src.zip
下载Apache的tika项目时发现网上没有现成的tika的jar文件,只能自己编译一个了。可能大家也会遇到这个问题。所以将编译好的jar包传上来于大家分享。其中包含了tika-app-0.5.jar,tika-core-0.5.jar,tika-parsers-...
tika-app-1.7.jar
tika-app-1.16,java文档内容提取工具jar包,可提取office文档内容
提卡示例 使用Apache Tika进行文件类型检测 使用检测项目中文件的类型(csv,xml等)。 一个有关我的即将发布的博客文章的项目。
Apache Tika解析doc/docx/txt/xls等文件内容,可以很方便地将文档内容提取出来,方便做全文检索使用。
apache基金项目tika,是一个可以对内容进行分析、提取的开发包,结合正则开发包,可以开发基于垂直搜索引擎,目前正处于孵化阶段,这里是目前的最新版本
tika-app.1.19.1.jar,轻松提取文本正文的工具。。。。
检测并提取来自上千种不同文件类型(如PPT,XLS和PDF)中的元数据和结构化文本。除了用gui进行操作外,还可以在命令行界面中使用java -jar tika-app-1.15.jar --text .doc命令进行文本格式的转换,text为要转变的...
ache tika 0.9 source 源文件 已经使用mvn生成对应的jar文件;app没有,需单独下载
最新tika1.8,可以帮助lucene的开发,提取文档的内容
Tika-Python是与Apache Tika:trade_mark:REST服务绑定的Python,允许在Python社区中本地调用Tika。 tika-python Apache Tika库的Python端口,可通过Tika REST Server使Tika可用。 这使得Apache Tika可以作为Python库...
这使得Apache Tika可以作为Python库使用,可以通过Setuptools,Pip和Easy Install进行安装。 要使用此库,您需要在系统上安装Java 7+,因为tika-python在后台启动Tika REST服务器。 受到启发。安装(带点子) pip ...