Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christian Merten
haskell-gargantext
Commits
2c6f3936
Commit
2c6f3936
authored
Apr 06, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MonadBase replaces MonadIO
parent
1adb6049
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
86 additions
and
96 deletions
+86
-96
Main.hs
bin/gargantext-import/Main.hs
+0
-1
API.hs
src/Gargantext/API.hs
+8
-9
Annuaire.hs
src/Gargantext/API/Annuaire.hs
+1
-1
Auth.hs
src/Gargantext/API/Auth.hs
+1
-2
New.hs
src/Gargantext/API/Corpus/New.hs
+5
-6
File.hs
src/Gargantext/API/Corpus/New/File.hs
+7
-8
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+15
-15
List.hs
src/Gargantext/API/Ngrams/List.hs
+1
-2
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+1
-1
Types.hs
src/Gargantext/Core/Types.hs
+1
-1
Flow.hs
src/Gargantext/Database/Flow.hs
+5
-6
Annuaire.hs
src/Gargantext/Database/Flow/Annuaire.hs
+1
-1
Utils.hs
src/Gargantext/Database/Utils.hs
+3
-4
Prelude.hs
src/Gargantext/Prelude.hs
+6
-6
Utils.hs
src/Gargantext/Prelude/Utils.hs
+7
-7
List.hs
src/Gargantext/Text/List.hs
+1
-0
Learn.hs
src/Gargantext/Text/List/Learn.hs
+5
-5
PosTagging.hs
src/Gargantext/Text/Terms/Multi/PosTagging.hs
+3
-4
Graph.hs
src/Gargantext/Viz/Graph.hs
+3
-3
API.hs
src/Gargantext/Viz/Graph/API.hs
+9
-10
API.hs
src/Gargantext/Viz/Phylo/API.hs
+1
-2
Main.hs
src/Gargantext/Viz/Phylo/Main.hs
+1
-1
stack.yaml
stack.yaml
+1
-1
No files found.
bin/gargantext-import/Main.hs
View file @
2c6f3936
...
@@ -37,7 +37,6 @@ import System.Environment (getArgs)
...
@@ -37,7 +37,6 @@ import System.Environment (getArgs)
--import Gargantext.Text.Corpus.Parsers.GrandDebat (readFile, GrandDebatReference(..))
--import Gargantext.Text.Corpus.Parsers.GrandDebat (readFile, GrandDebatReference(..))
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
qualified
Data.Text
as
Text
import
qualified
Data.Text
as
Text
import
Control.Monad.IO.Class
(
liftIO
)
main
::
IO
()
main
::
IO
()
main
=
do
main
=
do
...
...
src/Gargantext/API.hs
View file @
2c6f3936
...
@@ -51,7 +51,6 @@ import Control.Concurrent (threadDelay)
...
@@ -51,7 +51,6 @@ import Control.Concurrent (threadDelay)
import
Control.Exception
(
finally
)
import
Control.Exception
(
finally
)
import
Control.Lens
import
Control.Lens
import
Control.Monad.Except
(
withExceptT
,
ExceptT
)
import
Control.Monad.Except
(
withExceptT
,
ExceptT
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Control.Monad.Reader
(
ReaderT
,
runReaderT
)
import
Control.Monad.Reader
(
ReaderT
,
runReaderT
)
import
Data.Aeson.Encode.Pretty
(
encodePretty
)
import
Data.Aeson.Encode.Pretty
(
encodePretty
)
import
Data.Swagger
import
Data.Swagger
...
@@ -235,7 +234,7 @@ waitAPI :: Int -> GargServer WaitAPI
...
@@ -235,7 +234,7 @@ waitAPI :: Int -> GargServer WaitAPI
waitAPI
n
=
do
waitAPI
n
=
do
let
let
m
=
(
10
::
Int
)
^
(
6
::
Int
)
m
=
(
10
::
Int
)
^
(
6
::
Int
)
_
<-
lift
IO
$
threadDelay
(
m
*
n
)
_
<-
lift
Base
$
threadDelay
(
m
*
n
)
pure
$
"Waited: "
<>
(
cs
$
show
n
)
pure
$
"Waited: "
<>
(
cs
$
show
n
)
----------------------------------------
----------------------------------------
...
@@ -418,19 +417,19 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
...
@@ -418,19 +417,19 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
{-
{-
addUpload :: GargServer New.Upload
addUpload :: GargServer New.Upload
addUpload cId = (serveJobsAPI $ JobFunction (\i log -> New.addToCorpusJobFunction cid i (lift
IO
. log)))
addUpload cId = (serveJobsAPI $ JobFunction (\i log -> New.addToCorpusJobFunction cid i (lift
Base
. log)))
:<|> (serveJobsAPI $ JobFunction (\i log -> New.addToCorpusWithForm cid i (lift
IO
. log)))
:<|> (serveJobsAPI $ JobFunction (\i log -> New.addToCorpusWithForm cid i (lift
Base
. log)))
--}
--}
addCorpusWithQuery
::
GargServer
New
.
AddWithQuery
addCorpusWithQuery
::
GargServer
New
.
AddWithQuery
addCorpusWithQuery
cid
=
addCorpusWithQuery
cid
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
i
log
->
New
.
addToCorpusJobFunction
cid
i
(
lift
IO
.
log
))
JobFunction
(
\
i
log
->
New
.
addToCorpusJobFunction
cid
i
(
lift
Base
.
log
))
addWithFile
::
GargServer
New
.
AddWithFile
addWithFile
::
GargServer
New
.
AddWithFile
addWithFile
cid
i
f
=
addWithFile
cid
i
f
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
_i
log
->
New
.
addToCorpusWithFile
cid
i
f
(
lift
IO
.
log
))
JobFunction
(
\
_i
log
->
New
.
addToCorpusWithFile
cid
i
f
(
lift
Base
.
log
))
addCorpusWithForm
::
Text
->
GargServer
New
.
AddWithForm
addCorpusWithForm
::
Text
->
GargServer
New
.
AddWithForm
addCorpusWithForm
username
cid
=
addCorpusWithForm
username
cid
=
...
@@ -439,19 +438,19 @@ addCorpusWithForm username cid =
...
@@ -439,19 +438,19 @@ addCorpusWithForm username cid =
let
let
log'
x
=
do
log'
x
=
do
printDebug
"addCorpusWithForm"
x
printDebug
"addCorpusWithForm"
x
lift
IO
$
log
x
lift
Base
$
log
x
in
New
.
addToCorpusWithForm
username
cid
i
log'
)
in
New
.
addToCorpusWithForm
username
cid
i
log'
)
addAnnuaireWithForm
::
GargServer
Annuaire
.
AddWithForm
addAnnuaireWithForm
::
GargServer
Annuaire
.
AddWithForm
addAnnuaireWithForm
cid
=
addAnnuaireWithForm
cid
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
i
log
->
Annuaire
.
addToAnnuaireWithForm
cid
i
(
lift
IO
.
log
))
JobFunction
(
\
i
log
->
Annuaire
.
addToAnnuaireWithForm
cid
i
(
lift
Base
.
log
))
{-
{-
serverStatic :: Server (Get '[HTML] Html)
serverStatic :: Server (Get '[HTML] Html)
serverStatic = $(do
serverStatic = $(do
let path = "purescript-gargantext/dist/index.html"
let path = "purescript-gargantext/dist/index.html"
Just s <- lift
IO
(fileTypeToFileTree (FileTypeFile path))
Just s <- lift
Base
(fileTypeToFileTree (FileTypeFile path))
fileTreeToServer s
fileTreeToServer s
)
)
-}
-}
...
...
src/Gargantext/API/Annuaire.hs
View file @
2c6f3936
...
@@ -88,7 +88,7 @@ addToAnnuaireWithForm _cid (WithForm ft _d _l) logStatus = do
...
@@ -88,7 +88,7 @@ addToAnnuaireWithForm _cid (WithForm ft _d _l) logStatus = do
-- WOS -> Parser.parseFormat Parser.WOS
-- WOS -> Parser.parseFormat Parser.WOS
-- PresseRIS -> Parser.parseFormat Parser.RisPresse
-- PresseRIS -> Parser.parseFormat Parser.RisPresse
-- docs <- lift
IO
-- docs <- lift
Base
-- $ splitEvery 500
-- $ splitEvery 500
-- <$> take 1000000
-- <$> take 1000000
-- <$> parse (cs d)
-- <$> parse (cs d)
...
...
src/Gargantext/API/Auth.hs
View file @
2c6f3936
...
@@ -33,7 +33,6 @@ module Gargantext.API.Auth
...
@@ -33,7 +33,6 @@ module Gargantext.API.Auth
where
where
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.List
(
elem
)
import
Data.List
(
elem
)
import
Data.Swagger
import
Data.Swagger
...
@@ -91,7 +90,7 @@ makeTokenForUser :: (HasSettings env, HasJoseError err)
...
@@ -91,7 +90,7 @@ makeTokenForUser :: (HasSettings env, HasJoseError err)
=>
NodeId
->
Cmd'
env
err
Token
=>
NodeId
->
Cmd'
env
err
Token
makeTokenForUser
uid
=
do
makeTokenForUser
uid
=
do
jwtS
<-
view
$
settings
.
jwtSettings
jwtS
<-
view
$
settings
.
jwtSettings
e
<-
lift
IO
$
makeJWT
(
AuthenticatedUser
uid
)
jwtS
Nothing
e
<-
lift
Base
$
makeJWT
(
AuthenticatedUser
uid
)
jwtS
Nothing
-- TODO-SECURITY here we can implement token expiration ^^.
-- TODO-SECURITY here we can implement token expiration ^^.
either
joseError
(
pure
.
toStrict
.
decodeUtf8
)
e
either
joseError
(
pure
.
toStrict
.
decodeUtf8
)
e
-- TODO not sure about the encoding...
-- TODO not sure about the encoding...
...
...
src/Gargantext/API/Corpus/New.hs
View file @
2c6f3936
...
@@ -27,7 +27,6 @@ module Gargantext.API.Corpus.New
...
@@ -27,7 +27,6 @@ module Gargantext.API.Corpus.New
--import Gargantext.Text.Corpus.Parsers (parseFile, FileFormat(..))
--import Gargantext.Text.Corpus.Parsers (parseFile, FileFormat(..))
import
Control.Lens
hiding
(
elements
)
import
Control.Lens
hiding
(
elements
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Maybe
(
fromMaybe
)
...
@@ -95,7 +94,7 @@ api _uId (Query q _ as) = do
...
@@ -95,7 +94,7 @@ api _uId (Query q _ as) = do
Nothing
->
flowCorpusSearchInDatabase
"user1"
EN
q
Nothing
->
flowCorpusSearchInDatabase
"user1"
EN
q
Just
API
.
All
->
flowCorpusSearchInDatabase
"user1"
EN
q
Just
API
.
All
->
flowCorpusSearchInDatabase
"user1"
EN
q
Just
a
->
do
Just
a
->
do
docs
<-
lift
IO
$
API
.
get
a
q
(
Just
1000
)
docs
<-
lift
Base
$
API
.
get
a
q
(
Just
1000
)
cId'
<-
flowCorpus
"user1"
(
Left
q
)
(
Multi
EN
)
[
docs
]
cId'
<-
flowCorpus
"user1"
(
Left
q
)
(
Multi
EN
)
[
docs
]
pure
cId'
pure
cId'
...
@@ -234,10 +233,10 @@ addToCorpusWithForm' :: FlowCmdM env err m
...
@@ -234,10 +233,10 @@ addToCorpusWithForm' :: FlowCmdM env err m
-> (ScraperStatus -> m ())
-> (ScraperStatus -> m ())
-> m ScraperStatus
-> m ScraperStatus
addToCorpusWithForm' cid (WithForm ft d l) logStatus = do
addToCorpusWithForm' cid (WithForm ft d l) logStatus = do
newStatus <- lift
IO
newEmptyMVar
newStatus <- lift
Base
newEmptyMVar
s <- addToCorpusWithForm cid (WithForm ft d l) logStatus
s <- addToCorpusWithForm cid (WithForm ft d l) logStatus
_ <- lift
IO
$ forkIO $ putMVar newStatus s
_ <- lift
Base
$ forkIO $ putMVar newStatus s
s' <- lift
IO
$ takeMVar newStatus
s' <- lift
Base
$ takeMVar newStatus
pure s'
pure s'
-}
-}
addToCorpusWithForm
::
FlowCmdM
env
err
m
addToCorpusWithForm
::
FlowCmdM
env
err
m
...
@@ -264,7 +263,7 @@ addToCorpusWithForm username cid (WithForm ft d l _n) logStatus = do
...
@@ -264,7 +263,7 @@ addToCorpusWithForm username cid (WithForm ft d l _n) logStatus = do
printDebug
"Parsing corpus: "
cid
printDebug
"Parsing corpus: "
cid
-- TODO granularity of the logStatus
-- TODO granularity of the logStatus
docs
<-
lift
IO
$
splitEvery
500
docs
<-
lift
Base
$
splitEvery
500
<$>
take
1000000
<$>
take
1000000
<$>
parse
(
cs
d
)
<$>
parse
(
cs
d
)
...
...
src/Gargantext/API/Corpus/New/File.hs
View file @
2c6f3936
...
@@ -27,7 +27,6 @@ module Gargantext.API.Corpus.New.File
...
@@ -27,7 +27,6 @@ module Gargantext.API.Corpus.New.File
import
Control.Lens
((
.~
),
(
?~
))
import
Control.Lens
((
.~
),
(
?~
))
import
Control.Monad
(
forM
)
import
Control.Monad
(
forM
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Maybe
import
Data.Maybe
import
Data.Aeson
import
Data.Aeson
import
Data.Monoid
(
mempty
)
import
Data.Monoid
(
mempty
)
...
@@ -100,18 +99,18 @@ postUpload :: NodeId
...
@@ -100,18 +99,18 @@ postUpload :: NodeId
->
Cmd
err
[
Hash
]
->
Cmd
err
[
Hash
]
postUpload
_
Nothing
_
=
panic
"fileType is a required parameter"
postUpload
_
Nothing
_
=
panic
"fileType is a required parameter"
postUpload
_
(
Just
fileType
)
multipartData
=
do
postUpload
_
(
Just
fileType
)
multipartData
=
do
p
utStrLn
$
"File Type: "
<>
(
show
fileType
)
p
rintDebug
"File Type: "
fileType
is
<-
lift
IO
$
do
is
<-
lift
Base
$
do
p
utStrLn
(
"Inputs:"
::
Text
)
p
rintDebug
"Inputs:"
(
)
forM
(
inputs
multipartData
)
$
\
input
->
do
forM
(
inputs
multipartData
)
$
\
input
->
do
p
utStrLn
$
(
"iName "
::
Text
)
<>
(
iName
input
)
p
rintDebug
"iName "
(
iName
input
)
<>
(
"iValue "
::
Text
)
<>
(
iValue
input
)
printDebug
"iValue "
(
iValue
input
)
pure
$
iName
input
pure
$
iName
input
_
<-
forM
(
files
multipartData
)
$
\
file
->
do
_
<-
forM
(
files
multipartData
)
$
\
file
->
do
let
content
=
fdPayload
file
let
content
=
fdPayload
file
p
utStrLn
$
(
"XXX "
::
Text
)
<>
(
fdFileName
file
)
p
rintDebug
"XXX "
(
fdFileName
file
)
p
utStrLn
$
(
"YYY "
::
Text
)
<>
cs
content
p
rintDebug
"YYY "
content
--pure $ cs content
--pure $ cs content
-- is <- inputs multipartData
-- is <- inputs multipartData
...
...
src/Gargantext/API/Ngrams.hs
View file @
2c6f3936
...
@@ -119,6 +119,7 @@ import qualified Data.Set as Set
...
@@ -119,6 +119,7 @@ import qualified Data.Set as Set
import
Control.Category
((
>>>
))
import
Control.Category
((
>>>
))
import
Control.Concurrent
import
Control.Concurrent
import
Control.Lens
(
makeLenses
,
makePrisms
,
Getter
,
Iso
'
,
iso
,
from
,
(
.~
),
(
?=
),
(
#
),
to
,
folded
,
{-withIndex, ifolded,-}
view
,
use
,
(
^.
),
(
^..
),
(
^?
),
(
+~
),
(
%~
),
(
.~
),
(
%=
),
sumOf
,
at
,
_Just
,
Each
(
..
),
itraverse_
,
both
,
forOf_
,
(
%%~
),
(
?~
),
mapped
)
import
Control.Lens
(
makeLenses
,
makePrisms
,
Getter
,
Iso
'
,
iso
,
from
,
(
.~
),
(
?=
),
(
#
),
to
,
folded
,
{-withIndex, ifolded,-}
view
,
use
,
(
^.
),
(
^..
),
(
^?
),
(
+~
),
(
%~
),
(
.~
),
(
%=
),
sumOf
,
at
,
_Just
,
Each
(
..
),
itraverse_
,
both
,
forOf_
,
(
%%~
),
(
?~
),
mapped
)
import
Control.Monad.Base
(
MonadBase
,
liftBase
)
import
Control.Monad.Error.Class
(
MonadError
)
import
Control.Monad.Error.Class
(
MonadError
)
import
Control.Monad.Reader
import
Control.Monad.Reader
import
Control.Monad.State
import
Control.Monad.State
...
@@ -797,15 +798,14 @@ instance HasRepoSaver RepoEnv where
...
@@ -797,15 +798,14 @@ instance HasRepoSaver RepoEnv where
type
RepoCmdM
env
err
m
=
type
RepoCmdM
env
err
m
=
(
MonadReader
env
m
(
MonadReader
env
m
,
MonadError
err
m
,
MonadError
err
m
,
MonadIO
m
-- TODO liftIO -> liftBase
,
MonadBaseControl
IO
m
,
MonadBaseControl
IO
m
,
HasRepo
env
,
HasRepo
env
)
)
------------------------------------------------------------------------
------------------------------------------------------------------------
saveRepo
::
(
MonadReader
env
m
,
MonadIO
m
,
HasRepoSaver
env
)
saveRepo
::
(
MonadReader
env
m
,
Monad
Base
IO
m
,
HasRepoSaver
env
)
=>
m
()
=>
m
()
saveRepo
=
lift
IO
=<<
view
repoSaver
saveRepo
=
lift
Base
=<<
view
repoSaver
listTypeConflictResolution
::
ListType
->
ListType
->
ListType
listTypeConflictResolution
::
ListType
->
ListType
->
ListType
listTypeConflictResolution
_
_
=
undefined
-- TODO Use Map User ListType
listTypeConflictResolution
_
_
=
undefined
-- TODO Use Map User ListType
...
@@ -836,7 +836,7 @@ copyListNgrams :: RepoCmdM env err m
...
@@ -836,7 +836,7 @@ copyListNgrams :: RepoCmdM env err m
-> m ()
-> m ()
copyListNgrams srcListId dstListId ngramsType = do
copyListNgrams srcListId dstListId ngramsType = do
var <- view repoVar
var <- view repoVar
lift
IO
$ modifyMVar_ var $
lift
Base
$ modifyMVar_ var $
pure . (r_state . at ngramsType %~ (Just . f . something))
pure . (r_state . at ngramsType %~ (Just . f . something))
saveRepo
saveRepo
where
where
...
@@ -851,7 +851,7 @@ addListNgrams :: RepoCmdM env err m
...
@@ -851,7 +851,7 @@ addListNgrams :: RepoCmdM env err m
-> [NgramsElement] -> m ()
-> [NgramsElement] -> m ()
addListNgrams listId ngramsType nes = do
addListNgrams listId ngramsType nes = do
var <- view repoVar
var <- view repoVar
lift
IO
$ modifyMVar_ var $
lift
Base
$ modifyMVar_ var $
pure . (r_state . at ngramsType . _Just . at listId . _Just <>~ m)
pure . (r_state . at ngramsType . _Just . at listId . _Just <>~ m)
saveRepo
saveRepo
where
where
...
@@ -873,7 +873,7 @@ setListNgrams :: RepoCmdM env err m
...
@@ -873,7 +873,7 @@ setListNgrams :: RepoCmdM env err m
->
m
()
->
m
()
setListNgrams
listId
ngramsType
ns
=
do
setListNgrams
listId
ngramsType
ns
=
do
var
<-
view
repoVar
var
<-
view
repoVar
lift
IO
$
modifyMVar_
var
$
lift
Base
$
modifyMVar_
var
$
pure
.
(
r_state
pure
.
(
r_state
.
at
ngramsType
%~
.
at
ngramsType
%~
(
Just
.
(
Just
.
...
@@ -901,7 +901,7 @@ putListNgrams' :: RepoCmdM env err m
...
@@ -901,7 +901,7 @@ putListNgrams' :: RepoCmdM env err m
putListNgrams'
listId
ngramsType
ns
=
do
putListNgrams'
listId
ngramsType
ns
=
do
-- printDebug "putListNgrams" (length nes)
-- printDebug "putListNgrams" (length nes)
var
<-
view
repoVar
var
<-
view
repoVar
lift
IO
$
modifyMVar_
var
$
lift
Base
$
modifyMVar_
var
$
pure
.
(
r_state
pure
.
(
r_state
.
at
ngramsType
%~
.
at
ngramsType
%~
(
Just
.
(
Just
.
...
@@ -930,7 +930,7 @@ currentVersion :: RepoCmdM env err m
...
@@ -930,7 +930,7 @@ currentVersion :: RepoCmdM env err m
=>
m
Version
=>
m
Version
currentVersion
=
do
currentVersion
=
do
var
<-
view
repoVar
var
<-
view
repoVar
r
<-
lift
IO
$
readMVar
var
r
<-
lift
Base
$
readMVar
var
pure
$
r
^.
r_version
pure
$
r
^.
r_version
tableNgramsPull
::
RepoCmdM
env
err
m
tableNgramsPull
::
RepoCmdM
env
err
m
...
@@ -939,7 +939,7 @@ tableNgramsPull :: RepoCmdM env err m
...
@@ -939,7 +939,7 @@ tableNgramsPull :: RepoCmdM env err m
->
m
(
Versioned
NgramsTablePatch
)
->
m
(
Versioned
NgramsTablePatch
)
tableNgramsPull
listId
ngramsType
p_version
=
do
tableNgramsPull
listId
ngramsType
p_version
=
do
var
<-
view
repoVar
var
<-
view
repoVar
r
<-
lift
IO
$
readMVar
var
r
<-
lift
Base
$
readMVar
var
let
let
q
=
mconcat
$
take
(
r
^.
r_version
-
p_version
)
(
r
^.
r_history
)
q
=
mconcat
$
take
(
r
^.
r_version
-
p_version
)
(
r
^.
r_history
)
...
@@ -968,7 +968,7 @@ tableNgramsPut tabType listId (Versioned p_version p_table)
...
@@ -968,7 +968,7 @@ tableNgramsPut tabType listId (Versioned p_version p_table)
assertValid
p_validity
assertValid
p_validity
var
<-
view
repoVar
var
<-
view
repoVar
vq'
<-
lift
IO
$
modifyMVar
var
$
\
r
->
do
vq'
<-
lift
Base
$
modifyMVar
var
$
\
r
->
do
let
let
q
=
mconcat
$
take
(
r
^.
r_version
-
p_version
)
(
r
^.
r_history
)
q
=
mconcat
$
take
(
r
^.
r_version
-
p_version
)
(
r
^.
r_history
)
(
p'
,
q'
)
=
transformWith
ngramsStatePatchConflictResolution
p
q
(
p'
,
q'
)
=
transformWith
ngramsStatePatchConflictResolution
p
q
...
@@ -1008,7 +1008,7 @@ getNgramsTableMap :: RepoCmdM env err m
...
@@ -1008,7 +1008,7 @@ getNgramsTableMap :: RepoCmdM env err m
->
m
(
Versioned
NgramsTableMap
)
->
m
(
Versioned
NgramsTableMap
)
getNgramsTableMap
nodeId
ngramsType
=
do
getNgramsTableMap
nodeId
ngramsType
=
do
v
<-
view
repoVar
v
<-
view
repoVar
repo
<-
lift
IO
$
readMVar
v
repo
<-
lift
Base
$
readMVar
v
pure
$
Versioned
(
repo
^.
r_version
)
pure
$
Versioned
(
repo
^.
r_version
)
(
repo
^.
r_state
.
at
ngramsType
.
_Just
.
at
nodeId
.
_Just
)
(
repo
^.
r_state
.
at
ngramsType
.
_Just
.
at
nodeId
.
_Just
)
...
@@ -1020,8 +1020,8 @@ type MaxSize = Int
...
@@ -1020,8 +1020,8 @@ type MaxSize = Int
-- | Table of Ngrams is a ListNgrams formatted (sorted and/or cut).
-- | Table of Ngrams is a ListNgrams formatted (sorted and/or cut).
-- TODO: should take only one ListId
-- TODO: should take only one ListId
getTime'
::
MonadIO
m
=>
m
TimeSpec
getTime'
::
Monad
Base
IO
m
=>
m
TimeSpec
getTime'
=
lift
IO
$
getTime
ProcessCPUTime
getTime'
=
lift
Base
$
getTime
ProcessCPUTime
getTableNgrams
::
forall
env
err
m
.
getTableNgrams
::
forall
env
err
m
.
...
@@ -1087,7 +1087,7 @@ getTableNgrams _nType nId tabType listId limit_ offset
...
@@ -1087,7 +1087,7 @@ getTableNgrams _nType nId tabType listId limit_ offset
ngramsType
ngramsType
ngrams_terms
ngrams_terms
t2
<-
getTime'
t2
<-
getTime'
lift
IO
$
hprint
stderr
lift
Base
$
hprint
stderr
(
"getTableNgrams/setScores #ngrams="
%
int
%
" time="
%
timeSpecs
%
"
\n
"
)
(
"getTableNgrams/setScores #ngrams="
%
int
%
" time="
%
timeSpecs
%
"
\n
"
)
(
length
ngrams_terms
)
t1
t2
(
length
ngrams_terms
)
t1
t2
{-
{-
...
@@ -1116,7 +1116,7 @@ getTableNgrams _nType nId tabType listId limit_ offset
...
@@ -1116,7 +1116,7 @@ getTableNgrams _nType nId tabType listId limit_ offset
.
setScores
(
not
scoresNeeded
)
.
setScores
(
not
scoresNeeded
)
.
selectAndPaginate
.
selectAndPaginate
t3
<-
getTime'
t3
<-
getTime'
lift
IO
$
hprint
stderr
lift
Base
$
hprint
stderr
(
"getTableNgrams total="
%
timeSpecs
(
"getTableNgrams total="
%
timeSpecs
%
" map1="
%
timeSpecs
%
" map1="
%
timeSpecs
%
" map2="
%
timeSpecs
%
" map2="
%
timeSpecs
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
2c6f3936
...
@@ -24,7 +24,6 @@ module Gargantext.API.Ngrams.List
...
@@ -24,7 +24,6 @@ module Gargantext.API.Ngrams.List
where
where
import
Control.Lens
hiding
(
elements
)
import
Control.Lens
hiding
(
elements
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Aeson
import
Data.Aeson
import
Data.List
(
zip
)
import
Data.List
(
zip
)
import
Data.Map
(
Map
,
toList
,
fromList
)
import
Data.Map
(
Map
,
toList
,
fromList
)
...
@@ -111,7 +110,7 @@ type PostAPI = Summary "Update List"
...
@@ -111,7 +110,7 @@ type PostAPI = Summary "Update List"
postAsync
::
ListId
->
GargServer
PostAPI
postAsync
::
ListId
->
GargServer
PostAPI
postAsync
lId
=
postAsync
lId
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
f
log'
->
postAsync'
lId
f
(
lift
IO
.
log'
))
JobFunction
(
\
f
log'
->
postAsync'
lId
f
(
lift
Base
.
log'
))
postAsync'
::
FlowCmdM
env
err
m
postAsync'
::
FlowCmdM
env
err
m
=>
ListId
=>
ListId
...
...
src/Gargantext/API/Ngrams/Tools.hs
View file @
2c6f3936
...
@@ -37,7 +37,7 @@ type RootTerm = Text
...
@@ -37,7 +37,7 @@ type RootTerm = Text
getRepo
::
RepoCmdM
env
err
m
=>
m
NgramsRepo
getRepo
::
RepoCmdM
env
err
m
=>
m
NgramsRepo
getRepo
=
do
getRepo
=
do
v
<-
view
repoVar
v
<-
view
repoVar
lift
IO
$
readMVar
v
lift
Base
$
readMVar
v
listNgramsFromRepo
::
[
ListId
]
->
NgramsType
listNgramsFromRepo
::
[
ListId
]
->
NgramsType
->
NgramsRepo
->
Map
Text
NgramsRepoElement
->
NgramsRepo
->
Map
Text
NgramsRepoElement
...
...
src/Gargantext/Core/Types.hs
View file @
2c6f3936
...
@@ -139,7 +139,7 @@ class HasInvalidError e where
...
@@ -139,7 +139,7 @@ class HasInvalidError e where
assertValid
::
(
MonadError
e
m
,
HasInvalidError
e
)
=>
Validation
->
m
()
assertValid
::
(
MonadError
e
m
,
HasInvalidError
e
)
=>
Validation
->
m
()
assertValid
v
=
when
(
not
$
validationIsValid
v
)
$
throwError
$
_InvalidError
#
v
assertValid
v
=
when
(
not
$
validationIsValid
v
)
$
throwError
$
_InvalidError
#
v
-- assertValid :: MonadBase IO m => Validation -> m ()
-- assertValid v = when (not $ validationIsValid v) $ fail $ show v
-- assertValid v = when (not $ validationIsValid v) $ fail $ show v
...
...
src/Gargantext/Database/Flow.hs
View file @
2c6f3936
...
@@ -44,7 +44,6 @@ import Data.Tuple.Extra (first, second)
...
@@ -44,7 +44,6 @@ import Data.Tuple.Extra (first, second)
import
Data.Traversable
(
traverse
)
import
Data.Traversable
(
traverse
)
import
Debug.Trace
(
trace
)
import
Debug.Trace
(
trace
)
import
Control.Lens
((
^.
),
view
,
_Just
)
import
Control.Lens
((
^.
),
view
,
_Just
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.List
(
concat
)
import
Data.List
(
concat
)
import
Data.Map
(
Map
,
lookup
)
import
Data.Map
(
Map
,
lookup
)
import
Data.Maybe
(
Maybe
(
..
),
catMaybes
)
import
Data.Maybe
(
Maybe
(
..
),
catMaybes
)
...
@@ -109,7 +108,7 @@ _flowCorpusApi :: ( FlowCmdM env err m)
...
@@ -109,7 +108,7 @@ _flowCorpusApi :: ( FlowCmdM env err m)
->
ApiQuery
->
ApiQuery
->
m
CorpusId
->
m
CorpusId
_flowCorpusApi
u
n
tt
l
q
=
do
_flowCorpusApi
u
n
tt
l
q
=
do
docs
<-
lift
IO
$
splitEvery
500
<$>
getDataApi
(
_tt_lang
tt
)
l
q
docs
<-
lift
Base
$
splitEvery
500
<$>
getDataApi
(
_tt_lang
tt
)
l
q
flowCorpus
u
n
tt
docs
flowCorpus
u
n
tt
docs
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -121,7 +120,7 @@ flowAnnuaire :: FlowCmdM env err m
...
@@ -121,7 +120,7 @@ flowAnnuaire :: FlowCmdM env err m
->
FilePath
->
FilePath
->
m
AnnuaireId
->
m
AnnuaireId
flowAnnuaire
u
n
l
filePath
=
do
flowAnnuaire
u
n
l
filePath
=
do
docs
<-
lift
IO
$
((
splitEvery
500
<$>
deserialiseImtUsersFromFile
filePath
)
::
IO
[[
HyperdataContact
]])
docs
<-
lift
Base
$
((
splitEvery
500
<$>
deserialiseImtUsersFromFile
filePath
)
::
IO
[[
HyperdataContact
]])
flow
(
Nothing
::
Maybe
HyperdataAnnuaire
)
u
n
l
docs
flow
(
Nothing
::
Maybe
HyperdataAnnuaire
)
u
n
l
docs
-- UNUSED
-- UNUSED
...
@@ -130,7 +129,7 @@ _flowCorpusDebat :: FlowCmdM env err m
...
@@ -130,7 +129,7 @@ _flowCorpusDebat :: FlowCmdM env err m
->
Limit
->
FilePath
->
Limit
->
FilePath
->
m
CorpusId
->
m
CorpusId
_flowCorpusDebat
u
n
l
fp
=
do
_flowCorpusDebat
u
n
l
fp
=
do
docs
<-
lift
IO
(
splitEvery
500
docs
<-
lift
Base
(
splitEvery
500
<$>
take
l
<$>
take
l
<$>
readFile'
fp
<$>
readFile'
fp
::
IO
[[
GD
.
GrandDebatReference
]]
::
IO
[[
GD
.
GrandDebatReference
]]
...
@@ -143,7 +142,7 @@ flowCorpusFile :: FlowCmdM env err m
...
@@ -143,7 +142,7 @@ flowCorpusFile :: FlowCmdM env err m
->
TermType
Lang
->
FileFormat
->
FilePath
->
TermType
Lang
->
FileFormat
->
FilePath
->
m
CorpusId
->
m
CorpusId
flowCorpusFile
u
n
l
la
ff
fp
=
do
flowCorpusFile
u
n
l
la
ff
fp
=
do
docs
<-
lift
IO
(
splitEvery
500
docs
<-
lift
Base
(
splitEvery
500
<$>
take
l
<$>
take
l
<$>
parseFile
ff
fp
<$>
parseFile
ff
fp
)
)
...
@@ -439,7 +438,7 @@ instance ExtractNgramsT HyperdataDocument
...
@@ -439,7 +438,7 @@ instance ExtractNgramsT HyperdataDocument
terms'
<-
map
text2ngrams
terms'
<-
map
text2ngrams
<$>
map
(
intercalate
" "
.
_terms_label
)
<$>
map
(
intercalate
" "
.
_terms_label
)
<$>
concat
<$>
concat
<$>
lift
IO
(
extractTerms
lang'
$
hasText
doc
)
<$>
lift
Base
(
extractTerms
lang'
$
hasText
doc
)
pure
$
Map
.
fromList
$
[(
source
,
Map
.
singleton
Sources
1
)]
pure
$
Map
.
fromList
$
[(
source
,
Map
.
singleton
Sources
1
)]
<>
[(
i'
,
Map
.
singleton
Institutes
1
)
|
i'
<-
institutes
]
<>
[(
i'
,
Map
.
singleton
Institutes
1
)
|
i'
<-
institutes
]
...
...
src/Gargantext/Database/Flow/Annuaire.hs
View file @
2c6f3936
...
@@ -29,7 +29,7 @@ import Gargantext.Database.Flow
...
@@ -29,7 +29,7 @@ import Gargantext.Database.Flow
flowAnnuaire :: FlowCmdM env ServantErr m => FilePath -> m ()
flowAnnuaire :: FlowCmdM env ServantErr m => FilePath -> m ()
flowAnnuaire filePath = do
flowAnnuaire filePath = do
contacts <- lift
IO
$ deserialiseImtUsersFromFile filePath
contacts <- lift
Base
$ deserialiseImtUsersFromFile filePath
ps <- flowInsertAnnuaire "Annuaire"
ps <- flowInsertAnnuaire "Annuaire"
$ map (\h-> ToDbContact h)
$ map (\h-> ToDbContact h)
$ map addUniqIdsContact contacts
$ map addUniqIdsContact contacts
...
...
src/Gargantext/Database/Utils.hs
View file @
2c6f3936
...
@@ -61,12 +61,11 @@ instance HasConnectionPool (Pool Connection) where
...
@@ -61,12 +61,11 @@ instance HasConnectionPool (Pool Connection) where
type
CmdM'
env
err
m
=
type
CmdM'
env
err
m
=
(
MonadReader
env
m
(
MonadReader
env
m
,
MonadError
err
m
,
MonadError
err
m
,
MonadIO
m
,
Monad
BaseControl
IO
m
)
)
type
CmdM
env
err
m
=
type
CmdM
env
err
m
=
(
CmdM'
env
err
m
(
CmdM'
env
err
m
,
MonadBaseControl
IO
m
,
HasConnectionPool
env
,
HasConnectionPool
env
)
)
...
@@ -81,7 +80,7 @@ fromInt64ToInt = fromIntegral
...
@@ -81,7 +80,7 @@ fromInt64ToInt = fromIntegral
mkCmd
::
(
Connection
->
IO
a
)
->
Cmd
err
a
mkCmd
::
(
Connection
->
IO
a
)
->
Cmd
err
a
mkCmd
k
=
do
mkCmd
k
=
do
pool
<-
view
connPool
pool
<-
view
connPool
withResource
pool
(
lift
IO
.
k
)
withResource
pool
(
lift
Base
.
k
)
runCmd
::
(
HasConnectionPool
env
)
runCmd
::
(
HasConnectionPool
env
)
=>
env
->
Cmd'
env
err
a
=>
env
->
Cmd'
env
err
a
...
@@ -106,7 +105,7 @@ runPGSQuery' :: (PGS.ToRow a, PGS.FromRow b) => PGS.Query -> a -> Cmd err [b]
...
@@ -106,7 +105,7 @@ runPGSQuery' :: (PGS.ToRow a, PGS.FromRow b) => PGS.Query -> a -> Cmd err [b]
runPGSQuery'
q
a
=
mkCmd
$
\
conn
->
PGS
.
query
conn
q
a
runPGSQuery'
q
a
=
mkCmd
$
\
conn
->
PGS
.
query
conn
q
a
runPGSQuery
::
(
MonadError
err
m
,
MonadReader
env
m
,
MonadBaseControl
IO
m
,
runPGSQuery
::
(
MonadError
err
m
,
MonadReader
env
m
,
MonadBaseControl
IO
m
,
PGS
.
FromRow
r
,
PGS
.
ToRow
q
,
MonadIO
m
,
HasConnectionPool
env
)
PGS
.
FromRow
r
,
PGS
.
ToRow
q
,
HasConnectionPool
env
)
=>
PGS
.
Query
->
q
->
m
[
r
]
=>
PGS
.
Query
->
q
->
m
[
r
]
runPGSQuery
q
a
=
mkCmd
$
\
conn
->
catch
(
PGS
.
query
conn
q
a
)
(
printError
conn
)
runPGSQuery
q
a
=
mkCmd
$
\
conn
->
catch
(
PGS
.
query
conn
q
a
)
(
printError
conn
)
where
where
...
...
src/Gargantext/Prelude.hs
View file @
2c6f3936
...
@@ -12,6 +12,7 @@ Portability : POSIX
...
@@ -12,6 +12,7 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RankNTypes #-}
...
@@ -28,11 +29,11 @@ module Gargantext.Prelude
...
@@ -28,11 +29,11 @@ module Gargantext.Prelude
,
round
,
round
,
sortWith
,
sortWith
,
module
Prelude
,
module
Prelude
,
MonadBase
(
..
)
)
)
where
where
import
Control.Monad.IO.Class
(
liftIO
,
MonadIO
)
import
Control.Monad.Base
(
MonadBase
(
..
))
import
Control.Concurrent
(
newEmptyMVar
,
takeMVar
,
putMVar
,
forkIO
)
import
GHC.Exts
(
sortWith
)
import
GHC.Exts
(
sortWith
)
import
GHC.Err.Located
(
undefined
)
import
GHC.Err.Located
(
undefined
)
import
GHC.Real
(
round
)
import
GHC.Real
(
round
)
...
@@ -43,7 +44,6 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
...
@@ -43,7 +44,6 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
,
Enum
,
Bounded
,
Float
,
Enum
,
Bounded
,
Float
,
Floating
,
Char
,
IO
,
Floating
,
Char
,
IO
,
pure
,
(
>>=
),
(
=<<
),
(
<*>
),
(
<$>
),
(
>>
)
,
pure
,
(
>>=
),
(
=<<
),
(
<*>
),
(
<$>
),
(
>>
)
,
putStrLn
,
head
,
flip
,
head
,
flip
,
Ord
,
Integral
,
Foldable
,
RealFrac
,
Monad
,
filter
,
Ord
,
Integral
,
Foldable
,
RealFrac
,
Monad
,
filter
,
reverse
,
map
,
mapM
,
zip
,
drop
,
take
,
zipWith
,
reverse
,
map
,
mapM
,
zip
,
drop
,
take
,
zipWith
...
@@ -63,7 +63,7 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
...
@@ -63,7 +63,7 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
,
panic
,
panic
)
)
import
Prelude
(
Enum
,
Bounded
,
minBound
,
maxBound
)
import
Prelude
(
Enum
,
Bounded
,
minBound
,
maxBound
,
putStrLn
)
-- TODO import functions optimized in Utils.Count
-- TODO import functions optimized in Utils.Count
-- import Protolude hiding (head, last, all, any, sum, product, length)
-- import Protolude hiding (head, last, all, any, sum, product, length)
-- import Gargantext.Utils.Count
-- import Gargantext.Utils.Count
...
@@ -81,8 +81,8 @@ import Text.Read (Read())
...
@@ -81,8 +81,8 @@ import Text.Read (Read())
import
Data.String.Conversions
(
cs
)
import
Data.String.Conversions
(
cs
)
printDebug
::
(
Show
a
,
MonadIO
m
)
=>
[
Char
]
->
a
->
m
()
printDebug
::
(
Show
a
,
Monad
Base
IO
m
)
=>
[
Char
]
->
a
->
m
()
printDebug
msg
x
=
putStrLn
$
msg
<>
" "
<>
show
x
printDebug
msg
x
=
liftBase
.
putStrLn
$
msg
<>
" "
<>
show
x
-- printDebug _ _ = pure ()
-- printDebug _ _ = pure ()
...
...
src/Gargantext/Prelude/Utils.hs
View file @
2c6f3936
...
@@ -9,6 +9,7 @@ Portability : POSIX
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
@@ -17,7 +18,6 @@ module Gargantext.Prelude.Utils
...
@@ -17,7 +18,6 @@ module Gargantext.Prelude.Utils
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Control.Monad.Reader
(
MonadReader
)
import
Control.Monad.Reader
(
MonadReader
)
import
Control.Monad.IO.Class
(
MonadIO
,
liftIO
)
import
Control.Monad.Random.Class
(
MonadRandom
)
import
Control.Monad.Random.Class
(
MonadRandom
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Control.Monad.Reader
(
ask
)
import
Control.Monad.Reader
(
ask
)
...
@@ -84,23 +84,23 @@ class ReadFile a where
...
@@ -84,23 +84,23 @@ class ReadFile a where
readFile'
::
FilePath
->
IO
a
readFile'
::
FilePath
->
IO
a
writeFile
::
(
MonadReader
env
m
,
MonadIO
m
,
HasSettings
env
,
SaveFile
a
)
writeFile
::
(
MonadReader
env
m
,
Monad
Base
IO
m
,
HasSettings
env
,
SaveFile
a
)
=>
a
->
m
FilePath
=>
a
->
m
FilePath
writeFile
a
=
do
writeFile
a
=
do
dataPath
<-
view
(
settings
.
fileFolder
)
<$>
ask
dataPath
<-
view
(
settings
.
fileFolder
)
<$>
ask
(
fp
,
fn
)
<-
lift
IO
$
(
toPath
3
)
.
sha
.
Text
.
pack
.
show
<$>
newStdGen
(
fp
,
fn
)
<-
lift
Base
$
(
toPath
3
)
.
sha
.
Text
.
pack
.
show
<$>
newStdGen
let
foldPath
=
dataPath
<>
"/"
<>
fp
let
foldPath
=
dataPath
<>
"/"
<>
fp
filePath
=
foldPath
<>
"/"
<>
fn
filePath
=
foldPath
<>
"/"
<>
fn
_
<-
lift
IO
$
createDirectoryIfMissing
True
foldPath
_
<-
lift
Base
$
createDirectoryIfMissing
True
foldPath
_
<-
lift
IO
$
saveFile'
filePath
a
_
<-
lift
Base
$
saveFile'
filePath
a
pure
filePath
pure
filePath
readFile
::
(
MonadReader
env
m
,
MonadIO
m
,
HasSettings
env
,
ReadFile
a
)
readFile
::
(
MonadReader
env
m
,
Monad
Base
IO
m
,
HasSettings
env
,
ReadFile
a
)
=>
FilePath
->
m
a
=>
FilePath
->
m
a
readFile
fp
=
do
readFile
fp
=
do
dataPath
<-
view
(
settings
.
fileFolder
)
<$>
ask
dataPath
<-
view
(
settings
.
fileFolder
)
<$>
ask
lift
IO
$
readFile'
$
dataPath
<>
"/"
<>
fp
lift
Base
$
readFile'
$
dataPath
<>
"/"
<>
fp
src/Gargantext/Text/List.hs
View file @
2c6f3936
...
@@ -9,6 +9,7 @@ Portability : POSIX
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RankNTypes #-}
...
...
src/Gargantext/Text/List/Learn.hs
View file @
2c6f3936
...
@@ -13,6 +13,7 @@ CSV parser for Gargantext corpus files.
...
@@ -13,6 +13,7 @@ CSV parser for Gargantext corpus files.
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
@@ -20,7 +21,6 @@ module Gargantext.Text.List.Learn
...
@@ -20,7 +21,6 @@ module Gargantext.Text.List.Learn
where
where
import
Control.Monad.Reader
(
MonadReader
)
import
Control.Monad.Reader
(
MonadReader
)
import
Control.Monad.IO.Class
(
MonadIO
,
liftIO
)
import
Gargantext.API.Settings
import
Gargantext.API.Settings
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
maybe
)
import
Data.Maybe
(
maybe
)
...
@@ -87,18 +87,18 @@ type Tests = Map ListType [Vec.Vector Double]
...
@@ -87,18 +87,18 @@ type Tests = Map ListType [Vec.Vector Double]
type
Score
=
Double
type
Score
=
Double
type
Param
=
Double
type
Param
=
Double
grid
::
(
MonadReader
env
m
,
MonadIO
m
,
HasSettings
env
)
grid
::
(
MonadReader
env
m
,
Monad
Base
IO
m
,
HasSettings
env
)
=>
Param
->
Param
->
Train
->
[
Tests
]
->
m
(
Maybe
Model
)
=>
Param
->
Param
->
Train
->
[
Tests
]
->
m
(
Maybe
Model
)
grid
_
_
_
[]
=
panic
"Gargantext.Text.List.Learn.grid : empty test data"
grid
_
_
_
[]
=
panic
"Gargantext.Text.List.Learn.grid : empty test data"
grid
s
e
tr
te
=
do
grid
s
e
tr
te
=
do
let
let
grid'
::
(
MonadReader
env
m
,
MonadIO
m
,
HasSettings
env
)
grid'
::
(
MonadReader
env
m
,
Monad
Base
IO
m
,
HasSettings
env
)
=>
Double
->
Double
=>
Double
->
Double
->
Train
->
Train
->
[
Tests
]
->
[
Tests
]
->
m
(
Score
,
Model
)
->
m
(
Score
,
Model
)
grid'
x
y
tr'
te'
=
do
grid'
x
y
tr'
te'
=
do
model''
<-
lift
IO
$
trainList
x
y
tr'
model''
<-
lift
Base
$
trainList
x
y
tr'
let
let
model'
=
ModelSVM
model''
(
Just
x
)
(
Just
y
)
model'
=
ModelSVM
model''
(
Just
x
)
(
Just
y
)
...
@@ -117,7 +117,7 @@ grid s e tr te = do
...
@@ -117,7 +117,7 @@ grid s e tr te = do
$
map
(
\
(
k
,
vs
)
->
zip
(
repeat
k
)
vs
)
$
map
(
\
(
k
,
vs
)
->
zip
(
repeat
k
)
vs
)
$
Map
.
toList
t
$
Map
.
toList
t
res'
<-
lift
IO
$
predictList
m
toGuess
res'
<-
lift
Base
$
predictList
m
toGuess
pure
$
score''
$
score'
$
List
.
zip
res
res'
pure
$
score''
$
score'
$
List
.
zip
res
res'
score
<-
mapM
(
getScore
model'
)
te'
score
<-
mapM
(
getScore
model'
)
te'
...
...
src/Gargantext/Text/Terms/Multi/PosTagging.hs
View file @
2c6f3936
...
@@ -48,8 +48,6 @@ import Gargantext.Prelude
...
@@ -48,8 +48,6 @@ import Gargantext.Prelude
import
Network.HTTP.Simple
import
Network.HTTP.Simple
import
Control.Monad.Catch
(
MonadThrow
)
import
Control.Monad.IO.Class
(
MonadIO
)
import
Data.String.Conversions
(
ConvertibleStrings
)
import
Data.String.Conversions
(
ConvertibleStrings
)
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -116,9 +114,10 @@ $(deriveJSON (unPrefix "_") ''PosSentences)
...
@@ -116,9 +114,10 @@ $(deriveJSON (unPrefix "_") ''PosSentences)
--
--
corenlp'
::
(
MonadThrow
m
,
MonadIO
m
,
FromJSON
a
corenlp'
::
(
FromJSON
a
,
ConvertibleStrings
p
ByteString
)
=>
,
ConvertibleStrings
p
ByteString
)
=>
Lang
->
p
->
m
(
Response
a
)
Lang
->
p
->
IO
(
Response
a
)
corenlp'
lang
txt
=
do
corenlp'
lang
txt
=
do
let
properties
=
case
lang
of
let
properties
=
case
lang
of
EN
->
"{
\"
annotators
\"
:
\"
tokenize,ssplit,pos,ner
\"
,
\"
outputFormat
\"
:
\"
json
\"
}"
EN
->
"{
\"
annotators
\"
:
\"
tokenize,ssplit,pos,ner
\"
,
\"
outputFormat
\"
:
\"
json
\"
}"
...
...
src/Gargantext/Viz/Graph.hs
View file @
2c6f3936
...
@@ -10,6 +10,7 @@ Portability : POSIX
...
@@ -10,6 +10,7 @@ Portability : POSIX
-}
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}
...
@@ -18,7 +19,6 @@ module Gargantext.Viz.Graph
...
@@ -18,7 +19,6 @@ module Gargantext.Viz.Graph
where
where
import
Control.Lens
(
makeLenses
)
import
Control.Lens
(
makeLenses
)
import
Control.Monad.IO.Class
(
MonadIO
(
liftIO
))
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.ByteString.Lazy
as
DBL
(
readFile
,
writeFile
)
import
Data.ByteString.Lazy
as
DBL
(
readFile
,
writeFile
)
import
Data.Swagger
import
Data.Swagger
...
@@ -189,7 +189,7 @@ graphV3ToGraphWithFiles g1 g2 = do
...
@@ -189,7 +189,7 @@ graphV3ToGraphWithFiles g1 g2 = do
DBL
.
writeFile
g2
(
DA
.
encode
$
graphV3ToGraph
newGraph
)
DBL
.
writeFile
g2
(
DA
.
encode
$
graphV3ToGraph
newGraph
)
readGraphFromJson
::
MonadIO
m
=>
FilePath
->
m
(
Maybe
Graph
)
readGraphFromJson
::
Monad
Base
IO
m
=>
FilePath
->
m
(
Maybe
Graph
)
readGraphFromJson
fp
=
do
readGraphFromJson
fp
=
do
graph
<-
lift
IO
$
DBL
.
readFile
fp
graph
<-
lift
Base
$
DBL
.
readFile
fp
pure
$
DA
.
decode
graph
pure
$
DA
.
decode
graph
src/Gargantext/Viz/Graph/API.hs
View file @
2c6f3936
...
@@ -28,7 +28,6 @@ module Gargantext.Viz.Graph.API
...
@@ -28,7 +28,6 @@ module Gargantext.Viz.Graph.API
import
Debug.Trace
(
trace
)
import
Debug.Trace
(
trace
)
import
Control.Concurrent
-- (forkIO)
import
Control.Concurrent
-- (forkIO)
import
Control.Lens
(
set
,
(
^.
),
_Just
,
(
^?
))
import
Control.Lens
(
set
,
(
^.
),
_Just
,
(
^?
))
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Aeson
import
Data.Aeson
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Swagger
import
Data.Swagger
...
@@ -89,10 +88,10 @@ graphAPI u n = getGraph u n
...
@@ -89,10 +88,10 @@ graphAPI u n = getGraph u n
-- Each process has to be tailored
-- Each process has to be tailored
getGraph' :: UserId -> NodeId -> GargServer (Get '[JSON] Graph)
getGraph' :: UserId -> NodeId -> GargServer (Get '[JSON] Graph)
getGraph' u n = do
getGraph' u n = do
newGraph <- lift
IO
newEmptyMVar
newGraph <- lift
Base
newEmptyMVar
g <- getGraph u n
g <- getGraph u n
_ <- lift
IO
$ forkIO $ putMVar newGraph g
_ <- lift
Base
$ forkIO $ putMVar newGraph g
g' <- lift
IO
$ takeMVar newGraph
g' <- lift
Base
$ takeMVar newGraph
pure g'
pure g'
-}
-}
getGraph
::
UserId
->
NodeId
->
GargNoServer
Graph
getGraph
::
UserId
->
NodeId
->
GargNoServer
Graph
...
@@ -130,9 +129,9 @@ getGraph uId nId = do
...
@@ -130,9 +129,9 @@ getGraph uId nId = do
-- _ <- updateHyperdata nId (HyperdataGraph $ Just graph'')
-- _ <- updateHyperdata nId (HyperdataGraph $ Just graph'')
-- pure graph''
-- pure graph''
newGraph
<-
lift
IO
newEmptyMVar
newGraph
<-
lift
Base
newEmptyMVar
_
<-
lift
IO
$
forkIO
$
putMVar
newGraph
g
_
<-
lift
Base
$
forkIO
$
putMVar
newGraph
g
g'
<-
lift
IO
$
takeMVar
newGraph
g'
<-
lift
Base
$
takeMVar
newGraph
pure
{- $ trace (show g) $ -}
g'
pure
{- $ trace (show g) $ -}
g'
...
@@ -177,9 +176,9 @@ computeGraphAsync :: HasNodeError err
...
@@ -177,9 +176,9 @@ computeGraphAsync :: HasNodeError err
->
NgramsRepo
->
NgramsRepo
->
Cmd
err
Graph
->
Cmd
err
Graph
computeGraphAsync
cId
nt
repo
=
do
computeGraphAsync
cId
nt
repo
=
do
g
<-
lift
IO
newEmptyMVar
g
<-
lift
Base
newEmptyMVar
_
<-
forkIO
<$>
putMVar
g
<$>
computeGraph
cId
nt
repo
_
<-
forkIO
<$>
putMVar
g
<$>
computeGraph
cId
nt
repo
g'
<-
lift
IO
$
takeMVar
g
g'
<-
lift
Base
$
takeMVar
g
pure
g'
pure
g'
...
@@ -228,7 +227,7 @@ type GraphAsyncAPI = Summary "Update graph"
...
@@ -228,7 +227,7 @@ type GraphAsyncAPI = Summary "Update graph"
graphAsync
::
UserId
->
NodeId
->
GargServer
GraphAsyncAPI
graphAsync
::
UserId
->
NodeId
->
GargServer
GraphAsyncAPI
graphAsync
u
n
=
graphAsync
u
n
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
_
log'
->
graphAsync'
u
n
(
lift
IO
.
log'
))
JobFunction
(
\
_
log'
->
graphAsync'
u
n
(
lift
Base
.
log'
))
graphAsync'
::
UserId
graphAsync'
::
UserId
...
...
src/Gargantext/Viz/Phylo/API.hs
View file @
2c6f3936
...
@@ -42,7 +42,6 @@ import Servant
...
@@ -42,7 +42,6 @@ import Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Web.HttpApiData
(
parseUrlPiece
,
readTextData
)
import
Web.HttpApiData
(
parseUrlPiece
,
readTextData
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Network.HTTP.Media
((
//
),
(
/:
))
import
Network.HTTP.Media
((
//
),
(
/:
))
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -108,7 +107,7 @@ getPhylo phId _lId l msb = do
...
@@ -108,7 +107,7 @@ getPhylo phId _lId l msb = do
branc
=
maybe
2
identity
msb
branc
=
maybe
2
identity
msb
maybePhylo
=
hyperdataPhylo_data
$
_node_hyperdata
phNode
maybePhylo
=
hyperdataPhylo_data
$
_node_hyperdata
phNode
p
<-
lift
IO
$
viewPhylo2Svg
$
viewPhylo
level
branc
$
maybe
phyloFromQuery
identity
maybePhylo
p
<-
lift
Base
$
viewPhylo2Svg
$
viewPhylo
level
branc
$
maybe
phyloFromQuery
identity
maybePhylo
pure
(
SVG
p
)
pure
(
SVG
p
)
------------------------------------------------------------------------
------------------------------------------------------------------------
type
PostPhylo
=
QueryParam
"listId"
ListId
type
PostPhylo
=
QueryParam
"listId"
ListId
...
...
src/Gargantext/Viz/Phylo/Main.hs
View file @
2c6f3936
...
@@ -72,7 +72,7 @@ flowPhylo cId = do
...
@@ -72,7 +72,7 @@ flowPhylo cId = do
docs
=
map
(
(
\
(
y
,
t
)
->
Document
y
t
)
.
filterTerms
patterns
)
docs'
docs
=
map
(
(
\
(
y
,
t
)
->
Document
y
t
)
.
filterTerms
patterns
)
docs'
--lift
IO
$ flowPhylo' (List.sortOn date docs) termList l m fp
--lift
Base
$ flowPhylo' (List.sortOn date docs) termList l m fp
pure
$
buildPhylo
(
List
.
sortOn
date
docs
)
termList
pure
$
buildPhylo
(
List
.
sortOn
date
docs
)
termList
...
...
stack.yaml
View file @
2c6f3936
...
@@ -47,7 +47,7 @@ extra-deps:
...
@@ -47,7 +47,7 @@ extra-deps:
#- git: https://github.com/delanoe/servant-job.git
#- git: https://github.com/delanoe/servant-job.git
#commit: 7a7b7100e6d132adb4c11b25b2128e6309690ac0
#commit: 7a7b7100e6d132adb4c11b25b2128e6309690ac0
-
git
:
https://github.com/np/servant-job.git
-
git
:
https://github.com/np/servant-job.git
commit
:
4016c76398a56e1a352a45b3ee9d698dd0dd2597
commit
:
5bf03696edad27285b0588aba92b34b48db16832
-
git
:
https://gitlab.iscpif.fr/gargantext/clustering-louvain.git
-
git
:
https://gitlab.iscpif.fr/gargantext/clustering-louvain.git
commit
:
7d74f96dfea8e51fbab1793cc0429b2fe741f73d
commit
:
7d74f96dfea8e51fbab1793cc0429b2fe741f73d
-
git
:
https://github.com/np/patches-map
-
git
:
https://github.com/np/patches-map
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment