From 75ace0b26691848b9a16a9a0ec1880110e8262b8 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Thu, 11 Jan 2024 03:27:17 +0100 Subject: feat: add `check` cmd --- app/ProbabilityMap.hs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'app/ProbabilityMap.hs') diff --git a/app/ProbabilityMap.hs b/app/ProbabilityMap.hs index 9a700d7..dc7067d 100644 --- a/app/ProbabilityMap.hs +++ b/app/ProbabilityMap.hs @@ -25,7 +25,7 @@ import Control.Applicative (liftA2) import Control.Arrow ((***)) import Control.DeepSeq (NFData (..)) import Control.Exception (SomeException, try) -import Control.Parallel.Strategies +import Control.Parallel.Strategies (parList, rdeepseq, withStrategy) import Data.Binary qualified as B import Data.List (foldl') import Data.Map qualified as M @@ -37,6 +37,7 @@ import Data.Vector.Binary () import Document qualified as D import GHC.Conc (numCapabilities) import GHC.Generics (Generic) +import Parallel (streamsOf) import Tag qualified as G data ProbabilityCache = ProbabilityCache @@ -178,14 +179,6 @@ probabilityMap (ProbabilityCache' {..}) = allTags = M.keys docsPerTag fi = fromIntegral @Int @Double -streamsOf :: Int -> [a] -> [[a]] -streamsOf 1 xs = [xs] -streamsOf n xs - | n > 0 = [everyN k xs | k <- [0 .. n - 1]] - | otherwise = [] - where - everyN k xs = map snd $ filter ((== k) . (`mod` n) . fst) $ zip [0 ..] xs - addDocument :: D.Document -> ProbabilityCache -> ProbabilityCache addDocument doc probabilityCache = fromProbabilityCache' $ addDocument' doc (toProbabilityCache' probabilityCache) -- cgit v1.2.3