介绍一下Hyper Estraier

HyperEstraier是一款用C语言编写的全文搜索引擎,支持Java、Ruby和Perl等API。本文介绍其安装、配置及使用方法,包括命令行工具estcmd.exe的使用,以及如何通过Java API进行索引创建和搜索。
部署运行你感兴趣的模型镜像
介绍一下Hyper Estraier 
Hyper Estraier 是一个来自日本的全文搜索引擎,作者是 Mikio Hirabayashi,目前最高版本是1.49。

可以从这里下载编译好的版本



这个引擎使用C语言开发,另外还提供了java以及ruby、perl语言的上层API。该引擎使用2.1版本的GNU Lesser General Public License作为开源协议,LGPL算是一个商业友好的License吧,大家可以放心地用在自己的工程中。



将hyperestraier-1.4.9-win32.zip解压缩到d:\hyperestraier文件夹,从中可以找到README-en.txt这个文件,这个文件中简要介绍了重要文件的清单,大家可以先看一下,熟悉下情况,其中重点关注的是estcmd.exe和estraier.jar。

下面主要围绕这两个文件做下介绍

estcmd.exe是一个命令行工具,通过它,可以完成基本的搜索工作,供大家测试之用;

estraier.jar的全称是Java Binding of Hyper Estraier,是一个使用JNI技术的上层JAVA API,通过它,可以使用JAVA编程来调用这个引擎。



estcmd.exe的核心命令有两个,分别是gather(创建索引)和search(搜索)。

下面我们实战一下

首先创建一个文件夹d:\myData,然后找些htm以及txt文件copy进去

在开始菜单-〉运行中键入cmd,打开命令行界面,切换到estcmd.exe所在的文件夹,运行下面的命令

estcmd gather -sd myData d:\myData

这个命令的意思是,对d:\myData下的所有文件建立索引,索引数据库的名称为myData

命令运行后,可以在看到目录下的所有文件被一一registered,最后,会提示

estcmd:INFO:finished successfully:elapsed time: *h *m *s

其中*表示创建索引所花费的时间

这样,索引就建好了,dir一下,可以发现,当前目录下多了一个叫做myData的文件夹,这就是索引库

来,让我们体验一下全文搜索的魅力吧

运行下面的命令

estcmd search -ic Shift-Jis -vx myData どうぞ

这个意思是以Shift-Jis作为编码格式,在索引库myData中,搜索どうぞ,如果不需要指定编码格式,则可以去掉 –ic Shift-Jis命令

呵呵,看到搜索结果了吧,如果觉得搜索结果可读性不好,也可以将 –vx指令换成 –vh,这样,将把输出结果由xml格式变为摘要格式



喝口水,接着说



下面介绍如何通过JAVA API来完成同样的工作

首先,在操作系统的系统环境变量中,找到PATH,向其中加入d:\hyperestraier

然后,打开Eclipse,新建一个项目,并在Build Path中Add External JARs,添加对前面提到的estraier.jar的引用

最后,在代码中,import estraier.*;

好了,可以写程序了

Database db = new Database();

if(!db.open("D:\\hyperestraier\\myData",

Database.DBWRITER | Database.DBCREAT)){

System.err.println("error: " + db.err_msg(db.error()));

return;

}

Document doc = new Document();

doc.add_attr("@uri", "d:\\myData\\helloworld.txt");

doc.add_attr("@title", "helloworld");

doc.add_attr("otherAttribute", "attributeValue");

doc.add_text("life's made up of little things.");

if(!db.put_doc(doc, Database.PDCLEAN))

System.err.println("error: " + db.err_msg(db.error()));

if(!db.close())

System.err.println("error: " + db.err_msg(db.error()));

程序的大意是,新建或打开索引库D:\hyperestraier\myData

向其中添加一个文档,文档的地址是d:\myData\helloworld.txt

文档标题为helloworld

这个文档还有一个额外的自定义属性,属性的名/值为otherAttribute/ attributeValue

文档的内容为life's made up of little things

还差最后一点,就是通过程序检索了

Database db = new Database();

if(!db.open("D:\\hyperestraier\\myData", Database.DBREADER)){

System.err.println("error msg: " + db.err_msg(db.error()));

return;

}

Condition cond = new Condition();

cond.set_phrase("どうぞ");

//cond.set_order("@size NUMA");

//cond.set_order("otherAttribute STRD ");

cond.set_max(5);

//cond.add_attr("otherAttribute STREQ value");

//cond.add_attr("@title STRINC hello");

Result result = db.search(cond);

for(int i = 0; i < result.doc_num(); i++){

Document doc = db.get_doc(result.get_doc_id(i), 0);

if(doc == null) continue;

String uri = doc.attr("@uri");

if(uri != null) System.out.println("URI: " + uri);

String title = doc.attr("@title");

if(title != null) System.out.println("Title: " + title);

String myAttr = doc.attr("otherAttribute");

if(myAttr != null) System.out.println("otherAttribute:" + myAttr);

else System.out.println("there's no attr named otherAttribute ");

Iterator it = doc.texts().iterator();

while(it.hasNext()){

System.out.println((String)it.next());

}

}

if(!db.close())

System.err.println("error: " + db.err_msg(db.error()));

程序的大意是,对索引库D:\hyperestraier\myData,检索关键词,然后把前5条结果输出

程序中还注释掉了一些检索条件留给大家探索哈



啰罗嗦嗦写了半天,就先介绍到这里吧,进一步的学习,大家可以参考D:\hyperestraier下的doc文件夹中的帮助,帮助有英/日两国文字,总有一款适合您

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

 1.Hyper Estraier是一个用C语言开发的全文检索引擎,他是由一位日本人开发的.工程注册在sourceforge.net(http://hyperestraier.sourceforge.net). 2.Hyper的特性: 高速度,高稳定性,高可扩展性…(这可都是有原因的,不是瞎吹) P2P架构(可译为端到端的,不是咱们下大片用的p2p) 自带Web Crawler 文档权重排序 良好的多字节支持(想一想,它是由日本人开发的….) 简单实用的API(我看了一遍,真是个个都实用,我能看懂的,也就算简单了) 短语,正则表达式搜索(这个有点过了,不带这个,不是好的Full text Search Engine?) 结构化文档搜索能力(大概就是指可以自行给文档加上一堆属性并搜索这些属性吧?这个我没有实验) Hyper Estraier is a full-text search system. You can search lots of documents for some documents including specified words. If you run a web site, it is useful as your own search engine for pages in your site. Also, it is useful as search utilities of mail boxes and file servers. The characteristic of Hyper Estraier is the following. High performance of search High scalability of target documents Perfect recall ratio by N-gram method High precision by hybrid mechanism of N-gram and morphological analyzer Phrase search, regular expressions, attribute search, and similarity search Multilingualism with Unicode Independent of file format and repository Intelligent web crawler Simple and powerful API Supporting P2P architecture Hyper Estraier is an open-source software released under the terms of the GNU Lesser General Public License. It works on Linux, Windows, Mac OS X, and other UNIX-like systems.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值