diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-01-11 03:27:17 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-01-11 08:12:02 +0100 |
commit | 75ace0b26691848b9a16a9a0ec1880110e8262b8 (patch) | |
tree | befda6536685ebc0472f5b0273ad25fdf8eb0ae4 /app/ProbabilityMap.hs | |
parent | 7bdf16be84b368655ce2ee3d9ab6bf185dfb59b5 (diff) |
feat: add `check` cmd
Diffstat (limited to 'app/ProbabilityMap.hs')
-rw-r--r-- | app/ProbabilityMap.hs | 11 |
1 files changed, 2 insertions, 9 deletions
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) |