unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* [ANN] hyper search engine 0.2
@ 2016-06-19  9:49 Amirouche Boubekki
  2016-06-19 18:55 ` Amirouche Boubekki
  0 siblings, 1 reply; 2+ messages in thread
From: Amirouche Boubekki @ 2016-06-19  9:49 UTC (permalink / raw)
  To: Guile User

Héllo,


Yesterday someone on IRC asked for a new feature; the ability
to use xor/and/not/or to express queries. So here is it!

# Kesako?

The implementation is straight forward. Actually I defined
`xor*`, `and*`, `not*` and `or*` procedures that looks like
this:

```
(define* ((xor* a b) uid)
   (if (procedure? a)
       (if (procedure? b)
           ((xor* (a uid) (b uid)) uid)
           ((xor* (a uid) b) uid))
       (if (procedure? b)
           ((xor* a (b uid)) uid)
           (xor a b))))
```

As you can see it only accepts two arguments :(

Luckily you do no need to understand that to use it,
but it looks funny. That's why I pasted it.

Anyway, given a list of uids that you can retrieve with
`(documents db)` or `(search* db tokens ...)` you can filter
the results with the help of `(keyword db name)`:

```
(filter (and* (keyword db "hypermove") (keyword db "guile")) uids)
```

This is equivalent to `(search* db "hypermove" "guile")` but it is less
efficient!

Previously you could not for instance query the following:

```
(and* (keyword db "commercial") (or* (keyword db "hypermove") (keyword 
db "gnu")))
```

Right now, `keyword` is an implementation detail. But in
the future maybe, you could think of other ways to filter
documents for instance based on some kind of ranking.

# Note on performance

Now a word on `(documents db)`. `documents` does almost
a full scan of a database... To speed things up a little,
you rely on `search*` which is faster but you have
to reword your query. For instance, the previous query,
could actually be done like that:

```
(filter (or* (keyword db "hypermove") (keyword db "gnu")) (search* db 
"commercial"))
```

The documentation is up-to-date on the website:

https://framagit.org/a-guile-mind/hyper


Enjoy!


-- 
Amirouche ~ amz3 ~ http://www.hyperdev.fr



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ANN] hyper search engine 0.2
  2016-06-19  9:49 [ANN] hyper search engine 0.2 Amirouche Boubekki
@ 2016-06-19 18:55 ` Amirouche Boubekki
  0 siblings, 0 replies; 2+ messages in thread
From: Amirouche Boubekki @ 2016-06-19 18:55 UTC (permalink / raw)
  To: Guile User; +Cc: guile-user

On 2016-06-19 11:49, Amirouche Boubekki wrote:
> 
> ```
> (define* ((xor* a b) uid)
>   (if (procedure? a)
>       (if (procedure? b)
>           ((xor* (a uid) (b uid)) uid)
>           ((xor* (a uid) b) uid))
>       (if (procedure? b)
>           ((xor* a (b uid)) uid)
>           (xor a b))))
> ```
> 

That procedure is buggy, since we can assume that (a uid) returns a 
boolean, there is no need for the extra xor* call.

The following does what is expected thanks to ijp:

> (define ((xor* . fs) uid)
>  (fold logxor 0 (map (lambda (f) (if (procedure? f) (f uid) f)) fs)))

-- 
Amirouche ~ amz3 ~ http://www.hyperdev.fr



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-19 18:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-19  9:49 [ANN] hyper search engine 0.2 Amirouche Boubekki
2016-06-19 18:55 ` Amirouche Boubekki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).