Commit a21bbb3d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Cosmetics]

parent 3de15d1b
...@@ -28,7 +28,7 @@ import Data.Map as DM ...@@ -28,7 +28,7 @@ import Data.Map as DM
----import Data.Either.Extra(Either(..)) ----import Data.Either.Extra(Either(..))
---- ----
--import Control.Monad (join) --import Control.Monad (join)
import Codec.Archive.Zip import Codec.Archive.Zip (withArchive, getEntry, getEntries)
import Path.IO (resolveFile') import Path.IO (resolveFile')
------ import qualified Data.ByteString.Lazy as B ------ import qualified Data.ByteString.Lazy as B
--import Control.Applicative ( (<$>) ) --import Control.Applicative ( (<$>) )
...@@ -53,10 +53,18 @@ data FileFormat = WOS -- Implemented (ISI Format) ...@@ -53,10 +53,18 @@ data FileFormat = WOS -- Implemented (ISI Format)
-- | XML -- Not Implemented / see : -- | XML -- Not Implemented / see :
-- -- > http://chrisdone.com/posts/fast-haskell-c-parsing-xml -- -- > http://chrisdone.com/posts/fast-haskell-c-parsing-xml
---- | withParser: parse :: FileFormat -> FilePath
---- According the format of the text, choosing the right parser. -> IO [Either String [[(DB.ByteString, DB.ByteString)]]]
parse format path = do
files <- case takeExtension path of
".zip" -> openZip path
_ -> pure <$> DB.readFile path
mapConcurrently (runParser format) files
--withParser :: FileFormat -> ByteString -> IO Corpus -- | withParser:
-- According the format of the text, choosing the right parser.
-- TODO withParser :: FileFormat -> Parser [Document]
withParser :: FileFormat -> Parser [[(DB.ByteString, DB.ByteString)]] withParser :: FileFormat -> Parser [[(DB.ByteString, DB.ByteString)]]
withParser WOS = wosParser withParser WOS = wosParser
--withParser DOC = docParser --withParser DOC = docParser
...@@ -75,12 +83,4 @@ openZip fp = do ...@@ -75,12 +83,4 @@ openZip fp = do
bs <- mapConcurrently (\s -> withArchive path (getEntry s)) entries bs <- mapConcurrently (\s -> withArchive path (getEntry s)) entries
pure bs pure bs
parse :: FileFormat -> FilePath
-> IO [Either String [[(DB.ByteString, DB.ByteString)]]]
parse format path = do
files <- case takeExtension path of
".zip" -> openZip path
_ -> pure <$> DB.readFile path
mapConcurrently (runParser format) files
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