summaryrefslogtreecommitdiff
path: root/spellcheck/dictionary.scm
diff options
context:
space:
mode:
Diffstat (limited to 'spellcheck/dictionary.scm')
l---------[-rw-r--r--]spellcheck/dictionary.scm37
1 files changed, 1 insertions, 36 deletions
diff --git a/spellcheck/dictionary.scm b/spellcheck/dictionary.scm
index 856fec5..237a3c6 100644..120000
--- a/spellcheck/dictionary.scm
+++ b/spellcheck/dictionary.scm
@@ -1,36 +1 @@
-(define-module (dictionary)
- #:export (create-dictionary
- dict-occur-ref
- dict-keys-ref
- dict-values-ref))
-
-(define (create-dictionary lst)
- (dictionary-helper (make-hash-table) lst))
-
-(define (dictionary-helper dict rest)
- "Recursively adds words to DICT."
- (if (null? rest)
- dict
- (begin
- (dict-inc-word dict (car rest))
- (dictionary-helper dict (cdr rest)))))
-
-(define (dict-inc-word dict e)
- "Inserts word E into the DICT, using E
-as a key and the running total of occurances
-as the value."
- (hashq-set!
- dict e (1+ (dict-occur-ref dict e))))
-
-(define (dict-occur-ref dict e)
- "A wrapper for hashq-ref. Returns '0' if an element
-is not present, rather than '#f'."
- (or (hashq-ref dict e) 0))
-
-(define (dict-keys-ref dict)
- "Returns a list of all words in the dictionary."
- (map car (hash-map->list cons dict)))
-
-(define (dict-values-ref dict)
- "Sums up the total number of occurances for all words."
- (apply + (map cdr (hash-map->list cons dict))))
+../dictionary/dictionary.scm \ No newline at end of file