|
1 | 1 | (ns com.nytimes.querqy.commonrules-test
|
2 | 2 | (:refer-clojure :exclude [filter])
|
3 | 3 | (:require
|
4 |
| - [clojure.datafy :refer [datafy]] |
5 |
| - [clojure.java.io :as io] |
6 |
| - [clojure.test :refer [deftest is]] |
7 |
| - [com.nytimes.querqy :as querqy] |
8 |
| - [com.nytimes.querqy.commonrules :as r :refer [boost delete filter match match* synonym]] |
9 |
| - [testit.core :refer [=> =in=> facts]]) |
| 4 | + [clojure.datafy :refer [datafy]] |
| 5 | + [clojure.java.io :as io] |
| 6 | + [clojure.test :refer [deftest is]] |
| 7 | + [com.nytimes.querqy :as querqy] |
| 8 | + [com.nytimes.querqy.commonrules :as r :refer [boost delete filter match match* synonym]] |
| 9 | + [testit.core :refer [=> =in=> facts]]) |
10 | 10 | (:import
|
11 |
| - (querqy.rewrite.commonrules.select.booleaninput BooleanInputParser) |
12 |
| - (querqy.rewrite.commonrules.select.booleaninput.model BooleanInputElement BooleanInputElement$Type))) |
| 11 | + (querqy.rewrite.commonrules.select.booleaninput BooleanInputParser) |
| 12 | + (querqy.rewrite.commonrules.select.booleaninput.model BooleanInputElement BooleanInputElement$Type))) |
13 | 13 |
|
14 | 14 | (deftest match-macro-inputs
|
15 | 15 | (facts "valid inputs to match macro"
|
|
52 | 52 |
|
53 | 53 | (def resource-rewriter
|
54 | 54 | (r/rules-rewriter
|
55 |
| - (io/resource "com/nytimes/querqy/common-rules.txt"))) |
| 55 | + (io/resource "com/nytimes/querqy/common-rules.txt"))) |
56 | 56 |
|
57 | 57 | (def dsl-rewriter
|
58 | 58 | (r/rules-rewriter
|
59 | 59 | ;; basics
|
60 |
| - (match "A1" (synonym "B1")) |
61 |
| - (match "A2 B2" (synonym "C2")) |
62 |
| - (match "A3" (synonym "B3") (synonym "C3")) |
63 |
| - (match "A4 B4" (synonym "C4") (synonym "D4")) |
64 |
| - (match "A5" (boost 2 "B5")) |
65 |
| - (match "A6" (filter "B6")) |
66 |
| - (match "A7 B7" (delete "B7")) |
67 |
| - (match "A8" (synonym "B8") (boost 2 "C8")) |
| 60 | + (match "A1" (synonym "B1")) |
| 61 | + (match "A2 B2" (synonym "C2")) |
| 62 | + (match "A3" (synonym "B3") (synonym "C3")) |
| 63 | + (match "A4 B4" (synonym "C4") (synonym "D4")) |
| 64 | + (match "A5" (boost 2 "B5")) |
| 65 | + (match "A6" (filter "B6")) |
| 66 | + (match "A7 B7" (delete "B7")) |
| 67 | + (match "A8" (synonym "B8") (boost 2 "C8")) |
68 | 68 | ;; boolean rules
|
69 |
| - (match (or "A9" "B9") (boost 2 "C9")) |
70 |
| - (match (and "A10" "B10") (boost 2 "C10")) |
71 |
| - (match (and "A11" (not "B11")) (boost 2 "C11")) |
| 69 | + (match (or "A9" "B9") (boost 2 "C9")) |
| 70 | + (match (and "A10" "B10") (boost 2 "C10")) |
| 71 | + (match (and "A11" (not "B11")) (boost 2 "C11")) |
72 | 72 |
|
73 | 73 | ;; multi anchor rules
|
74 |
| - (match (and "best" "netflix" "show") |
75 |
| - (boost 2 "netflix")) |
| 74 | + (match (and "best" "netflix" "show") |
| 75 | + (boost 2 "netflix")) |
76 | 76 |
|
77 |
| - (match (and "best" "amazon" "show") |
78 |
| - (boost 2 "amazon")))) |
| 77 | + (match (and "best" "amazon" "show") |
| 78 | + (boost 2 "amazon")))) |
79 | 79 |
|
80 | 80 | (defn rewrite
|
81 | 81 | "util to do a rewrite and datafy the result for easier comparison"
|
|
110 | 110 |
|
111 | 111 | (def rules-with-custom-functions
|
112 | 112 | (r/rules-rewriter
|
113 |
| - (synonyms "chickpea" "garbanzo bean") |
114 |
| - (synonyms "chickpeas" "garbanzo beans"))) |
| 113 | + (synonyms "chickpea" "garbanzo bean") |
| 114 | + (synonyms "chickpeas" "garbanzo beans"))) |
115 | 115 |
|
116 | 116 | (deftest custom-functions-test
|
117 | 117 | (facts "helper functions can return multiple match rules"
|
|
0 commit comments