Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
nearDocs k t1 t2 returns docs where both terms occur within k positions (unordered); candidates from the posting intersection, filtered on positional postings. 205/205. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9 lines
810 B
Plaintext
9 lines
810 B
Plaintext
;; search proximity (NEAR) — Haskell source fragment. Depends on query (posIn,
|
|
;; docsWith, sortedInter). Finds docs where two terms occur within k positions of
|
|
;; each other (unordered), using the positional postings.
|
|
;; nearDocs :: Int -> Term -> Term -> Index -> [DocId] (sorted)
|
|
|
|
(define
|
|
search/near-src
|
|
"nrAbsDiff a b = if a > b then a - b else b - a\nnrCloseTo k x [] = False\nnrCloseTo k x (y:ys) = if nrAbsDiff x y <= k then True else nrCloseTo k x ys\nnrAnyClose k [] ys = False\nnrAnyClose k (x:xs) ys = if nrCloseTo k x ys then True else nrAnyClose k xs ys\nnearInDoc k t1 t2 d idx = nrAnyClose k (posIn t1 d idx) (posIn t2 d idx)\nnearHere k t1 t2 idx d = nearInDoc k t1 t2 d idx\nnearDocs k t1 t2 idx = filter (nearHere k t1 t2 idx) (sortedInter (docsWith t1 idx) (docsWith t2 idx))\n")
|