Debian Codegraph @

test/levenshtein-performance.scm

raw
1 ;;
2 ;; benchmarking for util.levenshtein
3 ;;
4
5 (use gauche.time)
6 (use util.match)
7 (use file.util)
8 (use util.levenshtein)
9
10 (define (main args)
11 (match (cdr args)
12 [() (doit l-distances #f)]
13 [("l". x) (doit l-distances (and (pair? x) (string->number (car x))))]
14 [("re". x) (doit re-distances (and (pair? x) (string->number (car x))))]
15 [("dl". x) (doit dl-distances (and (pair? x) (string->number (car x))))]
16 [_ (exit 1 "Usage: ~a [type [cutoff]]\
17 \n Type: l (levenshtein), re (restricted edit) or dl (damerau-levenshtein\
18 \n Cutoff: integer cutoff"
19 (car args))])
20 0)
21
22 (define (doit proc cutoff)
23 (define data (file->string-list "/usr/share/dict/words"))
24 (time (proc "scratch" data :cutoff cutoff)))