From d12b405ef28ac05686df8e252e761db4afe0648c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexandre=20Delano=C3=AB?= <devel+git@delanoe.org>
Date: Wed, 16 May 2018 08:23:48 +0000
Subject: [PATCH] [CSV PARSER] facto (without tests which are coming next)

---
 src/Gargantext/Text/Parsers/CSV.hs | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/Gargantext/Text/Parsers/CSV.hs b/src/Gargantext/Text/Parsers/CSV.hs
index c4594d74..7395a858 100644
--- a/src/Gargantext/Text/Parsers/CSV.hs
+++ b/src/Gargantext/Text/Parsers/CSV.hs
@@ -19,12 +19,12 @@ module Gargantext.Text.Parsers.CSV where
 
 import GHC.Real (round)
 import GHC.IO (FilePath)
+
 import Control.Applicative
 
 import Data.Char (ord)
 import Data.Csv
 import Data.Either (Either(Left, Right))
-import Data.List (concat)
 import Data.String (IsString)
 import Data.Text (Text, pack, unpack, length)
 import qualified Data.ByteString.Lazy as BL
@@ -54,16 +54,10 @@ toDocs :: Vector CsvDoc -> [Doc]
 toDocs v = V.toList 
          $ V.zipWith (\nId (CsvDoc t s py pm pd abst auth)
                        -> Doc nId t s py pm pd abst auth )
-                       (V.enumFromN 1 (V.length v')) v''
-      where
-        m  = docsSize v
-        v' = V.concatMap (splitDoc m Paragraph) v
-
-        m' = docsSize v
-        v'' = V.concatMap (splitDoc m' Sentences) v'
-        
-        m'' = docsSize v'
-        v''' = V.concatMap (splitDoc m' Sentences) v''
+                       (V.enumFromN 1 (V.length v'')) v''
+          where
+            v'' = V.foldl (\v' sep -> V.concatMap (splitDoc (docsSize v') sep) v') v seps
+            seps= (V.fromList [Paragraph, Sentences, Chars])
 
 ---------------------------------------------------------------
 fromDocs :: Vector Doc -> Vector CsvDoc
-- 
2.21.0