-}
-{-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Strict #-}
module Main where
-import Data.Either
-import Prelude (read)
import Control.Exception (finally)
-import Gargantext.Prelude
-import Gargantext.Database.Flow (FlowCmdM, flowCorpusFile)
-import Gargantext.Text.Corpus.Parsers (FileFormat(..))
-import Gargantext.Database.Utils (Cmd, )
-import Gargantext.Database.Types.Node (CorpusId, toHyperdataDocument)
-import Gargantext.Database.Schema.User (insertUsersDemo)
-import Gargantext.Text.Terms (TermType(..))
-import Gargantext.Core (Lang(..))
-import Gargantext.API.Types (GargError)
-import Gargantext.API.Node () -- instances
-import Gargantext.API.Settings (withDevEnv, runCmdDev, DevEnv)
-import System.Environment (getArgs)
---import Gargantext.Text.Corpus.Parsers.GrandDebat (readFile, GrandDebatReference(..))
+import Data.Either
+import Data.Maybe (Maybe(..))
import Data.Text (Text)
+import System.Environment (getArgs)
import qualified Data.Text as Text
-import Control.Monad.IO.Class (liftIO)
+import Text.Read (readMaybe)
+
+import Gargantext.API.Dev (withDevEnv, runCmdDev)
+import Gargantext.API.Admin.EnvTypes (DevEnv(..))
+import Gargantext.API.Node () -- instances
+import Gargantext.API.Prelude (GargError)
+import Gargantext.Core (Lang(..))
+import Gargantext.Core.Types.Individu (User(..))
+import Gargantext.Database.Action.Flow (flowCorpusFile, flowAnnuaire, TermType(..))
+import Gargantext.Database.Action.Flow.Types (FlowCmdM)
+import Gargantext.Database.Admin.Types.Hyperdata (toHyperdataDocument)
+import Gargantext.Database.Admin.Types.Node (CorpusId)
+import Gargantext.Database.Prelude (Cmd)
+import Gargantext.Prelude
+import Gargantext.Core.Text.Corpus.Parsers (FileFormat(..), FileType(..))
main :: IO ()
main = do
- [userCreate, user, name, iniPath, limit, corpusPath] <- getArgs
+ [fun, user, name, iniPath, limit, corpusPath] <- getArgs
--{-
- let createUsers :: Cmd GargError Int64
- createUsers = insertUsersDemo
-
+
let
--tt = (Unsupervised EN 6 0 Nothing)
tt = (Multi EN)
- format = CsvGargV3 -- CsvHalFormat --WOS
- cmd :: forall m. FlowCmdM DevEnv GargError m => m CorpusId
- cmd = flowCorpusFile (cs user) (Left (cs name :: Text)) (read limit :: Int) tt format corpusPath
+ format = CsvGargV3 -- CsvHal --WOS
+ limit' = case (readMaybe limit :: Maybe Int) of
+ Nothing -> panic $ "Cannot read limit: " <> (Text.pack limit)
+ Just l -> l
+ corpus :: forall m. FlowCmdM DevEnv GargError m => m CorpusId
+ corpus = flowCorpusFile (UserName $ cs user) (Left (cs name :: Text)) limit' tt format Plain corpusPath Nothing (\_ -> pure ())
+
+ corpusCsvHal :: forall m. FlowCmdM DevEnv GargError m => m CorpusId
+ corpusCsvHal = flowCorpusFile (UserName $ cs user) (Left (cs name :: Text)) limit' tt CsvHal Plain corpusPath Nothing (\_ -> pure ())
+
+ annuaire :: forall m. FlowCmdM DevEnv GargError m => m CorpusId
+ annuaire = flowAnnuaire (UserName $ cs user) (Left "Annuaire") (Multi EN) corpusPath (\_ -> pure ())
+
{-
let debatCorpus :: forall m. FlowCmdM DevEnv GargError m => m CorpusId
debatCorpus = do
flowCorpus (Text.pack user) (Text.pack name) (Multi FR) (map (map toHyperdataDocument) docs)
--}
-
withDevEnv iniPath $ \env -> do
- _ <- if userCreate == "true"
- then runCmdDev env createUsers
+ _ <- if fun == "corpus"
+ then runCmdDev env corpus
else pure 0 --(cs "false")
- _ <- runCmdDev env cmd
+ _ <- if fun == "corpusCsvHal"
+ then runCmdDev env corpusCsvHal
+ else pure 0 --(cs "false")
+
+ _ <- if fun == "annuaire"
+ then runCmdDev env annuaire
+ else pure 0
{-
_ <- if corpusType == "csv"
then runCmdDev env csvCorpus