Skip to content

Commit

Permalink
custom-dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
huahaiy committed Dec 15, 2021
1 parent f9fe973 commit 66f973e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(def version "0.2.0")
(def version "0.2.1")

(defproject org.clojars.huahaiy/symspell-clj version
:description "SymSpell in Clojure"
Expand Down
4 changes: 3 additions & 1 deletion src/symspell_clj/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@
:or {max-edit-distance 2
prefix-length 10
custom-dictionary []}}]
(let [unigram (read-unigram unigram-file)]
(let [unigram-file (or unigram-file "en_unigrams.txt")
bigram-file (or bigram-file "en_bigrams.txt")
unigram (read-unigram unigram-file)]
(doseq [w custom-dictionary]
(.put unigram w custom-word-default-freq))
(->SpellChecker
Expand Down
7 changes: 5 additions & 2 deletions test/symspell_clj/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
[["what is fuji" 2]]))
(sut/add-word sc "juji")
(is (= (sut/lookup-compound sc "wht is juji")
[["what is juji" 1]]))
))
[["what is juji" 1]]))))

(deftest custom-dict-test
(let [sc (sut/new-spellchecker nil nil {:custom-dictionary ["juji"]})]
(is (= (sut/lookup sc "juji") [["juji" 0]]))))

0 comments on commit 66f973e

Please sign in to comment.