]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/API/GraphQL/NLP.hs
[FIX/FEAT] Order 2 improvement
[gargantext.git] / src / Gargantext / API / GraphQL / NLP.hs
1 {-# LANGUAGE DeriveAnyClass #-}
2 {-# LANGUAGE DuplicateRecordFields #-}
3
4 module Gargantext.API.GraphQL.NLP
5 ( Lang(..)
6 , LanguagesArgs(..)
7 , LanguagesMap
8 , resolveLanguages
9 )
10 where
11
12 import Control.Lens (view)
13 import qualified Data.Map.Strict as Map
14 import Data.Morpheus.Types
15 ( GQLType
16 , Resolver
17 , QUERY
18 )
19 import Gargantext.API.Prelude (GargM, GargError)
20 import Gargantext.Core (Lang(..), NLPServerConfig(..), PosTagAlgo) -- , allLangs)
21 import Gargantext.Core.NLP (HasNLPServer(..))
22 import Gargantext.Prelude
23 import Protolude
24
25 data LanguagesArgs
26 = LanguagesArgs
27 { } deriving (Generic, GQLType)
28
29 type GqlM e env = Resolver QUERY e (GargM env GargError)
30
31 type LanguagesMap = Map.Map Lang NLPServer
32
33 data NLPServer = NLPServer
34 {
35 server :: !PosTagAlgo
36 , url :: !Text
37 }
38 deriving (Show, Eq, Generic, GQLType)
39
40 resolveLanguages
41 :: HasNLPServer env => LanguagesArgs -> GqlM e env LanguagesMap
42 resolveLanguages LanguagesArgs { } = do
43 -- pure $ allLangs
44 lift $ do
45 ns <- view nlpServer
46 printDebug "[resolveLanguages] nlpServer" ns
47 pure $ Map.map (\(NLPServerConfig { .. }) -> NLPServer { server
48 , url = Protolude.show url }) ns