Skip to content

Commit

Permalink
Run cljfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jvia committed Jan 11, 2024
1 parent 4e768f4 commit 59c150f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
42 changes: 21 additions & 21 deletions src/com/nytimes/querqy/commonrules.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"CommonRules based rewriter"
(:refer-clojure :exclude [filter])
(:require
[clojure.java.io :as io]
[clojure.string :as str]
[com.nytimes.querqy.model :as model]
[com.nytimes.querqy.parser :as parser])
[clojure.java.io :as io]
[clojure.string :as str]
[com.nytimes.querqy.model :as model]
[com.nytimes.querqy.parser :as parser])
(:import
(java.io Reader)
(java.net URL)
(java.util List UUID)
(querqy.model Input Input$BooleanInput Input$SimpleInput)
(querqy.parser QuerqyParser)
(querqy.rewrite RewriterFactory)
(querqy.rewrite.commonrules CommonRulesRewriter LineParser QuerqyParserFactory SimpleCommonRulesParser WhiteSpaceQuerqyParserFactory)
(querqy.rewrite.commonrules.model BoostInstruction BoostInstruction$BoostDirection DeleteInstruction FilterInstruction Instructions SynonymInstruction TrieMapRulesCollectionBuilder)
(querqy.rewrite.commonrules.select SelectionStrategyFactory)
(querqy.rewrite.commonrules.select.booleaninput BooleanInputParser)
(querqy.rewrite.commonrules.select.booleaninput.model BooleanInputElement BooleanInputElement$Type BooleanInputLiteral)))
(java.io Reader)
(java.net URL)
(java.util List UUID)
(querqy.model Input Input$BooleanInput Input$SimpleInput)
(querqy.parser QuerqyParser)
(querqy.rewrite RewriterFactory)
(querqy.rewrite.commonrules CommonRulesRewriter LineParser QuerqyParserFactory SimpleCommonRulesParser WhiteSpaceQuerqyParserFactory)
(querqy.rewrite.commonrules.model BoostInstruction BoostInstruction$BoostDirection DeleteInstruction FilterInstruction Instructions SynonymInstruction TrieMapRulesCollectionBuilder)
(querqy.rewrite.commonrules.select SelectionStrategyFactory)
(querqy.rewrite.commonrules.select.booleaninput BooleanInputParser)
(querqy.rewrite.commonrules.select.booleaninput.model BooleanInputElement BooleanInputElement$Type BooleanInputLiteral)))

(set! *warn-on-reflection* true)

Expand All @@ -44,8 +44,8 @@
(proxy [RewriterFactory] [(str (UUID/randomUUID))]
(createRewriter [_ _]
(CommonRulesRewriter.
rules
SelectionStrategyFactory/DEFAULT_SELECTION_STRATEGY))
rules
SelectionStrategyFactory/DEFAULT_SELECTION_STRATEGY))
(getCacheableGenerableTerms [] #{})))

;; ----------------------------------------------------------------------
Expand All @@ -59,10 +59,10 @@
ignore-case true
parser (WhiteSpaceQuerqyParserFactory.)}}]
(let [rules-parser (SimpleCommonRulesParser.
^Reader stream
^boolean boolean-input
^QuerqyParserFactory parser
^boolean ignore-case)]
^Reader stream
^boolean boolean-input
^QuerqyParserFactory parser
^boolean ignore-case)]
(.parse rules-parser))))

(extend-protocol CommonRulesRewriterBuilder
Expand Down
8 changes: 4 additions & 4 deletions src/com/nytimes/querqy/model.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns com.nytimes.querqy.model
"Builders for classes in the `querqy.model` package."
(:require
[clojure.core.protocols :as cp]
[clojure.datafy :refer [datafy]]
[clojure.string :as str])
[clojure.core.protocols :as cp]
[clojure.datafy :refer [datafy]]
[clojure.string :as str])
(:import
(querqy.model BooleanParent BooleanQuery BoostQuery BoostedTerm Clause Clause$Occur DisjunctionMaxQuery ExpandedQuery Input$SimpleInput MatchAllQuery QuerqyQuery Query Term)))
(querqy.model BooleanParent BooleanQuery BoostQuery BoostedTerm Clause Clause$Occur DisjunctionMaxQuery ExpandedQuery Input$SimpleInput MatchAllQuery QuerqyQuery Query Term)))

