[nlp] allow to specify NLP in ini files

parent 791c2a70
cabal-version: 1.12 cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.34.4. -- This file has been generated from package.yaml by hpack version 0.34.7.
-- --
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
--
-- hash: 6d2d8c161ae59694c70216c31e6ac2cdb0f16397f06fd30a24d7098e86f268e8
name: gargantext-prelude name: gargantext-prelude
version: 0.1.0.0 version: 0.1.0.0
...@@ -40,6 +38,8 @@ library ...@@ -40,6 +38,8 @@ library
Gargantext.Prelude.Fibonacci Gargantext.Prelude.Fibonacci
Gargantext.Prelude.Mail Gargantext.Prelude.Mail
Gargantext.Prelude.Mail.Types Gargantext.Prelude.Mail.Types
Gargantext.Prelude.NLP
Gargantext.Prelude.NLP.Types
Gargantext.Prelude.Utils Gargantext.Prelude.Utils
other-modules: other-modules:
Paths_gargantext_prelude Paths_gargantext_prelude
...@@ -81,6 +81,7 @@ library ...@@ -81,6 +81,7 @@ library
, mime-mail , mime-mail
, mtl , mtl
, network , network
, network-uri
, password , password
, protolude , protolude
, qrcode-core , qrcode-core
...@@ -140,6 +141,7 @@ executable gargantext-prelude-exe ...@@ -140,6 +141,7 @@ executable gargantext-prelude-exe
, mime-mail , mime-mail
, mtl , mtl
, network , network
, network-uri
, password , password
, protolude , protolude
, qrcode-core , qrcode-core
...@@ -200,6 +202,7 @@ test-suite gargantext-prelude-test ...@@ -200,6 +202,7 @@ test-suite gargantext-prelude-test
, mime-mail , mime-mail
, mtl , mtl
, network , network
, network-uri
, password , password
, protolude , protolude
, qrcode-core , qrcode-core
......
...@@ -43,6 +43,7 @@ dependencies: ...@@ -43,6 +43,7 @@ dependencies:
- mime-mail - mime-mail
- mtl - mtl
- network - network
- network-uri
- password - password
- protolude - protolude
- qrcode-core - qrcode-core
......
...@@ -51,4 +51,3 @@ instance IsHashable (Set Hash) where ...@@ -51,4 +51,3 @@ instance IsHashable (Set Hash) where
instance {-# OVERLAPPABLE #-} IsHashable a => IsHashable [a] where instance {-# OVERLAPPABLE #-} IsHashable a => IsHashable [a] where
hash = hash . Set.fromList . map hash hash = hash . Set.fromList . map hash
{-| {-|
Module : Gargantext.Core.Mail Module : Gargantext.Prelude.Mail
Description : Description :
Copyright : (c) CNRS, 2017-Present Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3 License : AGPL + CECILL v3
...@@ -67,4 +67,3 @@ gargMail (MailConfig {..}) (GargMail { .. }) = do ...@@ -67,4 +67,3 @@ gargMail (MailConfig {..}) (GargMail { .. }) = do
to = [Address gm_name gm_to] to = [Address gm_name gm_to]
cc = [] cc = []
bcc = [] bcc = []
{-|
Module : Gargantext.Prelude.NLP
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
module Gargantext.Prelude.NLP
(NLPConfig(..), readConfig)
where
import Data.Text (Text, unpack)
import qualified Data.Text as T
import Data.Maybe
import Gargantext.Prelude
import Gargantext.Prelude.Config (readIniFile', val)
import Gargantext.Prelude.NLP.Types (NLPConfig(..))
import Network.URI (parseURI)
import System.IO (FilePath)
type URL = Text
readConfig :: FilePath -> IO NLPConfig
readConfig fp = do
ini <- readIniFile' fp
let val' = val ini "nlp"
let m_nlp_en = parseURI $ cs $ val' "EN"
let m_nlp_fr = parseURI $ cs $ val' "FR"
let m_nlp_all = parseURI $ cs $ val' "All"
let mRet = NLPConfig <$> m_nlp_en <*> m_nlp_fr <*> m_nlp_all
case mRet of
Nothing -> panic $ T.concat [ "Cannot read config file: _nlp_en = "
, T.pack $ show m_nlp_en
, ", _nlp_fr = "
, T.pack $ show m_nlp_fr
, ", _nlp_all = "
, T.pack $ show m_nlp_all ]
Just ret -> pure ret
{-|
Module : Gargantext.Prelude.NLP.Types
Description : Textmining Collaborative Platform
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
module Gargantext.Prelude.NLP.Types where
import Control.Lens (makeLenses)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Network.Socket (PortNumber)
import Network.URI (URI)
import Protolude
data NLPConfig = NLPConfig { _nlp_en :: !URI
, _nlp_fr :: !URI
, _nlp_all :: !URI
}
deriving (Generic, Show)
makeLenses ''NLPConfig
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