excellent
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
(ns wiktionary-tf2.main
|
||||
(:require [clojure.java.io :as io]
|
||||
[cheshire.core :as json]
|
||||
[babashka.fs :as fs]
|
||||
[babashka.process :as p]
|
||||
[progrock.core :as prog]
|
||||
@@ -22,16 +23,13 @@
|
||||
[word gloss]))
|
||||
|
||||
(defn lookup-word [word]
|
||||
(let [r (p/shell {:out :string :continue true}
|
||||
"zgrep" "-m1"
|
||||
(format "^%s\t[^[:space:]]" word)
|
||||
*dictionary-file*)]
|
||||
(when (zero? (:exit r))
|
||||
(->> r
|
||||
:out
|
||||
str/split-lines
|
||||
(map #(-> % parse-plaintext-entry second))
|
||||
(filter #(not (empty? %))) ; remove nil and ""
|
||||
(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))))
|
||||
|
||||
(defn parse-chat-message [x]
|
||||
|
||||
Reference in New Issue
Block a user