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
5ac27a46
Commit
5ac27a46
authored
Apr 07, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-graph-explorer-gexf
parents
d424a377
5b70b168
Changes
63
Hide whitespace changes
Inline
Side-by-side
Showing
63 changed files
with
488 additions
and
273 deletions
+488
-273
Main.hs
bin/gargantext-import/Main.hs
+0
-1
Main.hs
bin/gargantext-server/Main.hs
+13
-3
build-shell.nix
build-shell.nix
+21
-13
install
devops/debian/install
+1
-1
docker-compose.yaml
devops/docker/docker-compose.yaml
+1
-0
package.yaml
package.yaml
+33
-27
pinned-19.09.nix
pinned-19.09.nix
+8
-0
pinned.nix
pinned.nix
+4
-2
shell.nix
shell.nix
+1
-1
API.hs
src/Gargantext/API.hs
+46
-22
Annuaire.hs
src/Gargantext/API/Annuaire.hs
+1
-1
Auth.hs
src/Gargantext/API/Auth.hs
+4
-5
New.hs
src/Gargantext/API/Corpus/New.hs
+22
-27
File.hs
src/Gargantext/API/Corpus/New/File.hs
+7
-8
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+23
-21
List.hs
src/Gargantext/API/Ngrams/List.hs
+2
-3
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+2
-1
Types.hs
src/Gargantext/API/Orchestrator/Types.hs
+2
-2
Settings.hs
src/Gargantext/API/Settings.hs
+17
-13
Types.hs
src/Gargantext/Core/Flow/Types.hs
+1
-0
Types.hs
src/Gargantext/Core/Types.hs
+2
-2
Flow.hs
src/Gargantext/Database/Flow.hs
+5
-6
Annuaire.hs
src/Gargantext/Database/Flow/Annuaire.hs
+1
-1
Pairing.hs
src/Gargantext/Database/Flow/Pairing.hs
+1
-0
Utils.hs
src/Gargantext/Database/Flow/Utils.hs
+1
-0
Init.hs
src/Gargantext/Database/Init.hs
+1
-0
NgramsByNode.hs
src/Gargantext/Database/Metrics/NgramsByNode.hs
+1
-0
Add.hs
src/Gargantext/Database/Node/Document/Add.hs
+2
-0
Insert.hs
src/Gargantext/Database/Node/Document/Insert.hs
+1
-0
Update.hs
src/Gargantext/Database/Node/Update.hs
+1
-0
UpdateOpaleye.hs
src/Gargantext/Database/Node/UpdateOpaleye.hs
+1
-0
Ngrams.hs
src/Gargantext/Database/Schema/Ngrams.hs
+1
-0
NodeNgrams.hs
src/Gargantext/Database/Schema/NodeNgrams.hs
+1
-0
NodeNode.hs
src/Gargantext/Database/Schema/NodeNode.hs
+1
-0
NodeNodeNgrams.hs
src/Gargantext/Database/Schema/NodeNodeNgrams.hs
+1
-0
NodeNodeNgrams2.hs
src/Gargantext/Database/Schema/NodeNodeNgrams2.hs
+1
-0
Node_NodeNgramsNodeNgrams.hs
src/Gargantext/Database/Schema/Node_NodeNgramsNodeNgrams.hs
+1
-0
NodesNgramsRepo.hs
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
+1
-0
User.hs
src/Gargantext/Database/Schema/User.hs
+1
-0
TextSearch.hs
src/Gargantext/Database/TextSearch.hs
+1
-0
Tree.hs
src/Gargantext/Database/Tree.hs
+1
-0
NodeNodeNgrams.hs
src/Gargantext/Database/Triggers/NodeNodeNgrams.hs
+1
-0
Nodes.hs
src/Gargantext/Database/Triggers/Nodes.hs
+1
-0
NodesNodes.hs
src/Gargantext/Database/Triggers/NodesNodes.hs
+1
-0
Utils.hs
src/Gargantext/Database/Utils.hs
+16
-12
Prelude.hs
src/Gargantext/Prelude.hs
+6
-8
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
+154
-22
Bridgeness.hs
src/Gargantext/Viz/Graph/Bridgeness.hs
+1
-1
IGraph.hs
src/Gargantext/Viz/Graph/IGraph.hs
+3
-0
Tools.hs
src/Gargantext/Viz/Graph/Tools.hs
+40
-41
API.hs
src/Gargantext/Viz/Phylo/API.hs
+1
-2
Aggregates.hs
src/Gargantext/Viz/Phylo/Aggregates.hs
+1
-1
Cluster.hs
src/Gargantext/Viz/Phylo/Cluster.hs
+1
-0
Main.hs
src/Gargantext/Viz/Phylo/Main.hs
+1
-1
PhyloTools.hs
src/Gargantext/Viz/Phylo/PhyloTools.hs
+1
-1
TemporalMatching.hs
src/Gargantext/Viz/Phylo/TemporalMatching.hs
+1
-1
ViewMaker.hs
src/Gargantext/Viz/Phylo/View/ViewMaker.hs
+1
-1
stack.yaml
stack.yaml
+3
-3
No files found.
bin/gargantext-import/Main.hs
View file @
5ac27a46
...
@@ -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
...
...
bin/gargantext-server/Main.hs
View file @
5ac27a46
...
@@ -22,9 +22,11 @@ Script to start gargantext with different modes (Dev, Prod, Mock).
...
@@ -22,9 +22,11 @@ Script to start gargantext with different modes (Dev, Prod, Mock).
module
Main
where
module
Main
where
import
Data.Version
(
showVersion
)
import
Options.Generic
import
Data.Text
(
unpack
)
import
Data.Text
(
unpack
)
import
qualified
Paths_gargantext
as
PG
-- cabal magic build module
import
Options.Generic
import
System.Exit
(
exitSuccess
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.API
(
startGargantext
)
-- , startGargantextMock)
import
Gargantext.API
(
startGargantext
)
-- , startGargantextMock)
...
@@ -51,6 +53,8 @@ data MyOptions w =
...
@@ -51,6 +53,8 @@ data MyOptions w =
<?>
"By default: 8008"
<?>
"By default: 8008"
,
ini
::
w
:::
Maybe
Text
,
ini
::
w
:::
Maybe
Text
<?>
"Ini-file path of gargantext.ini"
<?>
"Ini-file path of gargantext.ini"
,
version
::
w
:::
Bool
<?>
"Show version number and exit"
}
}
deriving
(
Generic
)
deriving
(
Generic
)
...
@@ -60,9 +64,15 @@ deriving instance Show (MyOptions Unwrapped)
...
@@ -60,9 +64,15 @@ deriving instance Show (MyOptions Unwrapped)
main
::
IO
()
main
::
IO
()
main
=
do
main
=
do
MyOptions
myMode
myPort
myIniFile
<-
unwrapRecord
MyOptions
myMode
myPort
myIniFile
myVersion
<-
unwrapRecord
"Gargantext server"
"Gargantext server"
if
myVersion
then
do
putStrLn
$
"Version: "
<>
showVersion
PG
.
version
System
.
Exit
.
exitSuccess
else
return
()
let
myPort'
=
case
myPort
of
let
myPort'
=
case
myPort
of
Just
p
->
p
Just
p
->
p
Nothing
->
8008
Nothing
->
8008
...
...
build-shell.nix
View file @
5ac27a46
{
ghc
}:
{
ghc
with
(
import
./pinned.nix
{});
,
pkgs
?
import
./pinned.nix
{}
}:
haskell
.
lib
.
buildStackProject
{
let
inherit
ghc
;
buildInputs
=
with
pkgs
;
[
name
=
"gargantext"
;
buildInputs
=
[
docker-compose
blas
bzip2
bzip2
#gfortran
gfortran
.
cc
.
lib
glibc
gmp
gmp
gsl
gsl
igraph
igraph
liblapack
liblapack
lzma
pcre
pcre
postgresql
postgresql
#stack
xz
xz
zlib
zlib
blas
gfortran7
gfortran7
.
cc
.
lib
];
];
libraryPaths
=
pkgs
.
lib
.
makeLibraryPath
buildInputs
;
in
pkgs
.
haskell
.
lib
.
buildStackProject
rec
{
inherit
ghc
;
inherit
buildInputs
;
name
=
"gargantext"
;
shellHook
=
''
export LD_LIBRARY_PATH="
${
libraryPaths
}
"
export LIBRARY_PATH="
${
libraryPaths
}
"
''
;
}
}
devops/debian/install
View file @
5ac27a46
...
@@ -26,7 +26,7 @@ tmux
...
@@ -26,7 +26,7 @@ tmux
# Open Stack only: attach volumes
# Open Stack only: attach volumes
# attach the volume created (OS interface or API)
# attach the volume created (OS interface or API)
sudo
fdisk
-l
sudo
fdisk
-l
sudo
fisk /dev/vdb
(
n,p,t,83,w
)
sudo
f
d
isk /dev/vdb
(
n,p,t,83,w
)
sudo
mkfs.ext4 /dev/vdb1
sudo
mkfs.ext4 /dev/vdb1
sudo
blkid
sudo
blkid
...
...
devops/docker/docker-compose.yaml
View file @
5ac27a46
...
@@ -3,6 +3,7 @@ version: '3'
...
@@ -3,6 +3,7 @@ version: '3'
services
:
services
:
postgres
:
postgres
:
image
:
'
postgres:latest'
image
:
'
postgres:latest'
network_mode
:
host
ports
:
ports
:
-
5432:5432
-
5432:5432
environment
:
environment
:
...
...
package.yaml
View file @
5ac27a46
...
@@ -10,6 +10,8 @@ copyright:
...
@@ -10,6 +10,8 @@ copyright:
license
:
BSD3
license
:
BSD3
homepage
:
https://gargantext.org
homepage
:
https://gargantext.org
ghc-options
:
-Wall
ghc-options
:
-Wall
extra-libraries
:
-
gfortran
dependencies
:
dependencies
:
-
extra
-
extra
-
text
-
text
...
@@ -82,13 +84,18 @@ library:
...
@@ -82,13 +84,18 @@ library:
-
Gargantext.Viz.Phylo.View.Export
-
Gargantext.Viz.Phylo.View.Export
-
Gargantext.Viz.Phylo.View.ViewMaker
-
Gargantext.Viz.Phylo.View.ViewMaker
dependencies
:
dependencies
:
-
array
-
HSvm
-
KMP
-
MonadRandom
-
QuickCheck
-
QuickCheck
-
SHA
-
Unique
-
accelerate
-
accelerate
-
aeson
-
aeson
-
aeson-lens
-
aeson-lens
-
aeson-pretty
-
aeson-pretty
-
argon2
-
argon2
-
array
-
async
-
async
-
attoparsec
-
attoparsec
-
auto-update
-
auto-update
...
@@ -101,53 +108,51 @@ library:
...
@@ -101,53 +108,51 @@ library:
-
bytestring
-
bytestring
-
case-insensitive
-
case-insensitive
-
cassava
-
cassava
#- charsetdetect-ae # detect charset
-
cereal
# (IGraph)
-
clock
-
clock
-
clustering-louvain
-
clustering-louvain
-
conduit
-
conduit
-
conduit-extra
-
conduit-extra
-
containers
-
containers
-
contravariant
-
contravariant
-
crawlerPubMed
-
crawlerIsidore
-
crawlerHAL
-
crawlerHAL
-
crawlerISTEX
-
crawlerISTEX
-
crawlerIsidore
-
crawlerPubMed
-
data-time-segment
-
data-time-segment
-
deepseq
-
deepseq
-
directory
-
directory
-
duckling
-
duckling
-
exceptions
-
exceptions
-
filepath
-
fast-logger
-
formatting
-
fullstop
-
fclabels
-
fclabels
-
fgl
-
fgl
-
fast-logger
-
filelock
-
filelock
-
filepath
-
formatting
-
full-text-search
-
full-text-search
-
fullstop
-
graphviz
-
graphviz
-
haskell-igraph
-
haskell-igraph
-
hlcm
-
hsparql
-
hstatistics
-
http-api-data
-
http-client
-
http-client
-
http-client-tls
-
http-client-tls
-
http-conduit
-
http-conduit
-
http-media
-
http-media
-
http-api-data
-
http-types
-
http-types
-
hsparql
-
hstatistics
-
HSvm
-
hxt
-
hxt
-
hlcm
-
ini
-
ini
-
insert-ordered-containers
-
insert-ordered-containers
-
jose
-
jose
# - kmeans-vector
-
json-stream
-
json-stream
-
KMP
-
lens
-
lens
-
located-base
-
located-base
-
logging-effect
-
logging-effect
-
matrix
-
matrix
-
monad-control
-
monad-logger
-
monad-logger
-
mtl
-
mtl
-
natural-transformation
-
natural-transformation
...
@@ -166,36 +171,35 @@ library:
...
@@ -166,36 +171,35 @@ library:
-
profunctors
-
profunctors
-
protolude
-
protolude
-
pureMD5
-
pureMD5
-
random-shuffle
-
MonadRandom
-
SHA
-
simple-reflect
-
cereal
# (IGraph)
-
singletons
# (IGraph)
-
quickcheck-instances
-
quickcheck-instances
-
random
-
rake
-
rake
-
random
-
random-shuffle
-
rdf4h
-
regex-compat
-
regex-compat
-
resource-pool
-
resourcet
-
resourcet
-
rdf4h
-
safe
-
safe
-
semigroups
-
semigroups
-
serialise
-
servant
-
servant
-
servant-auth
-
servant-auth
-
servant-auth-server >= 0.4.4.0
-
servant-auth-server >= 0.4.4.0
-
servant-auth-swagger
-
servant-auth-swagger
-
servant-blaze
-
servant-blaze
-
servant-cassava
-
servant-client
-
servant-client
-
servant-flatten
-
servant-flatten
-
servant-job
-
servant-job
-
servant-mock
-
servant-mock
-
servant-multipart
-
servant-multipart
-
servant-server
-
servant-server
-
servant-static-th
-
servant-swagger
-
servant-swagger
-
servant-swagger-ui
-
servant-swagger-ui
-
servant-
static-th
-
servant-
xml
-
s
ervant-cassava
-
s
imple-reflect
-
s
erialise
-
s
ingletons
# (IGraph)
-
split
-
split
-
stemmer
-
stemmer
-
string-conversions
-
string-conversions
...
@@ -209,7 +213,6 @@ library:
...
@@ -209,7 +213,6 @@ library:
-
transformers
-
transformers
-
transformers-base
-
transformers-base
-
unordered-containers
-
unordered-containers
-
Unique
-
uuid
-
uuid
-
validity
-
validity
-
vector
-
vector
...
@@ -220,9 +223,12 @@ library:
...
@@ -220,9 +223,12 @@ library:
-
wreq
-
wreq
-
xml-conduit
-
xml-conduit
-
xml-types
-
xml-types
-
xmlbf
-
yaml
-
yaml
-
zip
-
zip
-
zlib
-
zlib
# - kmeans-vector
#- charsetdetect-ae # detect charset
# - utc
# - utc
# API external connections
# API external connections
...
...
pinned-19.09.nix
0 → 100644
View file @
5ac27a46
# this version of nixpkgs contains liblapack at 3.8.0
# this version of nixpkgs contains gsl at 2.5.0
import
(
builtins
.
fetchTarball
{
url
=
"https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
;
sha256
=
"0mhqhq21y5vrr1f30qd2bvydv4bbbslvyzclhw0kdxmkgg3z4c92"
;
}
)
pinned.nix
View file @
5ac27a46
# this version of nixpkgs contains liblapack at 3.8.0
# this version of nixpkgs contains gsl at 2.5.0
import
(
import
(
builtins
.
fetchTarball
{
builtins
.
fetchTarball
{
url
=
"https://github.com/
nixos/nixpkgs/archive/ece829033b7b8f4e81261fef5427144df4147bc4
.tar.gz"
;
url
=
"https://github.com/
NixOS/nixpkgs/archive/18.09
.tar.gz"
;
sha256
=
"
07n91k3d9i9pym8npsszha9mnvg4d1r0l0ldnhk4g8sx15vv1br5
"
;
sha256
=
"
1ib96has10v5nr6bzf7v8kw7yzww8zanxgw2qi1ll1sbv6kj6zpd
"
;
}
}
)
)
shell.nix
View file @
5ac27a46
{
pkgs
?
import
./pinned.nix
{}
}:
{
pkgs
?
import
./pinned
-19.09
.nix
{}
}:
pkgs
.
mkShell
{
pkgs
.
mkShell
{
buildInputs
=
with
pkgs
;
[
buildInputs
=
with
pkgs
;
[
...
...
src/Gargantext/API.hs
View file @
5ac27a46
...
@@ -51,16 +51,17 @@ import Control.Concurrent (threadDelay)
...
@@ -51,16 +51,17 @@ 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
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.Validity
import
Data.Validity
import
Data.Version
(
showVersion
)
import
GHC.Generics
(
D1
,
Meta
(
..
),
Rep
)
import
GHC.Generics
(
D1
,
Meta
(
..
),
Rep
)
import
GHC.TypeLits
(
AppendSymbol
,
Symbol
)
import
GHC.TypeLits
(
AppendSymbol
,
Symbol
)
import
Network.Wai
import
Network.Wai
import
Network.Wai.Handler.Warp
hiding
(
defaultSettings
)
import
Network.Wai.Handler.Warp
hiding
(
defaultSettings
)
import
qualified
Paths_gargantext
as
PG
-- cabal magic build module
import
Servant
import
Servant
import
Servant.Auth
as
SA
import
Servant.Auth
as
SA
import
Servant.Auth.Server
(
AuthResult
(
..
))
import
Servant.Auth.Server
(
AuthResult
(
..
))
...
@@ -84,7 +85,7 @@ import Gargantext.API.Types
...
@@ -84,7 +85,7 @@ import Gargantext.API.Types
import
Gargantext.Database.Node.Contact
(
HyperdataContact
)
import
Gargantext.Database.Node.Contact
(
HyperdataContact
)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
(
NodeId
,
CorpusId
,
AnnuaireId
)
import
Gargantext.Database.Types.Node
(
NodeId
,
CorpusId
,
AnnuaireId
)
import
Gargantext.Database.Utils
(
HasConnection
)
import
Gargantext.Database.Utils
(
HasConnection
Pool
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Viz.Graph.API
import
Gargantext.Viz.Graph.API
import
Network.HTTP.Types
hiding
(
Query
)
import
Network.HTTP.Types
hiding
(
Query
)
...
@@ -197,17 +198,25 @@ type GargAPI = "api" :> Summary "API " :> GargAPIVersion
...
@@ -197,17 +198,25 @@ type GargAPI = "api" :> Summary "API " :> GargAPIVersion
-- | TODO :<|> Summary "Latest API" :> GargAPI'
-- | TODO :<|> Summary "Latest API" :> GargAPI'
type
GargAPIVersion
=
"v1.0"
:>
Summary
"v1.0: "
:>
GargAPI'
type
GargAPIVersion
=
"v1.0"
:>
Summary
"Garg API Version "
:>
GargAPI'
type
GargVersion
=
"version"
:>
Summary
"Backend version"
:>
Get
'[
J
SON
]
Text
type
GargAPI'
=
type
GargAPI'
=
-- Auth endpoint
-- Auth endpoint
"auth"
:>
Summary
"AUTH API"
"auth"
:>
Summary
"AUTH API"
:>
ReqBody
'[
J
SON
]
AuthRequest
:>
ReqBody
'[
J
SON
]
AuthRequest
:>
Post
'[
J
SON
]
AuthResponse
:>
Post
'[
J
SON
]
AuthResponse
-- TODO-ACCESS here we want to request a particular header for
:<|>
GargVersion
-- TODO-ACCESS here we want to request a particular header for
-- auth and capabilities.
-- auth and capabilities.
:<|>
GargPrivateAPI
:<|>
GargPrivateAPI
type
GargPrivateAPI
=
SA
.
Auth
'[
S
A
.
JWT
,
SA
.
Cookie
]
AuthenticatedUser
:>
GargPrivateAPI'
type
GargPrivateAPI
=
SA
.
Auth
'[
S
A
.
JWT
,
SA
.
Cookie
]
AuthenticatedUser
:>
GargPrivateAPI'
type
GargAdminAPI
type
GargAdminAPI
...
@@ -225,7 +234,7 @@ waitAPI :: Int -> GargServer WaitAPI
...
@@ -225,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
)
----------------------------------------
----------------------------------------
...
@@ -293,7 +302,7 @@ type GargPrivateAPI' =
...
@@ -293,7 +302,7 @@ type GargPrivateAPI' =
:<|>
New
.
AddWithForm
:<|>
New
.
AddWithForm
:<|>
New
.
AddWithQuery
:<|>
New
.
AddWithQuery
:<|>
Annuaire
.
AddWithForm
:<|>
"annuaire"
:>
Annuaire
.
AddWithForm
-- :<|> New.AddWithFile
-- :<|> New.AddWithFile
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "new" :> New.Api
-- :<|> "new" :> New.Api
...
@@ -324,7 +333,7 @@ type API = SwaggerAPI
...
@@ -324,7 +333,7 @@ type API = SwaggerAPI
type
GargServerM
env
err
=
ReaderT
env
(
ExceptT
err
IO
)
type
GargServerM
env
err
=
ReaderT
env
(
ExceptT
err
IO
)
type
EnvC
env
=
type
EnvC
env
=
(
HasConnection
env
(
HasConnection
Pool
env
,
HasRepo
env
,
HasRepo
env
,
HasSettings
env
,
HasSettings
env
,
HasJobEnv
env
ScraperStatus
ScraperStatus
,
HasJobEnv
env
ScraperStatus
ScraperStatus
...
@@ -337,7 +346,11 @@ server :: forall env. EnvC env => env -> IO (Server API)
...
@@ -337,7 +346,11 @@ server :: forall env. EnvC env => env -> IO (Server API)
server
env
=
do
server
env
=
do
-- orchestrator <- scrapyOrchestrator env
-- orchestrator <- scrapyOrchestrator env
pure
$
schemaUiServer
swaggerDoc
pure
$
schemaUiServer
swaggerDoc
:<|>
hoistServerWithContext
(
Proxy
::
Proxy
GargAPI
)
(
Proxy
::
Proxy
AuthContext
)
transform
serverGargAPI
:<|>
hoistServerWithContext
(
Proxy
::
Proxy
GargAPI
)
(
Proxy
::
Proxy
AuthContext
)
transform
serverGargAPI
:<|>
frontEndServer
:<|>
frontEndServer
where
where
transform
::
forall
a
.
GargServerM
env
GargError
a
->
Handler
a
transform
::
forall
a
.
GargServerM
env
GargError
a
->
Handler
a
...
@@ -345,12 +358,18 @@ server env = do
...
@@ -345,12 +358,18 @@ server env = do
serverGargAPI
::
GargServerT
env
err
(
GargServerM
env
err
)
GargAPI
serverGargAPI
::
GargServerT
env
err
(
GargServerM
env
err
)
GargAPI
serverGargAPI
-- orchestrator
serverGargAPI
-- orchestrator
=
auth
:<|>
serverPrivateGargAPI
=
auth
:<|>
gargVersion
:<|>
serverPrivateGargAPI
-- :<|> orchestrator
-- :<|> orchestrator
where
gargVersion
::
GargServer
GargVersion
gargVersion
=
pure
(
cs
$
showVersion
PG
.
version
)
serverPrivateGargAPI
::
GargServerT
env
err
(
GargServerM
env
err
)
GargPrivateAPI
serverPrivateGargAPI
::
GargServerT
env
err
(
GargServerM
env
err
)
GargPrivateAPI
serverPrivateGargAPI
(
Authenticated
auser
)
=
serverPrivateGargAPI'
auser
serverPrivateGargAPI
(
Authenticated
auser
)
=
serverPrivateGargAPI'
auser
serverPrivateGargAPI
_
=
throwAll'
(
_ServerError
#
err401
)
serverPrivateGargAPI
_
=
throwAll'
(
_ServerError
#
err401
)
-- Here throwAll' requires a concrete type for the monad.
-- Here throwAll' requires a concrete type for the monad.
-- TODO-SECURITY admin only: withAdmin
-- TODO-SECURITY admin only: withAdmin
...
@@ -386,7 +405,7 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
...
@@ -386,7 +405,7 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
-- TODO access
-- TODO access
-- :<|> addUpload
-- :<|> addUpload
-- :<|> (\corpus -> addWithQuery corpus :<|> addWithFile corpus)
-- :<|> (\corpus -> addWithQuery corpus :<|> addWithFile corpus)
:<|>
addCorpusWithForm
:<|>
addCorpusWithForm
"user1"
:<|>
addCorpusWithQuery
:<|>
addCorpusWithQuery
:<|>
addAnnuaireWithForm
:<|>
addAnnuaireWithForm
...
@@ -398,35 +417,40 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
...
@@ -398,35 +417,40 @@ 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
::
GargServer
New
.
AddWithForm
addCorpusWithForm
::
Text
->
GargServer
New
.
AddWithForm
addCorpusWithForm
cid
=
addCorpusWithForm
username
cid
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
i
log
->
New
.
addToCorpusWithForm
cid
i
(
liftIO
.
log
))
JobFunction
(
\
i
log
->
let
log'
x
=
do
printDebug
"addCorpusWithForm"
x
liftBase
$
log
x
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 @
5ac27a46
...
@@ -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 @
5ac27a46
...
@@ -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
...
@@ -50,7 +49,7 @@ import Gargantext.API.Types (HasJoseError(..), joseError, HasServerError, GargSe
...
@@ -50,7 +49,7 @@ import Gargantext.API.Types (HasJoseError(..), joseError, HasServerError, GargSe
import
Gargantext.Database.Root
(
getRoot
)
import
Gargantext.Database.Root
(
getRoot
)
import
Gargantext.Database.Tree
(
isDescendantOf
,
isIn
)
import
Gargantext.Database.Tree
(
isDescendantOf
,
isIn
)
import
Gargantext.Database.Types.Node
(
NodePoly
(
_node_id
),
NodeId
(
..
),
UserId
,
ListId
,
DocId
)
import
Gargantext.Database.Types.Node
(
NodePoly
(
_node_id
),
NodeId
(
..
),
UserId
,
ListId
,
DocId
)
import
Gargantext.Database.Utils
(
Cmd
'
,
CmdM
,
HasConnection
)
import
Gargantext.Database.Utils
(
Cmd
'
,
CmdM
,
HasConnection
Pool
)
import
Gargantext.Prelude
hiding
(
reverse
)
import
Gargantext.Prelude
hiding
(
reverse
)
import
Test.QuickCheck
(
elements
,
oneof
)
import
Test.QuickCheck
(
elements
,
oneof
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
...
@@ -91,12 +90,12 @@ makeTokenForUser :: (HasSettings env, HasJoseError err)
...
@@ -91,12 +90,12 @@ 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...
checkAuthRequest
::
(
HasSettings
env
,
HasConnection
env
,
HasJoseError
err
)
checkAuthRequest
::
(
HasSettings
env
,
HasConnection
Pool
env
,
HasJoseError
err
)
=>
Username
->
Password
->
Cmd'
env
err
CheckAuth
=>
Username
->
Password
->
Cmd'
env
err
CheckAuth
checkAuthRequest
u
p
checkAuthRequest
u
p
|
not
(
u
`
elem
`
arbitraryUsername
)
=
pure
InvalidUser
|
not
(
u
`
elem
`
arbitraryUsername
)
=
pure
InvalidUser
...
@@ -109,7 +108,7 @@ checkAuthRequest u p
...
@@ -109,7 +108,7 @@ checkAuthRequest u p
token
<-
makeTokenForUser
uid
token
<-
makeTokenForUser
uid
pure
$
Valid
token
uid
pure
$
Valid
token
uid
auth
::
(
HasSettings
env
,
HasConnection
env
,
HasJoseError
err
)
auth
::
(
HasSettings
env
,
HasConnection
Pool
env
,
HasJoseError
err
)
=>
AuthRequest
->
Cmd'
env
err
AuthResponse
=>
AuthRequest
->
Cmd'
env
err
AuthResponse
auth
(
AuthRequest
u
p
)
=
do
auth
(
AuthRequest
u
p
)
=
do
checkAuthRequest'
<-
checkAuthRequest
u
p
checkAuthRequest'
<-
checkAuthRequest
u
p
...
...
src/Gargantext/API/Corpus/New.hs
View file @
5ac27a46
...
@@ -27,8 +27,6 @@ module Gargantext.API.Corpus.New
...
@@ -27,8 +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
Control.Concurrent
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Maybe
(
fromMaybe
)
...
@@ -67,7 +65,6 @@ data Query = Query { query_query :: Text
...
@@ -67,7 +65,6 @@ data Query = Query { query_query :: Text
deriveJSON
(
unPrefix
"query_"
)
'Q
u
ery
deriveJSON
(
unPrefix
"query_"
)
'Q
u
ery
instance
Arbitrary
Query
where
instance
Arbitrary
Query
where
arbitrary
=
elements
[
Query
q
n
fs
arbitrary
=
elements
[
Query
q
n
fs
|
q
<-
[
"a"
,
"b"
]
|
q
<-
[
"a"
,
"b"
]
...
@@ -97,7 +94,7 @@ api _uId (Query q _ as) = do
...
@@ -97,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'
...
@@ -157,7 +154,6 @@ type Upload = Summary "Corpus Upload endpoint"
...
@@ -157,7 +154,6 @@ type Upload = Summary "Corpus Upload endpoint"
:<|>
"addWithquery"
:>
AsyncJobsAPI
ScraperStatus
WithQuery
ScraperStatus
:<|>
"addWithquery"
:>
AsyncJobsAPI
ScraperStatus
WithQuery
ScraperStatus
:<|>
"addWithfile"
:>
AsyncJobs
ScraperStatus
'[
F
ormUrlEncoded
]
WithForm
ScraperStatus
:<|>
"addWithfile"
:>
AsyncJobs
ScraperStatus
'[
F
ormUrlEncoded
]
WithForm
ScraperStatus
type
AddWithQuery
=
Summary
"Add with Query to corpus endpoint"
type
AddWithQuery
=
Summary
"Add with Query to corpus endpoint"
:>
"corpus"
:>
"corpus"
:>
Capture
"corpus_id"
CorpusId
:>
Capture
"corpus_id"
CorpusId
...
@@ -205,7 +201,6 @@ addToCorpusJobFunction _cid (WithQuery _q _dbs _l) logStatus = do
...
@@ -205,7 +201,6 @@ addToCorpusJobFunction _cid (WithQuery _q _dbs _l) logStatus = do
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
addToCorpusWithFile
::
FlowCmdM
env
err
m
addToCorpusWithFile
::
FlowCmdM
env
err
m
=>
CorpusId
=>
CorpusId
->
MultipartData
Mem
->
MultipartData
Mem
...
@@ -218,6 +213,7 @@ addToCorpusWithFile cid input filetype logStatus = do
...
@@ -218,6 +213,7 @@ addToCorpusWithFile cid input filetype logStatus = do
,
_scst_remaining
=
Just
138
,
_scst_remaining
=
Just
138
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
printDebug
"addToCorpusWithFile"
cid
_h
<-
postUpload
cid
filetype
input
_h
<-
postUpload
cid
filetype
input
pure
ScraperStatus
{
_scst_succeeded
=
Just
137
pure
ScraperStatus
{
_scst_succeeded
=
Just
137
...
@@ -237,20 +233,19 @@ addToCorpusWithForm' :: FlowCmdM env err m
...
@@ -237,20 +233,19 @@ 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
=>
CorpusId
=>
Text
->
CorpusId
->
WithForm
->
WithForm
->
(
ScraperStatus
->
m
()
)
->
(
ScraperStatus
->
m
()
)
->
m
ScraperStatus
->
m
ScraperStatus
addToCorpusWithForm
cid
(
WithForm
ft
d
l
_n
)
logStatus
=
do
addToCorpusWithForm
username
cid
(
WithForm
ft
d
l
_n
)
logStatus
=
do
printDebug
"ft"
ft
let
let
parse
=
case
ft
of
parse
=
case
ft
of
...
@@ -259,29 +254,29 @@ addToCorpusWithForm cid (WithForm ft d l _n) logStatus = do
...
@@ -259,29 +254,29 @@ addToCorpusWithForm cid (WithForm ft d l _n) logStatus = do
WOS
->
Parser
.
parseFormat
Parser
.
WOS
WOS
->
Parser
.
parseFormat
Parser
.
WOS
PresseRIS
->
Parser
.
parseFormat
Parser
.
RisPresse
PresseRIS
->
Parser
.
parseFormat
Parser
.
RisPresse
newDocs
<-
liftIO
newEmptyMVar
docs
<-
liftIO
$
splitEvery
500
<$>
take
1000000
<$>
parse
(
cs
d
)
_
<-
liftIO
$
forkIO
$
putMVar
newDocs
docs
logStatus
ScraperStatus
{
_scst_succeeded
=
Just
1
logStatus
ScraperStatus
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
docs'
<-
liftIO
$
takeMVar
newDocs
printDebug
"Parsing corpus: "
cid
newCid
<-
liftIO
newEmptyMVar
cid'
<-
flowCorpus
"user1"
-- TODO granularity of the logStatus
docs
<-
liftBase
$
splitEvery
500
<$>
take
1000000
<$>
parse
(
cs
d
)
printDebug
"Parsing corpus finished : "
cid
printDebug
"Starting extraction : "
cid
-- TODO granularity of the logStatus
_cid'
<-
flowCorpus
username
(
Right
[
cid
])
(
Right
[
cid
])
(
Multi
$
fromMaybe
EN
l
)
(
Multi
$
fromMaybe
EN
l
)
(
map
(
map
toHyperdataDocument
)
docs'
)
(
map
(
map
toHyperdataDocument
)
docs
)
_
<-
liftIO
$
forkIO
$
putMVar
newCid
cid'
cid''
<-
liftIO
$
takeMVar
newCid
printDebug
"Extraction finished : "
cid
printDebug
"cid'"
cid''
pure
ScraperStatus
{
_scst_succeeded
=
Just
2
pure
ScraperStatus
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
...
...
src/Gargantext/API/Corpus/New/File.hs
View file @
5ac27a46
...
@@ -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 @
5ac27a46
...
@@ -119,9 +119,11 @@ import qualified Data.Set as Set
...
@@ -119,9 +119,11 @@ 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
import
Control.Monad.Trans.Control
(
MonadBaseControl
)
import
Data.Aeson
hiding
((
.=
))
import
Data.Aeson
hiding
((
.=
))
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Either
(
Either
(
Left
))
import
Data.Either
(
Either
(
Left
))
...
@@ -140,7 +142,7 @@ import Gargantext.Database.Config (userMaster)
...
@@ -140,7 +142,7 @@ import Gargantext.Database.Config (userMaster)
import
Gargantext.Database.Metrics.NgramsByNode
(
getOccByNgramsOnlyFast'
)
import
Gargantext.Database.Metrics.NgramsByNode
(
getOccByNgramsOnlyFast'
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
)
import
Gargantext.Database.Types.Node
(
NodeType
(
..
))
import
Gargantext.Database.Types.Node
(
NodeType
(
..
))
import
Gargantext.Database.Utils
(
fromField'
,
HasConnection
)
import
Gargantext.Database.Utils
(
fromField'
,
HasConnection
Pool
)
import
Gargantext.Database.Node.Select
import
Gargantext.Database.Node.Select
import
Gargantext.Database.Ngrams
import
Gargantext.Database.Ngrams
--import Gargantext.Database.Lists (listsWith)
--import Gargantext.Database.Lists (listsWith)
...
@@ -796,14 +798,14 @@ instance HasRepoSaver RepoEnv where
...
@@ -796,14 +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
,
Monad
IO
m
,
Monad
BaseControl
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
...
@@ -834,7 +836,7 @@ copyListNgrams :: RepoCmdM env err m
...
@@ -834,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
...
@@ -849,7 +851,7 @@ addListNgrams :: RepoCmdM env err m
...
@@ -849,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
...
@@ -871,7 +873,7 @@ setListNgrams :: RepoCmdM env err m
...
@@ -871,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
.
...
@@ -899,7 +901,7 @@ putListNgrams' :: RepoCmdM env err m
...
@@ -899,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
.
...
@@ -928,7 +930,7 @@ currentVersion :: RepoCmdM env err m
...
@@ -928,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
...
@@ -937,7 +939,7 @@ tableNgramsPull :: RepoCmdM env err m
...
@@ -937,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
)
...
@@ -966,7 +968,7 @@ tableNgramsPut tabType listId (Versioned p_version p_table)
...
@@ -966,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
...
@@ -1006,7 +1008,7 @@ getNgramsTableMap :: RepoCmdM env err m
...
@@ -1006,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
)
...
@@ -1018,12 +1020,12 @@ type MaxSize = Int
...
@@ -1018,12 +1020,12 @@ 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
.
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
Pool
env
)
=>
NodeType
->
NodeId
->
TabType
=>
NodeType
->
NodeId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
ListType
...
@@ -1085,7 +1087,7 @@ getTableNgrams _nType nId tabType listId limit_ offset
...
@@ -1085,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
{-
{-
...
@@ -1114,7 +1116,7 @@ getTableNgrams _nType nId tabType listId limit_ offset
...
@@ -1114,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
...
@@ -1184,7 +1186,7 @@ type TableNgramsApi = TableNgramsApiGet
...
@@ -1184,7 +1186,7 @@ type TableNgramsApi = TableNgramsApiGet
:<|>
TableNgramsApiPut
:<|>
TableNgramsApiPut
:<|>
TableNgramsApiPost
:<|>
TableNgramsApiPost
getTableNgramsCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
getTableNgramsCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
Pool
env
)
=>
NodeId
->
TabType
=>
NodeId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
ListType
...
@@ -1198,7 +1200,7 @@ getTableNgramsCorpus nId tabType listId limit_ offset listType minSize maxSize o
...
@@ -1198,7 +1200,7 @@ getTableNgramsCorpus nId tabType listId limit_ offset listType minSize maxSize o
searchQuery
=
maybe
(
const
True
)
isInfixOf
mt
searchQuery
=
maybe
(
const
True
)
isInfixOf
mt
-- | Text search is deactivated for now for ngrams by doc only
-- | Text search is deactivated for now for ngrams by doc only
getTableNgramsDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
getTableNgramsDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
Pool
env
)
=>
DocId
->
TabType
=>
DocId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
ListType
...
@@ -1218,7 +1220,7 @@ getTableNgramsDoc dId tabType listId limit_ offset listType minSize maxSize orde
...
@@ -1218,7 +1220,7 @@ getTableNgramsDoc dId tabType listId limit_ offset listType minSize maxSize orde
apiNgramsTableCorpus
::
(
RepoCmdM
env
err
m
apiNgramsTableCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasNodeError
err
,
HasInvalidError
err
,
HasInvalidError
err
,
HasConnection
env
,
HasConnection
Pool
env
)
)
=>
NodeId
->
ServerT
TableNgramsApi
m
=>
NodeId
->
ServerT
TableNgramsApi
m
apiNgramsTableCorpus
cId
=
getTableNgramsCorpus
cId
apiNgramsTableCorpus
cId
=
getTableNgramsCorpus
cId
...
@@ -1229,7 +1231,7 @@ apiNgramsTableCorpus cId = getTableNgramsCorpus cId
...
@@ -1229,7 +1231,7 @@ apiNgramsTableCorpus cId = getTableNgramsCorpus cId
apiNgramsTableDoc
::
(
RepoCmdM
env
err
m
apiNgramsTableDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasNodeError
err
,
HasInvalidError
err
,
HasInvalidError
err
,
HasConnection
env
,
HasConnection
Pool
env
)
)
=>
DocId
->
ServerT
TableNgramsApi
m
=>
DocId
->
ServerT
TableNgramsApi
m
apiNgramsTableDoc
dId
=
getTableNgramsDoc
dId
apiNgramsTableDoc
dId
=
getTableNgramsDoc
dId
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
5ac27a46
...
@@ -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
)
...
@@ -50,7 +49,7 @@ import Servant.Job.Utils (jsonOptions)
...
@@ -50,7 +49,7 @@ import Servant.Job.Utils (jsonOptions)
------------------------------------------------------------------------
------------------------------------------------------------------------
type
NgramsList
=
(
Map
NgramsType
(
Versioned
NgramsTableMap
))
type
NgramsList
=
(
Map
NgramsType
(
Versioned
NgramsTableMap
))
------------------------------------------------------------------------
------------------------------------------------------------------------
type
API
=
Get
'[
H
TML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
type
API
=
Get
'[
J
SON
,
HTML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
-- :<|> ReqBody '[JSON] NgramsList :> Post '[JSON] Bool
-- :<|> ReqBody '[JSON] NgramsList :> Post '[JSON] Bool
:<|>
PostAPI
:<|>
PostAPI
...
@@ -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 @
5ac27a46
...
@@ -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 #-}
...
@@ -36,7 +37,7 @@ type RootTerm = Text
...
@@ -36,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/API/Orchestrator/Types.hs
View file @
5ac27a46
...
@@ -85,7 +85,7 @@ data ScraperEvent = ScraperEvent
...
@@ -85,7 +85,7 @@ data ScraperEvent = ScraperEvent
,
_scev_level
::
!
(
Maybe
Text
)
,
_scev_level
::
!
(
Maybe
Text
)
,
_scev_date
::
!
(
Maybe
Text
)
,
_scev_date
::
!
(
Maybe
Text
)
}
}
deriving
Generic
deriving
(
Show
,
Generic
)
instance
Arbitrary
ScraperEvent
where
instance
Arbitrary
ScraperEvent
where
arbitrary
=
ScraperEvent
<$>
elements
[
Nothing
,
Just
"test message"
]
arbitrary
=
ScraperEvent
<$>
elements
[
Nothing
,
Just
"test message"
]
...
@@ -104,7 +104,7 @@ data ScraperStatus = ScraperStatus
...
@@ -104,7 +104,7 @@ data ScraperStatus = ScraperStatus
,
_scst_remaining
::
!
(
Maybe
Int
)
,
_scst_remaining
::
!
(
Maybe
Int
)
,
_scst_events
::
!
(
Maybe
[
ScraperEvent
])
,
_scst_events
::
!
(
Maybe
[
ScraperEvent
])
}
}
deriving
Generic
deriving
(
Show
,
Generic
)
instance
Arbitrary
ScraperStatus
where
instance
Arbitrary
ScraperStatus
where
arbitrary
=
ScraperStatus
arbitrary
=
ScraperStatus
...
...
src/Gargantext/API/Settings.hs
View file @
5ac27a46
...
@@ -35,13 +35,14 @@ import System.Environment (lookupEnv)
...
@@ -35,13 +35,14 @@ import System.Environment (lookupEnv)
import
System.IO
(
FilePath
,
hClose
)
import
System.IO
(
FilePath
,
hClose
)
import
System.IO.Temp
(
withTempFile
)
import
System.IO.Temp
(
withTempFile
)
import
System.FileLock
(
tryLockFile
,
unlockFile
,
SharedExclusive
(
Exclusive
))
import
System.FileLock
(
tryLockFile
,
unlockFile
,
SharedExclusive
(
Exclusive
))
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
,
close
,
ConnectInfo
)
import
Network.HTTP.Client
(
Manager
)
import
Network.HTTP.Client
(
Manager
)
import
Network.HTTP.Client.TLS
(
newTlsManager
)
import
Network.HTTP.Client.TLS
(
newTlsManager
)
import
Data.Aeson
import
Data.Aeson
import
Data.Maybe
(
fromMaybe
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Either
(
either
)
import
Data.Either
(
either
)
import
Data.Pool
(
Pool
,
createPool
)
import
Data.Text
import
Data.Text
--import Data.Text.Encoding (encodeUtf8)
--import Data.Text.Encoding (encodeUtf8)
import
Data.ByteString
(
ByteString
)
import
Data.ByteString
(
ByteString
)
...
@@ -61,7 +62,7 @@ import Control.Monad.Logger
...
@@ -61,7 +62,7 @@ import Control.Monad.Logger
import
Control.Monad.Reader
import
Control.Monad.Reader
import
Control.Lens
import
Control.Lens
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Database.Utils
(
databaseParameters
,
HasConnection
(
..
),
Cmd
'
,
runCmd
)
import
Gargantext.Database.Utils
(
databaseParameters
,
HasConnection
Pool
(
..
),
Cmd
'
,
runCmd
)
import
Gargantext.API.Ngrams
(
NgramsRepo
,
HasRepoVar
(
..
),
HasRepoSaver
(
..
),
HasRepo
(
..
),
RepoEnv
(
..
),
r_version
,
saveRepo
,
initRepo
,
renv_var
,
renv_lock
)
import
Gargantext.API.Ngrams
(
NgramsRepo
,
HasRepoVar
(
..
),
HasRepoSaver
(
..
),
HasRepo
(
..
),
RepoEnv
(
..
),
r_version
,
saveRepo
,
initRepo
,
renv_var
,
renv_lock
)
import
Gargantext.API.Orchestrator.Types
import
Gargantext.API.Orchestrator.Types
...
@@ -141,7 +142,7 @@ data FireWall = FireWall { unFireWall :: Bool }
...
@@ -141,7 +142,7 @@ data FireWall = FireWall { unFireWall :: Bool }
data
Env
=
Env
data
Env
=
Env
{
_env_settings
::
!
Settings
{
_env_settings
::
!
Settings
,
_env_logger
::
!
LoggerSet
,
_env_logger
::
!
LoggerSet
,
_env_
conn
::
!
Connection
,
_env_
pool
::
!
(
Pool
Connection
)
,
_env_repo
::
!
RepoEnv
,
_env_repo
::
!
RepoEnv
,
_env_manager
::
!
Manager
,
_env_manager
::
!
Manager
,
_env_self_url
::
!
BaseUrl
,
_env_self_url
::
!
BaseUrl
...
@@ -151,8 +152,8 @@ data Env = Env
...
@@ -151,8 +152,8 @@ data Env = Env
makeLenses
''
E
nv
makeLenses
''
E
nv
instance
HasConnection
Env
where
instance
HasConnection
Pool
Env
where
conn
ection
=
env_conn
conn
Pool
=
env_pool
instance
HasRepoVar
Env
where
instance
HasRepoVar
Env
where
repoVar
=
repoEnv
.
repoVar
repoVar
=
repoEnv
.
repoVar
...
@@ -254,7 +255,7 @@ newEnv port file = do
...
@@ -254,7 +255,7 @@ newEnv port file = do
self_url
<-
parseBaseUrl
$
"http://0.0.0.0:"
<>
show
port
self_url
<-
parseBaseUrl
$
"http://0.0.0.0:"
<>
show
port
param
<-
databaseParameters
file
param
<-
databaseParameters
file
conn
<-
connect
param
pool
<-
newPool
param
repo
<-
readRepoEnv
repo
<-
readRepoEnv
scrapers_env
<-
newJobEnv
defaultSettings
manager
scrapers_env
<-
newJobEnv
defaultSettings
manager
logger
<-
newStderrLoggerSet
defaultBufSize
logger
<-
newStderrLoggerSet
defaultBufSize
...
@@ -262,23 +263,26 @@ newEnv port file = do
...
@@ -262,23 +263,26 @@ newEnv port file = do
pure
$
Env
pure
$
Env
{
_env_settings
=
settings
{
_env_settings
=
settings
,
_env_logger
=
logger
,
_env_logger
=
logger
,
_env_
conn
=
conn
,
_env_
pool
=
pool
,
_env_repo
=
repo
,
_env_repo
=
repo
,
_env_manager
=
manager
,
_env_manager
=
manager
,
_env_scrapers
=
scrapers_env
,
_env_scrapers
=
scrapers_env
,
_env_self_url
=
self_url
,
_env_self_url
=
self_url
}
}
newPool
::
ConnectInfo
->
IO
(
Pool
Connection
)
newPool
param
=
createPool
(
connect
param
)
close
1
(
60
*
60
)
8
data
DevEnv
=
DevEnv
data
DevEnv
=
DevEnv
{
_dev_env_
conn
::
!
Connection
{
_dev_env_
pool
::
!
(
Pool
Connection
)
,
_dev_env_repo
::
!
RepoEnv
,
_dev_env_repo
::
!
RepoEnv
,
_dev_env_settings
::
!
Settings
,
_dev_env_settings
::
!
Settings
}
}
makeLenses
''
D
evEnv
makeLenses
''
D
evEnv
instance
HasConnection
DevEnv
where
instance
HasConnection
Pool
DevEnv
where
conn
ection
=
dev_env_conn
conn
Pool
=
dev_env_pool
instance
HasRepoVar
DevEnv
where
instance
HasRepoVar
DevEnv
where
repoVar
=
repoEnv
.
repoVar
repoVar
=
repoEnv
.
repoVar
...
@@ -306,11 +310,11 @@ withDevEnv iniPath k = do
...
@@ -306,11 +310,11 @@ withDevEnv iniPath k = do
where
where
newDevEnv
=
do
newDevEnv
=
do
param
<-
databaseParameters
iniPath
param
<-
databaseParameters
iniPath
conn
<-
connect
param
pool
<-
newPool
param
repo
<-
readRepoEnv
repo
<-
readRepoEnv
setts
<-
devSettings
devJwkFile
setts
<-
devSettings
devJwkFile
pure
$
DevEnv
pure
$
DevEnv
{
_dev_env_
conn
=
conn
{
_dev_env_
pool
=
pool
,
_dev_env_repo
=
repo
,
_dev_env_repo
=
repo
,
_dev_env_settings
=
setts
,
_dev_env_settings
=
setts
}
}
...
@@ -326,7 +330,7 @@ runCmdReplServantErr = runCmdRepl
...
@@ -326,7 +330,7 @@ runCmdReplServantErr = runCmdRepl
-- In particular this writes the repo file after running
-- In particular this writes the repo file after running
-- the command.
-- the command.
-- This function is constrained to the DevEnv rather than
-- This function is constrained to the DevEnv rather than
-- using HasConnection and HasRepoVar.
-- using HasConnection
Pool
and HasRepoVar.
runCmdDev
::
Show
err
=>
DevEnv
->
Cmd'
DevEnv
err
a
->
IO
a
runCmdDev
::
Show
err
=>
DevEnv
->
Cmd'
DevEnv
err
a
->
IO
a
runCmdDev
env
f
=
runCmdDev
env
f
=
(
either
(
fail
.
show
)
pure
=<<
runCmd
env
f
)
(
either
(
fail
.
show
)
pure
=<<
runCmd
env
f
)
...
...
src/Gargantext/Core/Flow/Types.hs
View file @
5ac27a46
...
@@ -10,6 +10,7 @@ Portability : POSIX
...
@@ -10,6 +10,7 @@ Portability : POSIX
-}
-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ConstrainedClassMethods #-}
{-# LANGUAGE ConstrainedClassMethods #-}
...
...
src/Gargantext/Core/Types.hs
View file @
5ac27a46
...
@@ -12,8 +12,8 @@ commentary with @some markup@.
...
@@ -12,8 +12,8 @@ commentary with @some markup@.
-}
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Core.Types
(
module
Gargantext
.
Core
.
Types
.
Main
module
Gargantext.Core.Types
(
module
Gargantext
.
Core
.
Types
.
Main
...
@@ -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 @
5ac27a46
...
@@ -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 @
5ac27a46
...
@@ -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/Flow/Pairing.hs
View file @
5ac27a46
...
@@ -9,6 +9,7 @@ Portability : POSIX
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Flow/Utils.hs
View file @
5ac27a46
...
@@ -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/Database/Init.hs
View file @
5ac27a46
...
@@ -11,6 +11,7 @@ Ngrams by node enable contextual metrics.
...
@@ -11,6 +11,7 @@ Ngrams by node enable contextual metrics.
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Metrics/NgramsByNode.hs
View file @
5ac27a46
...
@@ -11,6 +11,7 @@ Ngrams by node enable contextual metrics.
...
@@ -11,6 +11,7 @@ Ngrams by node enable contextual metrics.
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Node/Document/Add.hs
View file @
5ac27a46
...
@@ -13,6 +13,8 @@ Add Documents/Contact to a Corpus/Annuaire.
...
@@ -13,6 +13,8 @@ Add Documents/Contact to a Corpus/Annuaire.
------------------------------------------------------------------------
------------------------------------------------------------------------
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Node/Document/Insert.hs
View file @
5ac27a46
...
@@ -49,6 +49,7 @@ the concatenation of the parameters defined by @shaParameters@.
...
@@ -49,6 +49,7 @@ the concatenation of the parameters defined by @shaParameters@.
-}
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Node/Update.hs
View file @
5ac27a46
...
@@ -9,6 +9,7 @@ Portability : POSIX
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
...
...
src/Gargantext/Database/Node/UpdateOpaleye.hs
View file @
5ac27a46
...
@@ -9,6 +9,7 @@ Portability : POSIX
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
...
...
src/Gargantext/Database/Schema/Ngrams.hs
View file @
5ac27a46
...
@@ -13,6 +13,7 @@ Ngrams connection to the Database.
...
@@ -13,6 +13,7 @@ Ngrams connection to the Database.
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
...
...
src/Gargantext/Database/Schema/NodeNgrams.hs
View file @
5ac27a46
...
@@ -15,6 +15,7 @@ NodeNgrams register Context of Ngrams (named Cgrams then)
...
@@ -15,6 +15,7 @@ NodeNgrams register Context of Ngrams (named Cgrams then)
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
...
...
src/Gargantext/Database/Schema/NodeNode.hs
View file @
5ac27a46
...
@@ -14,6 +14,7 @@ commentary with @some markup@.
...
@@ -14,6 +14,7 @@ commentary with @some markup@.
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
...
...
src/Gargantext/Database/Schema/NodeNodeNgrams.hs
View file @
5ac27a46
...
@@ -12,6 +12,7 @@ Portability : POSIX
...
@@ -12,6 +12,7 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
...
...
src/Gargantext/Database/Schema/NodeNodeNgrams2.hs
View file @
5ac27a46
...
@@ -12,6 +12,7 @@ Portability : POSIX
...
@@ -12,6 +12,7 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
...
...
src/Gargantext/Database/Schema/Node_NodeNgramsNodeNgrams.hs
View file @
5ac27a46
...
@@ -22,6 +22,7 @@ Next Step benchmark:
...
@@ -22,6 +22,7 @@ Next Step benchmark:
-}
-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
...
...
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
View file @
5ac27a46
...
@@ -13,6 +13,7 @@ Portability : POSIX
...
@@ -13,6 +13,7 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
...
...
src/Gargantext/Database/Schema/User.hs
View file @
5ac27a46
...
@@ -14,6 +14,7 @@ Functions to deal with users, database side.
...
@@ -14,6 +14,7 @@ Functions to deal with users, database side.
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
...
...
src/Gargantext/Database/TextSearch.hs
View file @
5ac27a46
...
@@ -9,6 +9,7 @@ Portability : POSIX
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RankNTypes #-}
...
...
src/Gargantext/Database/Tree.hs
View file @
5ac27a46
...
@@ -12,6 +12,7 @@ Let a Root Node, return the Tree of the Node as a directed acyclic graph
...
@@ -12,6 +12,7 @@ Let a Root Node, return the Tree of the Node as a directed acyclic graph
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RankNTypes #-}
...
...
src/Gargantext/Database/Triggers/NodeNodeNgrams.hs
View file @
5ac27a46
...
@@ -11,6 +11,7 @@ Triggers on NodeNodeNgrams table.
...
@@ -11,6 +11,7 @@ Triggers on NodeNodeNgrams table.
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Triggers/Nodes.hs
View file @
5ac27a46
...
@@ -11,6 +11,7 @@ Triggers on Nodes table.
...
@@ -11,6 +11,7 @@ Triggers on Nodes table.
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Triggers/NodesNodes.hs
View file @
5ac27a46
...
@@ -11,6 +11,7 @@ Triggers on NodesNodes table.
...
@@ -11,6 +11,7 @@ Triggers on NodesNodes table.
-}
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Utils.hs
View file @
5ac27a46
...
@@ -13,6 +13,7 @@ commentary with @some markup@.
...
@@ -13,6 +13,7 @@ commentary with @some markup@.
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
...
@@ -22,10 +23,11 @@ module Gargantext.Database.Utils where
...
@@ -22,10 +23,11 @@ module Gargantext.Database.Utils where
import
Data.ByteString.Char8
(
hPutStrLn
)
import
Data.ByteString.Char8
(
hPutStrLn
)
import
System.IO
(
stderr
)
import
System.IO
(
stderr
)
import
Control.Exception
import
Control.Exception
import
Control.Monad.Error.Class
-- (MonadError(..), Error)
import
Control.Monad.Error.Class
-- (MonadError(..), Error)
import
Control.Lens
(
Getter
,
view
)
import
Control.Lens
(
Getter
,
view
)
import
Control.Monad.Reader
import
Control.Monad.Reader
import
Control.Monad.Trans.Control
(
MonadBaseControl
)
import
Control.Monad.Except
import
Control.Monad.Except
import
Data.Aeson
(
Result
(
Error
,
Success
),
fromJSON
,
FromJSON
)
import
Data.Aeson
(
Result
(
Error
,
Success
),
fromJSON
,
FromJSON
)
import
Data.Either.Extra
(
Either
(
Left
,
Right
))
import
Data.Either.Extra
(
Either
(
Left
,
Right
))
...
@@ -33,10 +35,12 @@ import Data.Ini (readIniFile, lookupValue)
...
@@ -33,10 +35,12 @@ import Data.Ini (readIniFile, lookupValue)
import
qualified
Data.List
as
DL
import
qualified
Data.List
as
DL
import
Data.Maybe
(
maybe
)
import
Data.Maybe
(
maybe
)
import
Data.Monoid
((
<>
))
import
Data.Monoid
((
<>
))
import
Data.Pool
(
Pool
,
withResource
)
import
Data.Profunctor.Product.Default
(
Default
)
import
Data.Profunctor.Product.Default
(
Default
)
import
Data.Text
(
unpack
,
pack
)
import
Data.Text
(
unpack
,
pack
)
import
Data.Typeable
(
Typeable
)
import
Data.Typeable
(
Typeable
)
import
Data.Word
(
Word16
)
import
Data.Word
(
Word16
)
--import Database.PostgreSQL.Simple (Connection, Pool, connect, withPoolConnection)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple.FromField
(
Conversion
,
ResultError
(
ConversionFailed
),
fromField
,
returnError
)
import
Database.PostgreSQL.Simple.FromField
(
Conversion
,
ResultError
(
ConversionFailed
),
fromField
,
returnError
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
...
@@ -48,21 +52,21 @@ import Text.Read (read)
...
@@ -48,21 +52,21 @@ import Text.Read (read)
import
qualified
Data.ByteString
as
DB
import
qualified
Data.ByteString
as
DB
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
class
HasConnection
env
where
class
HasConnection
Pool
env
where
conn
ection
::
Getter
env
Connection
conn
Pool
::
Getter
env
(
Pool
Connection
)
instance
HasConnection
Connection
where
instance
HasConnection
Pool
(
Pool
Connection
)
where
conn
ection
=
identity
conn
Pool
=
identity
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
,
HasConnection
env
,
HasConnection
Pool
env
)
)
type
Cmd'
env
err
a
=
forall
m
.
CmdM'
env
err
m
=>
m
a
type
Cmd'
env
err
a
=
forall
m
.
CmdM'
env
err
m
=>
m
a
...
@@ -75,10 +79,10 @@ fromInt64ToInt = fromIntegral
...
@@ -75,10 +79,10 @@ fromInt64ToInt = fromIntegral
-- TODO: ideally there should be very few calls to this functions.
-- TODO: ideally there should be very few calls to this functions.
mkCmd
::
(
Connection
->
IO
a
)
->
Cmd
err
a
mkCmd
::
(
Connection
->
IO
a
)
->
Cmd
err
a
mkCmd
k
=
do
mkCmd
k
=
do
conn
<-
view
connection
pool
<-
view
connPool
liftIO
$
k
conn
withResource
pool
(
liftBase
.
k
)
runCmd
::
(
HasConnection
env
)
runCmd
::
(
HasConnection
Pool
env
)
=>
env
->
Cmd'
env
err
a
=>
env
->
Cmd'
env
err
a
->
IO
(
Either
err
a
)
->
IO
(
Either
err
a
)
runCmd
env
m
=
runExceptT
$
runReaderT
m
env
runCmd
env
m
=
runExceptT
$
runReaderT
m
env
...
@@ -100,8 +104,8 @@ formatPGSQuery q a = mkCmd $ \conn -> PGS.formatQuery conn q a
...
@@ -100,8 +104,8 @@ formatPGSQuery q a = mkCmd $ \conn -> PGS.formatQuery conn q a
runPGSQuery'
::
(
PGS
.
ToRow
a
,
PGS
.
FromRow
b
)
=>
PGS
.
Query
->
a
->
Cmd
err
[
b
]
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
,
runPGSQuery
::
(
MonadError
err
m
,
MonadReader
env
m
,
MonadBaseControl
IO
m
,
PGS
.
FromRow
r
,
PGS
.
ToRow
q
,
MonadIO
m
,
HasConnection
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 @
5ac27a46
...
@@ -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,13 +29,14 @@ module Gargantext.Prelude
...
@@ -28,13 +29,14 @@ module Gargantext.Prelude
,
round
,
round
,
sortWith
,
sortWith
,
module
Prelude
,
module
Prelude
,
MonadBase
(
..
)
)
)
where
where
import
Control.Monad.Base
(
MonadBase
(
..
))
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
)
import
Control.Monad.IO.Class
(
MonadIO
)
import
Data.Maybe
(
isJust
,
fromJust
,
maybe
)
import
Data.Maybe
(
isJust
,
fromJust
,
maybe
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Protolude
(
Bool
(
True
,
False
),
Int
,
Int64
,
Double
,
Integer
import
Protolude
(
Bool
(
True
,
False
),
Int
,
Int64
,
Double
,
Integer
...
@@ -42,7 +44,6 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
...
@@ -42,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 +64,7 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
...
@@ -63,7 +64,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 +82,8 @@ import Text.Read (Read())
...
@@ -81,8 +82,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 ()
...
@@ -303,6 +304,3 @@ fib :: Int -> Int
...
@@ -303,6 +304,3 @@ fib :: Int -> Int
fib
0
=
0
fib
0
=
0
fib
1
=
1
fib
1
=
1
fib
n
=
fib
(
n
-
1
)
+
fib
(
n
-
2
)
fib
n
=
fib
(
n
-
1
)
+
fib
(
n
-
2
)
src/Gargantext/Prelude/Utils.hs
View file @
5ac27a46
...
@@ -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 @
5ac27a46
...
@@ -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 @
5ac27a46
...
@@ -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 @
5ac27a46
...
@@ -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 @
5ac27a46
...
@@ -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 @
5ac27a46
...
@@ -12,32 +12,37 @@ Portability : POSIX
...
@@ -12,32 +12,37 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
-- allows to write Text literals
{-# LANGUAGE OverloadedStrings #-}
-- allows to write Text literals
{-# LANGUAGE OverloadedLists #-}
-- allows to write Map and HashMap as lists
{-# LANGUAGE OverloadedLists #-}
-- allows to write Map and HashMap as lists
{-# LANGUAGE
DataKinds
#-}
{-# LANGUAGE
RankNTypes
#-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeOperators #-}
module
Gargantext.Viz.Graph.API
module
Gargantext.Viz.Graph.API
where
where
-- 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
Debug.Trace
(
trace
)
import
qualified
Data.HashMap.Lazy
as
HashMap
import
qualified
Data.HashMap.Lazy
as
HashMap
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Swagger
import
Data.Text
import
Data.Text
import
GHC.Generics
(
Generic
)
import
Servant
import
Servant
import
Servant.Job.Async
import
Servant.XML
import
Servant.XML
import
qualified
Xmlbf
as
Xmlbf
import
qualified
Xmlbf
as
Xmlbf
import
Gargantext.API.Ngrams
(
NgramsRepo
,
r_version
)
import
Gargantext.API.Ngrams
(
NgramsRepo
,
r_version
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Orchestrator.Types
import
Gargantext.API.Types
import
Gargantext.API.Types
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Main
import
Gargantext.Database.Config
import
Gargantext.Database.Config
...
@@ -66,11 +71,11 @@ instance Xmlbf.ToXml Graph where
...
@@ -66,11 +71,11 @@ instance Xmlbf.ToXml Graph where
where
where
params
=
HashMap
.
fromList
[
(
"xmlns"
,
"http://www.gexf.net/1.2draft"
)
params
=
HashMap
.
fromList
[
(
"xmlns"
,
"http://www.gexf.net/1.2draft"
)
,
(
"version"
,
"1.2"
)
]
,
(
"version"
,
"1.2"
)
]
meta
=
Xmlbf
.
element
"meta"
params
$
creator
<>
desc
ription
meta
=
Xmlbf
.
element
"meta"
params
$
creator
<>
desc
where
where
params
=
HashMap
.
fromList
[
(
"lastmodifieddate"
,
"2020-03-13"
)
]
params
=
HashMap
.
fromList
[
(
"lastmodifieddate"
,
"2020-03-13"
)
]
creator
=
Xmlbf
.
element
"creator"
HashMap
.
empty
$
Xmlbf
.
text
"Gargantext.org"
creator
=
Xmlbf
.
element
"creator"
HashMap
.
empty
$
Xmlbf
.
text
"Gargantext.org"
desc
ription
=
Xmlbf
.
element
"description"
HashMap
.
empty
$
Xmlbf
.
text
"Gargantext gexf file"
desc
=
Xmlbf
.
element
"description"
HashMap
.
empty
$
Xmlbf
.
text
"Gargantext gexf file"
graph
::
[
G
.
Node
]
->
[
G
.
Edge
]
->
[
Xmlbf
.
Node
]
graph
::
[
G
.
Node
]
->
[
G
.
Edge
]
->
[
Xmlbf
.
Node
]
graph
gn
ge
=
Xmlbf
.
element
"graph"
params
$
(
nodes
gn
)
<>
(
edges
ge
)
graph
gn
ge
=
Xmlbf
.
element
"graph"
params
$
(
nodes
gn
)
<>
(
edges
ge
)
where
where
...
@@ -101,14 +106,24 @@ instance Xmlbf.ToXml Graph where
...
@@ -101,14 +106,24 @@ instance Xmlbf.ToXml Graph where
type
GraphAPI
=
Get
'[
J
SON
]
Graph
type
GraphAPI
=
Get
'[
J
SON
]
Graph
:<|>
Post
'[
J
SON
]
[
GraphId
]
:<|>
Post
'[
J
SON
]
[
GraphId
]
:<|>
Put
'[
J
SON
]
Int
:<|>
Put
'[
J
SON
]
Int
:<|>
"gexf"
:>
Get
'[
X
ML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
Graph
)
:<|>
"gexf"
:>
Get
'[
X
ML
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
:<|>
GraphAsyncAPI
:<|>
"versions"
:>
GraphVersionsAPI
data
GraphVersions
=
GraphVersions
{
gv_graph
::
Maybe
Int
,
gv_repo
::
Int
}
deriving
(
Show
,
Generic
)
instance
ToJSON
GraphVersions
instance
ToSchema
GraphVersions
graphAPI
::
UserId
->
NodeId
->
GargServer
GraphAPI
graphAPI
::
UserId
->
NodeId
->
GargServer
GraphAPI
graphAPI
u
n
=
getGraph
u
n
graphAPI
u
n
=
getGraph
u
n
:<|>
postGraph
n
:<|>
postGraph
n
:<|>
putGraph
n
:<|>
putGraph
n
:<|>
getGraphGexf
u
n
:<|>
getGraphGexf
u
n
:<|>
graphAsync
u
n
:<|>
graphVersionsAPI
u
n
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -119,14 +134,56 @@ graphAPI u n = getGraph u n
...
@@ -119,14 +134,56 @@ 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
getGraph
uId
nId
=
do
getGraph
uId
nId
=
do
nodeGraph
<-
getNodeWith
nId
HyperdataGraph
let
graph
=
nodeGraph
^.
node_hyperdata
.
hyperdataGraph
-- let listVersion = graph ^? _Just
-- . graph_metadata
-- . _Just
-- . gm_list
-- . lfg_version
repo
<-
getRepo
-- let v = repo ^. r_version
nodeUser
<-
getNodeUser
(
NodeId
uId
)
let
uId'
=
nodeUser
^.
node_userId
let
cId
=
maybe
(
panic
"[ERR:G.V.G.API] Node has no parent"
)
identity
$
nodeGraph
^.
node_parentId
g
<-
case
graph
of
Nothing
->
do
graph'
<-
computeGraph
cId
NgramsTerms
repo
_
<-
insertGraph
cId
uId'
(
HyperdataGraph
$
Just
graph'
)
pure
$
trace
"Graph empty, computing"
$
graph'
Just
graph'
->
pure
$
trace
"Graph exists, returning"
$
graph'
-- Just graph' -> if listVersion == Just v
-- then pure graph'
-- else do
-- graph'' <- computeGraph cId NgramsTerms repo
-- _ <- updateHyperdata nId (HyperdataGraph $ Just graph'')
-- pure graph''
newGraph
<-
liftBase
newEmptyMVar
_
<-
liftBase
$
forkIO
$
putMVar
newGraph
g
g'
<-
liftBase
$
takeMVar
newGraph
pure
{- $ trace (show g) $ -}
g'
recomputeGraph
::
UserId
->
NodeId
->
GargNoServer
Graph
recomputeGraph
uId
nId
=
do
nodeGraph
<-
getNodeWith
nId
HyperdataGraph
nodeGraph
<-
getNodeWith
nId
HyperdataGraph
let
graph
=
nodeGraph
^.
node_hyperdata
.
hyperdataGraph
let
graph
=
nodeGraph
^.
node_hyperdata
.
hyperdataGraph
let
listVersion
=
graph
^?
_Just
let
listVersion
=
graph
^?
_Just
...
@@ -145,26 +202,39 @@ getGraph uId nId = do
...
@@ -145,26 +202,39 @@ getGraph uId nId = do
identity
identity
$
nodeGraph
^.
node_parentId
$
nodeGraph
^.
node_parentId
newGraph
<-
liftIO
newEmptyMVar
g
<-
case
graph
of
g
<-
case
graph
of
Nothing
->
do
Nothing
->
do
graph'
<-
computeGraph
cId
NgramsTerms
repo
graph'
<-
computeGraph
Async
cId
NgramsTerms
repo
_
<-
insertGraph
cId
uId'
(
HyperdataGraph
$
Just
graph'
)
_
<-
insertGraph
cId
uId'
(
HyperdataGraph
$
Just
graph'
)
pure
graph'
pure
$
trace
"[recomputeGraph] Graph empty, computing"
$
graph'
Just
graph'
->
if
listVersion
==
Just
v
Just
graph'
->
if
listVersion
==
Just
v
then
pure
graph'
then
pure
graph'
else
do
else
do
graph''
<-
computeGraph
cId
NgramsTerms
repo
graph''
<-
computeGraph
Async
cId
NgramsTerms
repo
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph''
)
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph''
)
pure
graph''
pure
$
trace
"[recomputeGraph] Graph exists, recomputing"
$
graph''
_
<-
liftIO
$
forkIO
$
putMVar
newGraph
g
g'
<-
liftIO
$
takeMVar
newGraph
pure
g
pure
{- $ trace (show g) $ -}
g'
computeGraphAsync
::
HasNodeError
err
=>
CorpusId
->
NgramsType
->
NgramsRepo
->
Cmd
err
Graph
computeGraphAsync
cId
nt
repo
=
do
g
<-
liftBase
newEmptyMVar
_
<-
forkIO
<$>
putMVar
g
<$>
computeGraph
cId
nt
repo
g'
<-
liftBase
$
takeMVar
g
pure
g'
-- TODO use Database Monad only here ?
-- TODO use Database Monad only here ?
computeGraph
::
HasNodeError
err
=>
CorpusId
->
NgramsType
->
NgramsRepo
->
Cmd
err
Graph
computeGraph
::
HasNodeError
err
=>
CorpusId
->
NgramsType
->
NgramsRepo
->
Cmd
err
Graph
computeGraph
cId
nt
repo
=
do
computeGraph
cId
nt
repo
=
do
lId
<-
defaultList
cId
lId
<-
defaultList
cId
...
@@ -179,11 +249,11 @@ computeGraph cId nt repo = do
...
@@ -179,11 +249,11 @@ computeGraph cId nt repo = do
let
ngs
=
filterListWithRoot
GraphTerm
$
mapTermListRoot
[
lId
]
nt
repo
let
ngs
=
filterListWithRoot
GraphTerm
$
mapTermListRoot
[
lId
]
nt
repo
myCooc
<-
Map
.
filter
(
>
1
)
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
(
Diagonal
Tru
e
)
<$>
getCoocByNgrams
(
Diagonal
Fals
e
)
<$>
groupNodesByNgrams
ngs
<$>
groupNodesByNgrams
ngs
<$>
getNodesByNgramsOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
Map
.
keys
ngs
)
<$>
getNodesByNgramsOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
Map
.
keys
ngs
)
graph
<-
lift
IO
$
cooc2graph
0
myCooc
graph
<-
lift
Base
$
cooc2graph
0
myCooc
let
graph'
=
set
graph_metadata
(
Just
metadata
)
graph
let
graph'
=
set
graph_metadata
(
Just
metadata
)
graph
pure
graph'
pure
graph'
...
@@ -196,7 +266,69 @@ putGraph :: NodeId -> GargServer (Put '[JSON] Int)
...
@@ -196,7 +266,69 @@ putGraph :: NodeId -> GargServer (Put '[JSON] Int)
putGraph
=
undefined
putGraph
=
undefined
getGraphGexf
::
UserId
->
NodeId
->
GargNoServer
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
Graph
)
------------------------------------------------------------
getGraphGexf
::
UserId
->
NodeId
->
GargNoServer
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
getGraphGexf
uId
nId
=
do
getGraphGexf
uId
nId
=
do
graph
<-
getGraph
uId
nId
graph
<-
getGraph
uId
nId
pure
$
addHeader
(
concat
[
"attachment; filename=graph.gexf"
])
graph
pure
$
addHeader
(
concat
[
"attachment; filename=graph.gexf"
])
graph
------------------------------------------------------------
type
GraphAsyncAPI
=
Summary
"Update graph"
:>
"async"
:>
AsyncJobsAPI
ScraperStatus
()
ScraperStatus
graphAsync
::
UserId
->
NodeId
->
GargServer
GraphAsyncAPI
graphAsync
u
n
=
serveJobsAPI
$
JobFunction
(
\
_
log'
->
graphAsync'
u
n
(
liftBase
.
log'
))
graphAsync'
::
UserId
->
NodeId
->
(
ScraperStatus
->
GargNoServer
()
)
->
GargNoServer
ScraperStatus
graphAsync'
u
n
logStatus
=
do
logStatus
ScraperStatus
{
_scst_succeeded
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
_g
<-
trace
(
show
u
)
$
recomputeGraph
u
n
pure
ScraperStatus
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
,
_scst_events
=
Just
[]
}
------------------------------------------------------------
type
GraphVersionsAPI
=
Summary
"Graph versions"
:>
Get
'[
J
SON
]
GraphVersions
:<|>
Summary
"Recompute graph version"
:>
Post
'[
J
SON
]
Graph
graphVersionsAPI
::
UserId
->
NodeId
->
GargServer
GraphVersionsAPI
graphVersionsAPI
u
n
=
graphVersions
u
n
:<|>
recomputeVersions
u
n
graphVersions
::
UserId
->
NodeId
->
GargNoServer
GraphVersions
graphVersions
_uId
nId
=
do
nodeGraph
<-
getNodeWith
nId
HyperdataGraph
let
graph
=
nodeGraph
^.
node_hyperdata
.
hyperdataGraph
let
listVersion
=
graph
^?
_Just
.
graph_metadata
.
_Just
.
gm_list
.
lfg_version
repo
<-
getRepo
let
v
=
repo
^.
r_version
pure
$
GraphVersions
{
gv_graph
=
listVersion
,
gv_repo
=
v
}
recomputeVersions
::
UserId
->
NodeId
->
GargNoServer
Graph
recomputeVersions
uId
nId
=
recomputeGraph
uId
nId
src/Gargantext/Viz/Graph/Bridgeness.hs
View file @
5ac27a46
...
@@ -25,7 +25,7 @@ import Data.Map (Map, fromListWith, lookup, fromList, delete, toList, mapKeys, m
...
@@ -25,7 +25,7 @@ import Data.Map (Map, fromListWith, lookup, fromList, delete, toList, mapKeys, m
import
qualified
Data.Map
as
DM
import
qualified
Data.Map
as
DM
import
Data.Maybe
(
fromJust
)
import
Data.Maybe
(
fromJust
)
import
Data.List
(
concat
,
sortOn
)
import
Data.List
(
concat
,
sortOn
)
import
Data.Graph.Clustering.Louvain.
CplusPlu
s
(
LouvainNode
(
..
))
import
Data.Graph.Clustering.Louvain.
Util
s
(
LouvainNode
(
..
))
-- TODO mv in Louvain Lib
-- TODO mv in Louvain Lib
...
...
src/Gargantext/Viz/Graph/IGraph.hs
View file @
5ac27a46
...
@@ -8,6 +8,9 @@ Portability : POSIX
...
@@ -8,6 +8,9 @@ Portability : POSIX
Main IGraph funs/types to ease portability with FGL.
Main IGraph funs/types to ease portability with FGL.
Reference:
* Gábor Csárdi, Tamás Nepusz: The igraph software package for complex network research. InterJournal Complex Systems, 1695, 2006.
-}
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
...
...
src/Gargantext/Viz/Graph/Tools.hs
View file @
5ac27a46
...
@@ -15,10 +15,8 @@ Portability : POSIX
...
@@ -15,10 +15,8 @@ Portability : POSIX
module
Gargantext.Viz.Graph.Tools
module
Gargantext.Viz.Graph.Tools
where
where
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Graph.Clustering.Louvain.Utils
(
LouvainNode
(
..
))
import
Control.Concurrent
(
newEmptyMVar
,
takeMVar
,
putMVar
,
forkIO
)
-- import Data.Graph.Clustering.Louvain (hLouvain, {-iLouvainMap-})
import
Debug.Trace
(
trace
)
import
Data.Graph.Clustering.Louvain.CplusPlus
(
LouvainNode
(
..
))
import
Data.Graph.Clustering.Louvain.CplusPlus
(
cLouvain
)
import
Data.Graph.Clustering.Louvain.CplusPlus
(
cLouvain
)
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
...
@@ -57,33 +55,33 @@ cooc2graph :: Threshold
...
@@ -57,33 +55,33 @@ cooc2graph :: Threshold
->
(
Map
(
Text
,
Text
)
Int
)
->
(
Map
(
Text
,
Text
)
Int
)
->
IO
Graph
->
IO
Graph
cooc2graph
threshold
myCooc
=
do
cooc2graph
threshold
myCooc
=
do
let
(
ti
,
_
)
=
createIndices
myCooc
let
myCooc'
=
toIndex
ti
myCooc
(
ti
,
_
)
=
createIndices
myCooc
matCooc
=
map2mat
0
(
Map
.
size
ti
)
$
Map
.
filter
(
>
1
)
myCooc'
myCooc'
=
toIndex
ti
myCooc
distanceMat
=
measureConditional
matCooc
matCooc
=
map2mat
0
(
Map
.
size
ti
)
$
Map
.
filter
(
>
1
)
myCooc'
distanceMap
=
Map
.
filter
(
>
threshold
)
$
mat2map
distanceMat
distanceMat
=
measureConditional
matCooc
distanceMap
=
Map
.
filter
(
>
threshold
)
$
mat2map
distanceMat
let
nodesApprox
::
Int
nodesApprox
::
Int
nodesApprox
=
n'
nodesApprox
=
n'
where
where
(
as
,
bs
)
=
List
.
unzip
$
Map
.
keys
distanceMap
(
as
,
bs
)
=
List
.
unzip
$
Map
.
keys
distanceMap
n'
=
Set
.
size
$
Set
.
fromList
$
as
<>
bs
n'
=
Set
.
size
$
Set
.
fromList
$
as
<>
bs
ClustersParams
rivers
level
=
{-trace ("nodesApprox: " <> show nodesApprox) $-}
clustersParams
nodesApprox
ClustersParams
rivers
level
=
clustersParams
nodesApprox
partitionsV
<-
liftIO
newEmptyMVar
partitions'
<-
case
Map
.
size
distanceMap
>
0
of
True
->
trace
(
"level"
<>
show
level
)
$
cLouvain
level
distanceMap
False
->
panic
"Text.Flow: DistanceMap is empty"
_
<-
liftIO
$
forkIO
$
putMVar
partitionsV
partitions'
partitions
<-
if
(
Map
.
size
distanceMap
>
0
)
partitions
<-
liftIO
$
takeMVar
partitionsV
--then iLouvainMap 100 10 distanceMap
-- then hLouvain distanceMap
then
cLouvain
level
distanceMap
else
panic
"Text.Flow: DistanceMap is empty"
let
bridgeness'
=
{-trace ("rivers: " <> show rivers) $-}
let
bridgeness
rivers
partitions
distanceMap
bridgeness'
=
bridgeness
rivers
partitions
distanceMap
confluence'
=
confluence
(
Map
.
keys
bridgeness'
)
3
True
False
let
confluence'
=
confluence
(
Map
.
keys
bridgeness'
)
3
True
False
pure
$
data2graph
(
Map
.
toList
ti
)
myCooc'
bridgeness'
confluence'
partitions
data2graph
(
Map
.
toList
ti
)
myCooc'
bridgeness'
confluence'
partitions
data
ClustersParams
=
ClustersParams
{
bridgness
::
Double
data
ClustersParams
=
ClustersParams
{
bridgness
::
Double
...
@@ -107,12 +105,13 @@ data2graph :: [(Text, Int)]
...
@@ -107,12 +105,13 @@ data2graph :: [(Text, Int)]
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
->
[
LouvainNode
]
->
[
LouvainNode
]
->
IO
Graph
->
Graph
data2graph
labels
coocs
bridge
conf
partitions
=
do
data2graph
labels
coocs
bridge
conf
partitions
=
Graph
nodes
edges
Nothing
where
let
community_id_by_node_id
=
Map
.
fromList
[
(
n
,
c
)
|
LouvainNode
n
c
<-
partitions
]
nodes
<-
mapM
(
setCoord
ForceAtlas
labels
bridge
)
community_id_by_node_id
=
Map
.
fromList
[
(
n
,
c
)
|
LouvainNode
n
c
<-
partitions
]
nodes
=
map
(
setCoord
ForceAtlas
labels
bridge
)
[
(
n
,
Node
{
node_size
=
maybe
0
identity
(
Map
.
lookup
(
n
,
n
)
coocs
)
[
(
n
,
Node
{
node_size
=
maybe
0
identity
(
Map
.
lookup
(
n
,
n
)
coocs
)
,
node_type
=
Terms
-- or Unknown
,
node_type
=
Terms
-- or Unknown
,
node_id
=
cs
(
show
n
)
,
node_id
=
cs
(
show
n
)
...
@@ -130,7 +129,7 @@ data2graph labels coocs bridge conf partitions = do
...
@@ -130,7 +129,7 @@ data2graph labels coocs bridge conf partitions = do
$
Map
.
toList
bridge
$
Map
.
toList
bridge
]
]
let
edges
=
[
Edge
{
edge_source
=
cs
(
show
s
)
edges
=
[
Edge
{
edge_source
=
cs
(
show
s
)
,
edge_target
=
cs
(
show
t
)
,
edge_target
=
cs
(
show
t
)
,
edge_weight
=
d
,
edge_weight
=
d
,
edge_confluence
=
maybe
0
identity
$
Map
.
lookup
(
s
,
t
)
conf
,
edge_confluence
=
maybe
0
identity
$
Map
.
lookup
(
s
,
t
)
conf
...
@@ -139,7 +138,6 @@ data2graph labels coocs bridge conf partitions = do
...
@@ -139,7 +138,6 @@ data2graph labels coocs bridge conf partitions = do
|
(
i
,
((
s
,
t
),
d
))
<-
zip
([
0
..
]
::
[
Integer
])
(
Map
.
toList
bridge
),
s
/=
t
,
d
>
0
|
(
i
,
((
s
,
t
),
d
))
<-
zip
([
0
..
]
::
[
Integer
])
(
Map
.
toList
bridge
),
s
/=
t
,
d
>
0
]
]
pure
$
Graph
nodes
edges
Nothing
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -153,22 +151,23 @@ setCoord' f (i,n) = n { node_x_coord = x, node_y_coord = y }
...
@@ -153,22 +151,23 @@ setCoord' f (i,n) = n { node_x_coord = x, node_y_coord = y }
-- | ACP
-- | ACP
setCoord
::
Ord
a
=>
Layout
->
[(
a
,
Int
)]
->
Map
(
Int
,
Int
)
Double
->
(
Int
,
Node
)
->
IO
Node
setCoord
::
Ord
a
=>
Layout
->
[(
a
,
Int
)]
->
Map
(
Int
,
Int
)
Double
->
(
Int
,
Node
)
->
Node
setCoord
l
labels
m
(
n
,
node
)
=
getCoord
l
labels
m
n
setCoord
l
labels
m
(
n
,
node
)
=
node
{
node_x_coord
=
x
>>=
\
(
x
,
y
)
->
pure
$
node
{
node_x_coord
=
x
,
node_y_coord
=
y
,
node_y_coord
=
y
}
}
where
(
x
,
y
)
=
getCoord
l
labels
m
n
getCoord
::
Ord
a
=>
Layout
getCoord
::
Ord
a
=>
Layout
->
[(
a
,
Int
)]
->
Map
(
Int
,
Int
)
Double
->
Int
->
IO
(
Double
,
Double
)
->
[(
a
,
Int
)]
->
Map
(
Int
,
Int
)
Double
->
Int
->
(
Double
,
Double
)
getCoord
KamadaKawai
_
m
n
=
layout
m
n
getCoord
KamadaKawai
_
_m
_n
=
undefined
--
layout m n
getCoord
ForceAtlas
_
_
n
=
pure
(
sin
d
,
cos
d
)
getCoord
ForceAtlas
_
_
n
=
(
sin
d
,
cos
d
)
where
where
d
=
fromIntegral
n
d
=
fromIntegral
n
getCoord
ACP
labels
m
n
=
pure
$
to2d
$
maybe
(
panic
"Graph.Tools no coordinate"
)
identity
getCoord
ACP
labels
m
n
=
to2d
$
maybe
(
panic
"Graph.Tools no coordinate"
)
identity
$
Map
.
lookup
n
$
Map
.
lookup
n
$
pcaReduceTo
(
Dimension
2
)
$
pcaReduceTo
(
Dimension
2
)
$
mapArray
labels
m
$
mapArray
labels
m
...
...
src/Gargantext/Viz/Phylo/API.hs
View file @
5ac27a46
...
@@ -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/Aggregates.hs
View file @
5ac27a46
...
@@ -27,7 +27,7 @@ import Gargantext.Viz.Phylo
...
@@ -27,7 +27,7 @@ import Gargantext.Viz.Phylo
import
Gargantext.Viz.Phylo.Tools
import
Gargantext.Viz.Phylo.Tools
import
Debug.Trace
(
trace
)
import
Debug.Trace
(
trace
)
import
Data.List
(
partition
,
concat
,
nub
,
elem
,
sort
,
(
++
),
null
,
union
)
import
Data.List
(
partition
,
concat
,
nub
,
elem
,
sort
,
(
++
),
null
,
union
)
import
Data.Map
(
Map
,
fromList
,
fromListWith
,
adjust
,
filterWithKey
,
elems
,
keys
,
unionWith
,
mapWithKey
)
import
Data.Map
(
Map
,
fromList
,
fromListWith
,
adjust
,
filterWithKey
,
elems
,
keys
,
unionWith
,
mapWithKey
)
import
Data.Set
(
size
)
import
Data.Set
(
size
)
...
...
src/Gargantext/Viz/Phylo/Cluster.hs
View file @
5ac27a46
...
@@ -19,6 +19,7 @@ module Gargantext.Viz.Phylo.Cluster
...
@@ -19,6 +19,7 @@ module Gargantext.Viz.Phylo.Cluster
where
where
import
Control.Parallel.Strategies
import
Control.Parallel.Strategies
import
Data.Graph.Clustering.Louvain.CplusPlus
import
Data.Graph.Clustering.Louvain.CplusPlus
import
Data.Graph.Clustering.Louvain.Utils
(
LouvainNode
(
..
))
import
Data.List
(
null
,
concat
,
sort
,
intersect
,(
++
),
elemIndex
,
groupBy
,
nub
,
union
,
(
\\
),
(
!!
))
import
Data.List
(
null
,
concat
,
sort
,
intersect
,(
++
),
elemIndex
,
groupBy
,
nub
,
union
,
(
\\
),
(
!!
))
import
Data.Map
(
Map
,
fromList
,
mapKeys
)
import
Data.Map
(
Map
,
fromList
,
mapKeys
)
import
Data.Tuple
(
fst
)
import
Data.Tuple
(
fst
)
...
...
src/Gargantext/Viz/Phylo/Main.hs
View file @
5ac27a46
...
@@ -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
...
...
src/Gargantext/Viz/Phylo/PhyloTools.hs
View file @
5ac27a46
...
@@ -492,4 +492,4 @@ traceTemporalMatching groups =
...
@@ -492,4 +492,4 @@ traceTemporalMatching groups =
traceGroupsProxi
::
Map
(
PhyloGroupId
,
PhyloGroupId
)
Double
->
Map
(
PhyloGroupId
,
PhyloGroupId
)
Double
traceGroupsProxi
::
Map
(
PhyloGroupId
,
PhyloGroupId
)
Double
->
Map
(
PhyloGroupId
,
PhyloGroupId
)
Double
traceGroupsProxi
m
=
traceGroupsProxi
m
=
trace
(
"
\n
"
<>
"-- | "
<>
show
(
Map
.
size
m
)
<>
" computed pairs of groups proximity"
<>
"
\n
"
)
m
trace
(
"
\n
"
<>
"-- | "
<>
show
(
Map
.
size
m
)
<>
" computed pairs of groups proximity"
<>
"
\n
"
)
m
\ No newline at end of file
src/Gargantext/Viz/Phylo/TemporalMatching.hs
View file @
5ac27a46
...
@@ -543,4 +543,4 @@ adaptativeTemporalMatching elevation phylo = updatePhyloGroups 1
...
@@ -543,4 +543,4 @@ adaptativeTemporalMatching elevation phylo = updatePhyloGroups 1
(
traceTemporalMatching
$
getGroupsFromLevel
1
phylo
)
(
traceTemporalMatching
$
getGroupsFromLevel
1
phylo
)
--------------------------------------
--------------------------------------
thr
::
Double
thr
::
Double
thr
=
toThreshold
elevation
(
phylo
^.
phylo_groupsProxi
)
thr
=
toThreshold
elevation
(
phylo
^.
phylo_groupsProxi
)
\ No newline at end of file
src/Gargantext/Viz/Phylo/View/ViewMaker.hs
View file @
5ac27a46
...
@@ -170,4 +170,4 @@ traceView pv = trace ("------------\n--| View |--\n------------\n\n"
...
@@ -170,4 +170,4 @@ traceView pv = trace ("------------\n--| View |--\n------------\n\n"
<>
show
(
percentile
75
(
VS
.
fromList
lst
))
<>
" (75%) "
<>
show
(
percentile
75
(
VS
.
fromList
lst
))
<>
" (75%) "
<>
show
(
percentile
90
(
VS
.
fromList
lst
))
<>
" (90%)
\n
"
)
pv
<>
show
(
percentile
90
(
VS
.
fromList
lst
))
<>
" (90%)
\n
"
)
pv
where
where
lst
=
sort
$
map
(
fromIntegral
.
length
.
snd
)
$
getNodesByBranches
pv
lst
=
sort
$
map
(
fromIntegral
.
length
.
snd
)
$
getNodesByBranches
pv
\ No newline at end of file
stack.yaml
View file @
5ac27a46
...
@@ -4,6 +4,7 @@ extra-package-dbs: []
...
@@ -4,6 +4,7 @@ extra-package-dbs: []
packages
:
packages
:
-
.
-
.
#- 'deps/servant-job'
#- 'deps/servant-job'
#- 'deps/clustering-louvain'
docker
:
docker
:
enable
:
false
enable
:
false
...
@@ -13,7 +14,6 @@ docker:
...
@@ -13,7 +14,6 @@ docker:
nix
:
nix
:
enable
:
false
enable
:
false
#packages: [gmp]
add-gc-roots
:
true
add-gc-roots
:
true
shell-file
:
build-shell.nix
shell-file
:
build-shell.nix
...
@@ -47,9 +47,9 @@ extra-deps:
...
@@ -47,9 +47,9 @@ 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
:
e5814cbfa71f43b0a453efb65f476240d7d51a53
commit
:
7d74f96dfea8e51fbab1793cc0429b2fe741f73d
-
git
:
https://github.com/np/patches-map
-
git
:
https://github.com/np/patches-map
commit
:
8c6f38c4844ead53e664cf9c82ba461715dbe445
commit
:
8c6f38c4844ead53e664cf9c82ba461715dbe445
-
git
:
https://github.com/delanoe/haskell-opaleye.git
#- opaleye-0.6.7002.0
-
git
:
https://github.com/delanoe/haskell-opaleye.git
#- opaleye-0.6.7002.0
...
...
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