From 37995536d596b3e7eb6f129132f770023b45b03b Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 4 Apr 2023 16:32:12 -0700 Subject: [PATCH] makes requirement of exact match. --- src/clj/auto_ap/jobs/ntg.clj | 6 +++--- src/clj/auto_ap/parse.clj | 10 ++++++++++ test/clj/auto_ap/integration/jobs/ntg.clj | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/clj/auto_ap/jobs/ntg.clj b/src/clj/auto_ap/jobs/ntg.clj index e1c76d77..b13e507d 100644 --- a/src/clj/auto_ap/jobs/ntg.clj +++ b/src/clj/auto_ap/jobs/ntg.clj @@ -68,8 +68,8 @@ (filter (fn [[_ _ _ _ _ _ _ _ _ _ _ break-flag]] (= "Y" break-flag))) (map (fn [[vendor location-hint invoice-number ship-date invoice-total ]] - (let [[matching-client similarity] (and location-hint - (parse/best-match clients location-hint 0.0))] + (let [matching-client (and location-hint + (parse/exact-match clients location-hint))] {:invoice/vendor vendor :invoice/location (parse/best-location-match matching-client location-hint location-hint ) :invoice/date (coerce/to-date (atime/parse ship-date atime/normal-date)) @@ -115,7 +115,7 @@ first :content first) - [matching-client similarity] (and location-hint (parse/best-match clients location-hint 0.0)) + matching-client (and location-hint (parse/exact-match clients location-hint)) ] (if matching-client diff --git a/src/clj/auto_ap/parse.clj b/src/clj/auto_ap/parse.clj index 1a5fe6f3..124d4752 100644 --- a/src/clj/auto_ap/parse.clj +++ b/src/clj/auto_ap/parse.clj @@ -121,6 +121,16 @@ first)] (or fuzzy-match client-word-match)))) +(defn exact-match + ([clients invoice-client-name] + (->> clients + (filter (fn [{:keys [:client/matches :client/name] :as client :or {matches []}}] + (seq + (filter (fn [m] + (= (.toLowerCase invoice-client-name) (.toLowerCase m))) + (conj matches name))))) + first))) + (defn best-location-match [client text full-text] (or (->> client :client/location-matches diff --git a/test/clj/auto_ap/integration/jobs/ntg.clj b/test/clj/auto_ap/integration/jobs/ntg.clj index e98a4288..d48a1170 100644 --- a/test/clj/auto_ap/integration/jobs/ntg.clj +++ b/test/clj/auto_ap/integration/jobs/ntg.clj @@ -2,7 +2,6 @@ (:require [auto-ap.jobs.ntg :as sut] [auto-ap.integration.util :refer [wrap-setup admin-token setup-test-data test-vendor test-account dissoc-id]] [clojure.test :as t :refer [deftest is testing use-fixtures]] - [datomic.api :as d] [clojure.java.io :as io]))