Outdated egg!
This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for the CHICKEN 4 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
estraier
Introduction
The Estraier Chicken egg is a thin wrapper around the Hyper Estraier API.
Examples
Indexing a document
The following code receives a path to a Estraier DB and a file and adds it to the DB:
(use estraier) (define (estraier-update-document path-db path-text) (let ((doc (est-doc-new))) ; Here you could use an HTTP URL if your file is visible somewhere: (est-doc-add-attr doc "@uri" path-text) ; You will want to set the title to something more meaningful: (est-doc-add-attr doc "@title" path-text) (with-input-from-file path-text (lambda () (let loop ((line (read-line))) (unless (eof-object? line) ; If your file is not in Unicode, use the iconv egg to convert ; the charset of the lines to Unicode. (est-doc-add-text doc line) (loop (read-line)))))) (let ((db (est-db-open path-db (bitwise-ior *estdbwriter* *estdbcreat*)))) (est-db-put-doc db doc *estpdclean*) (est-db-close db))))
Searching for documents
(use estraier) (define (estraier-search path-data query) (let ((condition (est-cond-new))) (est-cond-set-phrase condition query) (let* ((db (est-db-open (svnwiki-make-pathname path-data "estraier-db") 0)) (hints (cbmapopenex 32)) (results (vector->list (est-db-search db condition hints))) (words (est-hints-to-words hints))) (map (lambda (id) (let ((doc (est-db-get-doc db id 0))) (list (est-doc-attr doc "@uri") (est-doc-attr doc "@title") (est-doc-make-snippet doc words 480 96 96)))) results))))
Authors
This egg is made by Alejandro Forero Cuervo <azul@freaks-unidos.net>.
License
The estraier egg is available under the GNU General Public License.
Requirements
In order to build this egg you'll need to have Hyper Estraier and libQDBM. Note that you'll need the development packages for both.
Debian
In Debian, it suffices to install packages libestraier-dev and libqdbm-dev. The dependencies will take care of the rest.
As of this writing, Hyper Estraier is not available in Debian stable. You'll have to use testing.