so many bug fixes.

This commit is contained in:
Bryce Covert
2020-07-03 17:50:37 -07:00
parent 3de59d3fdc
commit 86f51f93e4
22 changed files with 1447 additions and 521 deletions

View File

@@ -81,33 +81,36 @@
[file filename]
(excel/parse-file file filename))
(defn best-match [clients invoice-client-name]
(let [fuzzy-match (->> clients
(mapcat (fn [{:keys [:db/id :client/matches :client/name] :as client :or {matches []}}]
(map (fn [m]
[client (m/jaccard (.toLowerCase invoice-client-name) (.toLowerCase m))])
(conj matches name))))
(filter #(< (second %) 0.25))
(sort-by second)
ffirst)
(defn best-match
([clients invoice-client-name]
(best-match clients invoice-client-name 0.25))
([clients invoice-client-name threshold]
(let [fuzzy-match (->> clients
(mapcat (fn [{:keys [:db/id :client/matches :client/name] :as client :or {matches []}}]
(map (fn [m]
[client (m/jaccard (.toLowerCase invoice-client-name) (.toLowerCase m))])
(conj matches name))))
(filter #(<= (second %) threshold))
(sort-by second)
ffirst)
word-set (set (filter (complement str/blank?) (str/split (.toLowerCase invoice-client-name) #"[\s:\-]" )))
client-word-match (->> clients
(map
(fn [{:keys [:db/id :client/matches :client/name] :as client :or {matches []}}]
(let [client-words (-> #{}
(into
(mapcat
(fn [match] (str/split (.toLowerCase match) #"\s" ))
matches))
(into
(str/split (.toLowerCase name) #"\s" )))]
[client (count (set/intersection client-words word-set))])))
(filter (fn [[_ c]] (> c 0)))
(sort-by (fn [[_ c]] c))
reverse
ffirst)]
(or fuzzy-match client-word-match)))
word-set (set (filter (complement str/blank?) (str/split (.toLowerCase invoice-client-name) #"[\s:\-]" )))
client-word-match (->> clients
(map
(fn [{:keys [:db/id :client/matches :client/name] :as client :or {matches []}}]
(let [client-words (-> #{}
(into
(mapcat
(fn [match] (str/split (.toLowerCase match) #"\s" ))
matches))
(into
(str/split (.toLowerCase name) #"\s" )))]
[client (count (set/intersection client-words word-set))])))
(filter (fn [[_ c]] (> c 0)))
(sort-by (fn [[_ c]] c))
reverse
ffirst)]
(or fuzzy-match client-word-match))))
(defn best-location-match [client text full-text]
(or (->> client