Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
searchRankTfIdf/searchRankBm25 parse a boolean query, filter docs via evalQuery, then rank survivors by relevance over the query's leaf terms (queryTerms) — the filter-then-rank pattern. 225/225. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
12 lines
1.1 KiB
Plaintext
12 lines
1.1 KiB
Plaintext
;; search boolean-filtered ranked search — Haskell source fragment.
|
|
;; Depends on parse (parseQuery/Query), query (evalQuery), rank (tfidfDoc/bm25Doc/
|
|
;; cmpScore). Filters by the boolean query, then ranks the surviving docs by
|
|
;; relevance over the query's leaf terms — the real-world filter-then-rank pattern.
|
|
;; queryTerms :: Query -> [Term]
|
|
;; searchRankTfIdf :: String -> Index -> [DocId]
|
|
;; searchRankBm25 :: Float -> Float -> String -> Index -> [DocId]
|
|
|
|
(define
|
|
search/rankq-src
|
|
"queryTerms (Term t) = [t]\nqueryTerms (And a b) = queryTerms a ++ queryTerms b\nqueryTerms (Or a b) = queryTerms a ++ queryTerms b\nqueryTerms (Not a) = queryTerms a\nqueryTerms (Phrase ts) = ts\nmkSubPair f terms idx d = (f terms idx d, d)\nrankSubsetWith f terms docs idx = map snd (sortBy cmpScore (map (mkSubPair f terms idx) docs))\nsearchRankTfIdf s idx = let q = parseQuery s in rankSubsetWith tfidfDoc (queryTerms q) (evalQuery idx q) idx\nsearchRankBm25 k1 b s idx = let q = parseQuery s in rankSubsetWith (bm25Doc k1 b) (queryTerms q) (evalQuery idx q) idx\n")
|