fix mapConcurrentlyChunked

parent 6296b828
...@@ -63,7 +63,8 @@ mapMP f xs = do ...@@ -63,7 +63,8 @@ mapMP f xs = do
mapConcurrentlyChunked :: (a -> IO b) -> [a] -> IO [b] mapConcurrentlyChunked :: (a -> IO b) -> [a] -> IO [b]
mapConcurrentlyChunked f ts = do mapConcurrentlyChunked f ts = do
n <- getNumCapabilities caps <- getNumCapabilities
let n = caps `div` length ts
concat <$> mapConcurrently (mapM f) (chunksOf n ts) concat <$> mapConcurrently (mapM f) (chunksOf n ts)
filterTermsAndCooc filterTermsAndCooc
...@@ -94,11 +95,8 @@ main = do ...@@ -94,11 +95,8 @@ main = do
putStrLn $ show $ length termList putStrLn $ show $ length termList
let years = DM.keys corpus
let patterns = WithList $ buildPatterns termList let patterns = WithList $ buildPatterns termList
let corpus' = DMaybe.catMaybes $ map (\k -> DM.lookup k corpus) years
r <- mapConcurrentlyChunked (filterTermsAndCooc patterns) (DM.toList corpus)
r <- mapConcurrentlyChunked (filterTermsAndCooc patterns) (zip years corpus')
putStrLn $ show r putStrLn $ show r
--writeFile outputFile cooc --writeFile outputFile cooc
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment