Fix performance issue due to infinit result of splitEvery

parent 519719a9
...@@ -42,18 +42,16 @@ main = do ...@@ -42,18 +42,16 @@ main = do
let q = ["gratuit", "gratuité", "culture", "culturel"] let q = ["gratuit", "gratuité", "culture", "culturel"]
(h,csvDocs) <- readCsv rPath (h,csvDocs) <- readCsv rPath
putStrLn $ "Number of documents before:" <> show (V.length csvDocs) putStrLn $ "Number of documents before:" <> show (V.length csvDocs)
putStrLn $ "Mean size of docs:" <> show ( docsSize csvDocs) putStrLn $ "Mean size of docs:" <> show ( docsSize csvDocs)
let docs = toDocs csvDocs let docs = toDocs csvDocs
let engine = insertDocs docs initialDocSearchEngine let engine = insertDocs docs initialDocSearchEngine
let docIds = S.query engine (map pack q) let docIds = S.query engine (map pack q)
let docs' = fromDocs $ filterDocs docIds (V.fromList docs) let docs' = fromDocs $ filterDocs docIds (V.fromList docs)
putStrLn $ "Number of documents after:" <> show (V.length docs') putStrLn $ "Number of documents after:" <> show (V.length docs')
putStrLn $ "Mean size of docs:" <> show (docsSize docs') putStrLn $ "Mean size of docs:" <> show (docsSize docs')
writeCsv wPath (h, docs')
writeCsv wPath (h, docs')
...@@ -109,7 +109,7 @@ ma = movingAverage 3 ...@@ -109,7 +109,7 @@ ma = movingAverage 3
-- | splitEvery n == chunkAlong n n -- | splitEvery n == chunkAlong n n
splitEvery :: Int -> [a] -> [[a]] splitEvery :: Int -> [a] -> [[a]]
splitEvery _ [] = L.cycle [[]] splitEvery _ [] = []
splitEvery n xs = splitEvery n xs =
let (h,t) = L.splitAt n xs let (h,t) = L.splitAt n xs
in h : splitEvery n t in h : splitEvery n t
......
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