fix-gloss

This commit is contained in:
2026-08-04 17:21:59 -06:00
parent c4d4bc8735
commit 6eb7e98864
4 changed files with 43 additions and 503 deletions
+10 -6
View File
@@ -22,15 +22,19 @@
(when-some [[_ word gloss] (re-matches #"([^\t]*)\t(.*)\n?" s)]
[word gloss]))
(defn lookup-word [word]
(defn query-word [word]
(let [ds (sql/get-datasource {:dbtype "sqlite" :dbname "db/words.db"})]
(with-open [conn (sql/get-connection ds)]
(->> (sql/execute! conn ["select info from words where word = ?"
word])
(map #(json/parse-string (:words/info %) keyword))
(mapcat :senses)
(mapcat :raw_glosses)
first))))
(map #(json/parse-string (:words/info %) keyword))))))
(defn gloss-word [word]
(->> word
query-word
(mapcat :senses)
(mapcat (some-fn :raw_glosses :glosses))
first))
(defn parse-chat-message [x]
(when-let [[_ _dead? author body]
@@ -52,7 +56,7 @@
(defn do-definition [s]
(when-some [w (find-word s)]
(l/infof "looking up word: %s" w)
(let [r (lookup-word w)]
(let [r (gloss-word w)]
(if r
(l/infof "found word! %s" r)
(l/infof "no entry... %s" w))