aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2020-10-14 15:36:10 +0530
committerArun Isaac2020-10-14 16:15:39 +0530
commit408557714585873a88ecf21ee36de7bce9b3f34d (patch)
tree6c3fa169d9cb7b3bac90ad2efcd37f50d9ad32d1
parent59ab908b1155f7159231e9903fbe6e0dc403f1db (diff)
downloadguile-xapian-408557714585873a88ecf21ee36de7bce9b3f34d.tar.gz
guile-xapian-408557714585873a88ecf21ee36de7bce9b3f34d.tar.lz
guile-xapian-408557714585873a88ecf21ee36de7bce9b3f34d.zip
xapian: Wrap MSet-snippet.
* xapian/xapian.scm (get-flag, mset-snippet): New functions.
-rw-r--r--xapian/xapian.scm21
1 files changed, 20 insertions, 1 deletions
diff --git a/xapian/xapian.scm b/xapian/xapian.scm
index 8c19c80..92bf5d3 100644
--- a/xapian/xapian.scm
+++ b/xapian/xapian.scm
@@ -18,6 +18,7 @@
;;; <https://www.gnu.org/licenses/>.
(define-module (xapian xapian)
+ #:use-module (rnrs arithmetic bitwise)
#:use-module (ice-9 match)
#:use-module (srfi srfi-26)
#:use-module (xapian wrap)
@@ -44,7 +45,8 @@
mset-item-document
mset-item-rank
mset-item-weight
- mset-fold))
+ mset-fold
+ mset-snippet))
(define xapian-open new-Database)
(define xapian-close delete-Database)
@@ -141,3 +143,20 @@ on the database object."
(else (let ((result (proc head result)))
(MSetIterator-next head)
(loop head result))))))
+
+(define (get-flag flag-thunk value)
+ (if value (flag-thunk) 0))
+
+;; TODO: Support cjk-words?
+(define* (mset-snippet mset text
+ #:key (length 500) (stemmer (make-stem "none"))
+ (highlight-start "<b>") (highlight-end "</b>") (omit "...")
+ (background-model? #t) (exhaustive? #t)
+ (empty-without-match? #t)
+ (cjk-ngram? #t))
+ (MSet-snippet mset text length stemmer
+ (bitwise-ior (get-flag MSet-SNIPPET-BACKGROUND-MODEL background-model?)
+ (get-flag MSet-SNIPPET-EXHAUSTIVE exhaustive?)
+ (get-flag MSet-SNIPPET-EMPTY-WITHOUT-MATCH empty-without-match?)
+ (get-flag MSet-SNIPPET-CJK-NGRAM cjk-ngram?))
+ highlight-start highlight-end omit))