(def should Clause$Occur/SHOULD)
(def must Clause$Occur/MUST)
Expand Down
52 changes: 26 additions & 26 deletions test/com/nytimes/querqy/commonrules_test.clj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(ns com.nytimes.querqy.commonrules-test
(:refer-clojure :exclude [filter])
(:require
[clojure.datafy :refer [datafy]]
[clojure.java.io :as io]
[clojure.test :refer [deftest is]]
[com.nytimes.querqy :as querqy]
[com.nytimes.querqy.commonrules :as r :refer [boost delete filter match match* synonym]]
[testit.core :refer [=> =in=> facts]])
[clojure.datafy :refer [datafy]]
[clojure.java.io :as io]
[clojure.test :refer [deftest is]]
[com.nytimes.querqy :as querqy]
[com.nytimes.querqy.commonrules :as r :refer [boost delete filter match match* synonym]]
[testit.core :refer [=> =in=> facts]])
(:import
(querqy.rewrite.commonrules.select.booleaninput BooleanInputParser)
(querqy.rewrite.commonrules.select.booleaninput.model BooleanInputElement BooleanInputElement$Type)))
(querqy.rewrite.commonrules.select.booleaninput BooleanInputParser)
(querqy.rewrite.commonrules.select.booleaninput.model BooleanInputElement BooleanInputElement$Type)))

(deftest match-macro-inputs
(facts "valid inputs to match macro"
Expand Down Expand Up @@ -52,30 +52,30 @@

(def resource-rewriter
(r/rules-rewriter
(io/resource "com/nytimes/querqy/common-rules.txt")))
(io/resource "com/nytimes/querqy/common-rules.txt")))

(def dsl-rewriter
(r/rules-rewriter
;; basics
(match "A1" (synonym "B1"))
(match "A2 B2" (synonym "C2"))
(match "A3" (synonym "B3") (synonym "C3"))
(match "A4 B4" (synonym "C4") (synonym "D4"))
(match "A5" (boost 2 "B5"))
(match "A6" (filter "B6"))
(match "A7 B7" (delete "B7"))
(match "A8" (synonym "B8") (boost 2 "C8"))
(match "A1" (synonym "B1"))
(match "A2 B2" (synonym "C2"))
(match "A3" (synonym "B3") (synonym "C3"))
(match "A4 B4" (synonym "C4") (synonym "D4"))
(match "A5" (boost 2 "B5"))
(match "A6" (filter "B6"))
(match "A7 B7" (delete "B7"))
(match "A8" (synonym "B8") (boost 2 "C8"))
;; boolean rules
(match (or "A9" "B9") (boost 2 "C9"))
(match (and "A10" "B10") (boost 2 "C10"))
(match (and "A11" (not "B11")) (boost 2 "C11"))
(match (or "A9" "B9") (boost 2 "C9"))
(match (and "A10" "B10") (boost 2 "C10"))
(match (and "A11" (not "B11")) (boost 2 "C11"))

;; multi anchor rules
(match (and "best" "netflix" "show")
(boost 2 "netflix"))
(match (and "best" "netflix" "show")
(boost 2 "netflix"))

(match (and "best" "amazon" "show")
(boost 2 "amazon"))))
(match (and "best" "amazon" "show")
(boost 2 "amazon"))))

(defn rewrite
"util to do a rewrite and datafy the result for easier comparison"
Expand Down Expand Up @@ -110,8 +110,8 @@

(def rules-with-custom-functions
(r/rules-rewriter
(synonyms "chickpea" "garbanzo bean")
(synonyms "chickpeas" "garbanzo beans")))
(synonyms "chickpea" "garbanzo bean")
(synonyms "chickpeas" "garbanzo beans")))

(deftest custom-functions-test
(facts "helper functions can return multiple match rules"
Expand Down

0 comments on commit 59c150f

Please sign in to comment.