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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
gargantext
haskell-gargantext
Commits
b5aec299
Commit
b5aec299
authored
Feb 21, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 111-dev-refactor-text-corpus-api-with-conduit
parents
92cb0a6c
9f99c992
Pipeline
#2510
failed with stage
in 8 minutes and 52 seconds
Changes
15
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
143 additions
and
56 deletions
+143
-56
CHANGELOG.md
CHANGELOG.md
+6
-0
Main.hs
bin/gargantext-phylo/Main.hs
+9
-9
init
bin/init
+4
-0
package.yaml
package.yaml
+1
-1
DocumentUpload.hs
src/Gargantext/API/Node/DocumentUpload.hs
+16
-4
Update.hs
src/Gargantext/API/Node/Update.hs
+40
-3
API.hs
src/Gargantext/Core/Viz/Graph/API.hs
+3
-2
GEXF.hs
src/Gargantext/Core/Viz/Graph/GEXF.hs
+3
-2
Phylo.hs
src/Gargantext/Core/Viz/Phylo.hs
+40
-13
API.hs
src/Gargantext/Core/Viz/Phylo/API.hs
+6
-5
Tools.hs
src/Gargantext/Core/Viz/Phylo/API/Tools.hs
+4
-8
Example.hs
src/Gargantext/Core/Viz/Phylo/Example.hs
+5
-3
PhyloMaker.hs
src/Gargantext/Core/Viz/Phylo/PhyloMaker.hs
+3
-3
PhyloTools.hs
src/Gargantext/Core/Viz/Phylo/PhyloTools.hs
+2
-2
Share.hs
src/Gargantext/Database/Action/Share.hs
+1
-1
No files found.
CHANGELOG.md
View file @
b5aec299
## Version 0.0.5.6.3
*
[
BACK
][
EXPORT
][
GEXF
]
node size
## Version 0.0.5.6.2
*
[
FRONT
][
FIX
]
Ngrams Batch change
## Version 0.0.5.6.1
## Version 0.0.5.6.1
*
[
BACK
][
FEAT
]
Confluence Method connection
*
[
BACK
][
FEAT
]
Confluence Method connection
...
...
bin/gargantext-phylo/Main.hs
View file @
b5aec299
...
@@ -136,7 +136,7 @@ fileToDocs' parser path time lst = do
...
@@ -136,7 +136,7 @@ fileToDocs' parser path time lst = do
-- Config time parameters to label
-- Config time parameters to label
timeToLabel
::
Config
->
[
Char
]
timeToLabel
::
Phylo
Config
->
[
Char
]
timeToLabel
config
=
case
(
timeUnit
config
)
of
timeToLabel
config
=
case
(
timeUnit
config
)
of
Epoch
p
s
f
->
(
"time_epochs"
<>
"_"
<>
(
show
p
)
<>
"_"
<>
(
show
s
)
<>
"_"
<>
(
show
f
))
Epoch
p
s
f
->
(
"time_epochs"
<>
"_"
<>
(
show
p
)
<>
"_"
<>
(
show
s
)
<>
"_"
<>
(
show
f
))
Year
p
s
f
->
(
"time_years"
<>
"_"
<>
(
show
p
)
<>
"_"
<>
(
show
s
)
<>
"_"
<>
(
show
f
))
Year
p
s
f
->
(
"time_years"
<>
"_"
<>
(
show
p
)
<>
"_"
<>
(
show
s
)
<>
"_"
<>
(
show
f
))
...
@@ -145,37 +145,37 @@ timeToLabel config = case (timeUnit config) of
...
@@ -145,37 +145,37 @@ timeToLabel config = case (timeUnit config) of
Day
p
s
f
->
(
"time_days"
<>
"_"
<>
(
show
p
)
<>
"_"
<>
(
show
s
)
<>
"_"
<>
(
show
f
))
Day
p
s
f
->
(
"time_days"
<>
"_"
<>
(
show
p
)
<>
"_"
<>
(
show
s
)
<>
"_"
<>
(
show
f
))
seaToLabel
::
Config
->
[
Char
]
seaToLabel
::
Phylo
Config
->
[
Char
]
seaToLabel
config
=
case
(
seaElevation
config
)
of
seaToLabel
config
=
case
(
seaElevation
config
)
of
Constante
start
step
->
(
"sea_cst_"
<>
(
show
start
)
<>
"_"
<>
(
show
step
))
Constante
start
step
->
(
"sea_cst_"
<>
(
show
start
)
<>
"_"
<>
(
show
step
))
Adaptative
granularity
->
(
"sea_adapt"
<>
(
show
granularity
))
Adaptative
granularity
->
(
"sea_adapt"
<>
(
show
granularity
))
sensToLabel
::
Config
->
[
Char
]
sensToLabel
::
Phylo
Config
->
[
Char
]
sensToLabel
config
=
case
(
phyloProximity
config
)
of
sensToLabel
config
=
case
(
phyloProximity
config
)
of
Hamming
_
->
undefined
Hamming
_
->
undefined
WeightedLogJaccard
s
->
(
"WeightedLogJaccard_"
<>
show
s
)
WeightedLogJaccard
s
->
(
"WeightedLogJaccard_"
<>
show
s
)
WeightedLogSim
s
->
(
"WeightedLogSim-sens_"
<>
show
s
)
WeightedLogSim
s
->
(
"WeightedLogSim-sens_"
<>
show
s
)
cliqueToLabel
::
Config
->
[
Char
]
cliqueToLabel
::
Phylo
Config
->
[
Char
]
cliqueToLabel
config
=
case
(
clique
config
)
of
cliqueToLabel
config
=
case
(
clique
config
)
of
Fis
s
s'
->
"fis_"
<>
(
show
s
)
<>
"_"
<>
(
show
s'
)
Fis
s
s'
->
"fis_"
<>
(
show
s
)
<>
"_"
<>
(
show
s'
)
MaxClique
s
t
f
->
"clique_"
<>
(
show
s
)
<>
"_"
<>
(
show
f
)
<>
"_"
<>
(
show
t
)
MaxClique
s
t
f
->
"clique_"
<>
(
show
s
)
<>
"_"
<>
(
show
f
)
<>
"_"
<>
(
show
t
)
syncToLabel
::
Config
->
[
Char
]
syncToLabel
::
Phylo
Config
->
[
Char
]
syncToLabel
config
=
case
(
phyloSynchrony
config
)
of
syncToLabel
config
=
case
(
phyloSynchrony
config
)
of
ByProximityThreshold
scl
sync_sens
scope
_
->
(
"scale_"
<>
(
show
scope
)
<>
"_"
<>
(
show
sync_sens
)
<>
"_"
<>
(
show
scl
))
ByProximityThreshold
scl
sync_sens
scope
_
->
(
"scale_"
<>
(
show
scope
)
<>
"_"
<>
(
show
sync_sens
)
<>
"_"
<>
(
show
scl
))
ByProximityDistribution
_
_
->
undefined
ByProximityDistribution
_
_
->
undefined
qualToConfig
::
Config
->
[
Char
]
qualToConfig
::
Phylo
Config
->
[
Char
]
qualToConfig
config
=
case
(
phyloQuality
config
)
of
qualToConfig
config
=
case
(
phyloQuality
config
)
of
Quality
g
m
->
"quality_"
<>
(
show
g
)
<>
"_"
<>
(
show
m
)
Quality
g
m
->
"quality_"
<>
(
show
g
)
<>
"_"
<>
(
show
m
)
-- To set up the export file's label from the configuration
-- To set up the export file's label from the configuration
configToLabel
::
Config
->
[
Char
]
configToLabel
::
Phylo
Config
->
[
Char
]
configToLabel
config
=
outputPath
config
configToLabel
config
=
outputPath
config
<>
(
unpack
$
phyloName
config
)
<>
(
unpack
$
phyloName
config
)
<>
"-"
<>
(
timeToLabel
config
)
<>
"-"
<>
(
timeToLabel
config
)
...
@@ -189,7 +189,7 @@ configToLabel config = outputPath config
...
@@ -189,7 +189,7 @@ configToLabel config = outputPath config
-- To write a sha256 from a set of config's parameters
-- To write a sha256 from a set of config's parameters
configToSha
::
PhyloStage
->
Config
->
[
Char
]
configToSha
::
PhyloStage
->
Phylo
Config
->
[
Char
]
configToSha
stage
config
=
unpack
configToSha
stage
config
=
unpack
$
replace
"/"
"-"
$
replace
"/"
"-"
$
T
.
pack
(
show
(
hash
$
C8
.
pack
label
))
$
T
.
pack
(
show
(
hash
$
C8
.
pack
label
))
...
@@ -242,7 +242,7 @@ main = do
...
@@ -242,7 +242,7 @@ main = do
printIOMsg
"Read the configuration file"
printIOMsg
"Read the configuration file"
[
args
]
<-
getArgs
[
args
]
<-
getArgs
jsonArgs
<-
(
eitherDecode
<$>
readJson
args
)
::
IO
(
Either
String
Config
)
jsonArgs
<-
(
eitherDecode
<$>
readJson
args
)
::
IO
(
Either
String
Phylo
Config
)
case
jsonArgs
of
case
jsonArgs
of
Left
err
->
putStrLn
err
Left
err
->
putStrLn
err
...
...
bin/init
0 → 100755
View file @
b5aec299
#!/bin/bash
ln
-s
$(
nix-shell
--run
"which dot"
)
~/.local/bin/dot
package.yaml
View file @
b5aec299
name
:
gargantext
name
:
gargantext
version
:
'
0.0.5.6.
1
'
version
:
'
0.0.5.6.
3
'
synopsis
:
Search, map, share
synopsis
:
Search, map, share
description
:
Please see README.md
description
:
Please see README.md
category
:
Data
category
:
Data
...
...
src/Gargantext/API/Node/DocumentUpload.hs
View file @
b5aec299
...
@@ -69,21 +69,32 @@ api :: UserId -> NodeId -> GargServer API
...
@@ -69,21 +69,32 @@ api :: UserId -> NodeId -> GargServer API
api
uId
nId
=
api
uId
nId
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
q
log'
->
do
JobFunction
(
\
q
log'
->
do
documentUpload
uId
nId
q
(
liftBase
.
log'
)
documentUpload
Async
uId
nId
q
(
liftBase
.
log'
)
)
)
documentUpload
::
(
FlowCmdM
env
err
m
)
documentUpload
Async
::
(
FlowCmdM
env
err
m
)
=>
UserId
=>
UserId
->
NodeId
->
NodeId
->
DocumentUpload
->
DocumentUpload
->
(
JobLog
->
m
()
)
->
(
JobLog
->
m
()
)
->
m
JobLog
->
m
JobLog
documentUpload
_uId
nId
doc
logStatus
=
do
documentUpload
Async
_uId
nId
doc
logStatus
=
do
let
jl
=
JobLog
{
_scst_succeeded
=
Just
0
let
jl
=
JobLog
{
_scst_succeeded
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
,
_scst_events
=
Just
[]
}
logStatus
jl
logStatus
jl
docIds
<-
documentUpload
nId
doc
printDebug
"documentUploadAsync"
docIds
pure
$
jobLogSuccess
jl
documentUpload
::
(
FlowCmdM
env
err
m
)
=>
NodeId
->
DocumentUpload
->
m
[
DocId
]
documentUpload
nId
doc
=
do
mcId
<-
getClosestParentIdByType'
nId
NodeCorpus
mcId
<-
getClosestParentIdByType'
nId
NodeCorpus
let
cId
=
case
mcId
of
let
cId
=
case
mcId
of
Just
c
->
c
Just
c
->
c
...
@@ -116,5 +127,6 @@ documentUpload _uId nId doc logStatus = do
...
@@ -116,5 +127,6 @@ documentUpload _uId nId doc logStatus = do
docIds
<-
insertMasterDocs
(
Nothing
::
Maybe
HyperdataCorpus
)
(
Multi
EN
)
[
hd
]
docIds
<-
insertMasterDocs
(
Nothing
::
Maybe
HyperdataCorpus
)
(
Multi
EN
)
[
hd
]
_
<-
Doc
.
add
cId
docIds
_
<-
Doc
.
add
cId
docIds
pure
docIds
pure
$
jobLogSuccess
jl
src/Gargantext/API/Node/Update.hs
View file @
b5aec299
...
@@ -29,12 +29,14 @@ import Gargantext.Core.Methods.Distances (GraphMetric(..))
...
@@ -29,12 +29,14 @@ import Gargantext.Core.Methods.Distances (GraphMetric(..))
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
import
Gargantext.Core.Viz.Graph.API
(
recomputeGraph
)
import
Gargantext.Core.Viz.Graph.API
(
recomputeGraph
)
import
Gargantext.Core.Viz.Graph.Tools
(
PartitionMethod
(
..
))
import
Gargantext.Core.Viz.Graph.Tools
(
PartitionMethod
(
..
))
import
Gargantext.Core.Viz.Phylo
(
PhyloSubConfig
(
..
),
subConfig2config
)
import
Gargantext.Core.Viz.Phylo.API.Tools
(
flowPhyloAPI
)
import
Gargantext.Database.Action.Flow.Pairing
(
pairing
)
import
Gargantext.Database.Action.Flow.Pairing
(
pairing
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Action.Metrics
(
updateNgramsOccurrences
,
updateContextScore
)
import
Gargantext.Database.Action.Metrics
(
updateNgramsOccurrences
,
updateContextScore
)
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Query.Table.Node
(
defaultList
)
import
Gargantext.Database.Query.Table.Node
(
defaultList
,
getNode
,
insertNodes
,
node
)
import
Gargantext.Database.Query.Table.Node
(
getNode
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
NgramsTerms
))
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
NgramsTerms
))
import
Gargantext.Database.Schema.Node
(
node_parent_id
)
import
Gargantext.Database.Schema.Node
(
node_parent_id
)
import
Gargantext.Prelude
(
Bool
(
..
),
Ord
,
Eq
,
(
<$>
),
(
$
),
liftBase
,
(
.
),
printDebug
,
pure
,
show
,
cs
,
(
<>
),
panic
,
(
<*>
))
import
Gargantext.Prelude
(
Bool
(
..
),
Ord
,
Eq
,
(
<$>
),
(
$
),
liftBase
,
(
.
),
printDebug
,
pure
,
show
,
cs
,
(
<>
),
panic
,
(
<*>
))
...
@@ -54,12 +56,19 @@ type API = Summary " Update node according to NodeType params"
...
@@ -54,12 +56,19 @@ type API = Summary " Update node according to NodeType params"
------------------------------------------------------------------------
------------------------------------------------------------------------
data
UpdateNodeParams
=
UpdateNodeParamsList
{
methodList
::
!
Method
}
data
UpdateNodeParams
=
UpdateNodeParamsList
{
methodList
::
!
Method
}
|
UpdateNodeParamsGraph
{
methodGraphMetric
::
!
GraphMetric
|
UpdateNodeParamsGraph
{
methodGraphMetric
::
!
GraphMetric
,
methodGraphClustering
::
!
PartitionMethod
,
methodGraphClustering
::
!
PartitionMethod
}
}
|
UpdateNodeParamsTexts
{
methodTexts
::
!
Granularity
}
|
UpdateNodeParamsTexts
{
methodTexts
::
!
Granularity
}
|
UpdateNodeParamsBoard
{
methodBoard
::
!
Charts
}
|
UpdateNodeParamsBoard
{
methodBoard
::
!
Charts
}
|
LinkNodeReq
{
nodeType
::
!
NodeType
,
id
::
!
NodeId
}
|
LinkNodeReq
{
nodeType
::
!
NodeType
,
id
::
!
NodeId
}
|
UpdateNodePhylo
{
config
::
!
PhyloSubConfig
}
deriving
(
Generic
)
deriving
(
Generic
)
----------------------------------------------------------------------
----------------------------------------------------------------------
...
@@ -182,6 +191,34 @@ updateNode _uId lId (UpdateNodeParamsList _mode) logStatus = do
...
@@ -182,6 +191,34 @@ updateNode _uId lId (UpdateNodeParamsList _mode) logStatus = do
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
updateNode
userId
phyloId
(
UpdateNodePhylo
config
)
logStatus
=
do
logStatus
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
2
,
_scst_events
=
Just
[]
}
corpusId'
<-
view
node_parent_id
<$>
getNode
phyloId
let
corpusId
=
fromMaybe
(
panic
""
)
corpusId'
phy
<-
flowPhyloAPI
(
subConfig2config
config
)
corpusId
logStatus
JobLog
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
_phyloId
<-
insertNodes
[
node
NodePhylo
"Phylo"
(
HyperdataPhylo
Nothing
(
Just
phy
))
(
Just
corpusId
)
userId
]
pure
JobLog
{
_scst_succeeded
=
Just
3
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
,
_scst_events
=
Just
[]
}
updateNode
_uId
tId
(
UpdateNodeParamsTexts
_mode
)
logStatus
=
do
updateNode
_uId
tId
(
UpdateNodeParamsTexts
_mode
)
logStatus
=
do
logStatus
JobLog
{
_scst_succeeded
=
Just
1
logStatus
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
...
...
src/Gargantext/Core/Viz/Graph/API.hs
View file @
b5aec299
...
@@ -102,7 +102,8 @@ getGraph _uId nId = do
...
@@ -102,7 +102,8 @@ getGraph _uId nId = do
case
graph
of
case
graph
of
Nothing
->
do
Nothing
->
do
let
defaultMetric
=
Order1
let
defaultMetric
=
Order1
graph'
<-
computeGraph
cId
Spinglass
(
withMetric
defaultMetric
)
NgramsTerms
repo
let
defaultPartitionMethod
=
Spinglass
graph'
<-
computeGraph
cId
defaultPartitionMethod
(
withMetric
defaultMetric
)
NgramsTerms
repo
mt
<-
defaultGraphMetadata
cId
"Title"
repo
defaultMetric
mt
<-
defaultGraphMetadata
cId
"Title"
repo
defaultMetric
let
let
graph''
=
set
graph_metadata
(
Just
mt
)
graph'
graph''
=
set
graph_metadata
(
Just
mt
)
graph'
...
...
src/Gargantext/Core/Viz/Graph/GEXF.hs
View file @
b5aec299
...
@@ -52,11 +52,12 @@ instance Xmlbf.ToXml Graph where
...
@@ -52,11 +52,12 @@ instance Xmlbf.ToXml Graph where
nodes
gn
=
Xmlbf
.
element
"nodes"
HashMap
.
empty
$
P
.
concatMap
node'
gn
nodes
gn
=
Xmlbf
.
element
"nodes"
HashMap
.
empty
$
P
.
concatMap
node'
gn
node'
::
G
.
Node
->
[
Xmlbf
.
Node
]
node'
::
G
.
Node
->
[
Xmlbf
.
Node
]
node'
(
G
.
Node
{
node_id
=
nId
,
node_label
=
l
})
=
node'
(
G
.
Node
{
node_id
=
nId
,
node_label
=
l
,
node_size
=
w
})
=
Xmlbf
.
element
"node"
params
[]
Xmlbf
.
element
"node"
params
[]
where
where
params
=
HashMap
.
fromList
[
(
"id"
,
nId
)
params
=
HashMap
.
fromList
[
(
"id"
,
nId
)
,
(
"label"
,
l
)
]
,
(
"label"
,
l
)
,
(
"size"
,
(
cs
.
show
)
w
)]
edges
::
[
G
.
Edge
]
->
[
Xmlbf
.
Node
]
edges
::
[
G
.
Edge
]
->
[
Xmlbf
.
Node
]
edges
gn
=
Xmlbf
.
element
"edges"
HashMap
.
empty
$
P
.
concatMap
edge
gn
edges
gn
=
Xmlbf
.
element
"edges"
HashMap
.
empty
$
P
.
concatMap
edge
gn
edge
::
G
.
Edge
->
[
Xmlbf
.
Node
]
edge
::
G
.
Edge
->
[
Xmlbf
.
Node
]
...
...
src/Gargantext/Core/Viz/Phylo.hs
View file @
b5aec299
...
@@ -26,24 +26,24 @@ one 8, e54847.
...
@@ -26,24 +26,24 @@ one 8, e54847.
module
Gargantext.Core.Viz.Phylo
where
module
Gargantext.Core.Viz.Phylo
where
import
Data.Swagger
import
Gargantext.Core.Utils.Prefix
(
unPrefixSwagger
)
import
Control.DeepSeq
(
NFData
)
import
Control.DeepSeq
(
NFData
)
import
Control.Lens
(
makeLenses
)
import
Control.Lens
(
makeLenses
)
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
Data.Swagger
import
Data.Text
(
Text
,
pack
)
import
Data.Text
(
Text
,
pack
)
import
Data.Vector
(
Vector
)
import
Data.Vector
(
Vector
)
import
GHC.Generics
import
GHC.Generics
import
GHC.IO
(
FilePath
)
import
GHC.IO
(
FilePath
)
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Core.Utils.Prefix
(
unPrefixSwagger
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Data.Text.Lazy
as
TextLazy
import
qualified
Data.Text.Lazy
as
TextLazy
----------------
----------------
-- | Config | --
-- |
Phylo
Config | --
----------------
----------------
data
CorpusParser
=
data
CorpusParser
=
...
@@ -180,9 +180,8 @@ instance ToSchema Quality where
...
@@ -180,9 +180,8 @@ instance ToSchema Quality where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_qua_"
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_qua_"
)
data
PhyloConfig
=
data
Config
=
PhyloConfig
{
corpusPath
::
FilePath
Config
{
corpusPath
::
FilePath
,
listPath
::
FilePath
,
listPath
::
FilePath
,
outputPath
::
FilePath
,
outputPath
::
FilePath
,
corpusParser
::
CorpusParser
,
corpusParser
::
CorpusParser
...
@@ -201,12 +200,32 @@ data Config =
...
@@ -201,12 +200,32 @@ data Config =
,
exportFilter
::
[
Filter
]
,
exportFilter
::
[
Filter
]
}
deriving
(
Show
,
Generic
,
Eq
)
}
deriving
(
Show
,
Generic
,
Eq
)
instance
ToSchema
Config
------------------------------------------------------------------------
data
PhyloSubConfig
=
PhyloSubConfig
{
_sc_phyloProximity
::
Double
,
_sc_phyloSynchrony
::
Double
,
_sc_phyloQuality
::
Double
,
_sc_timeUnit
::
TimeUnit
,
_sc_clique
::
Clique
,
_sc_exportFilter
::
Double
}
deriving
(
Show
,
Generic
,
Eq
)
subConfig2config
::
PhyloSubConfig
->
PhyloConfig
subConfig2config
subConfig
=
defaultConfig
{
phyloProximity
=
WeightedLogJaccard
$
_sc_phyloProximity
subConfig
,
phyloSynchrony
=
ByProximityThreshold
(
_sc_phyloSynchrony
subConfig
)
0
AllBranches
MergeAllGroups
,
phyloQuality
=
Quality
(
_sc_phyloQuality
subConfig
)
1
,
timeUnit
=
_sc_timeUnit
subConfig
,
clique
=
_sc_clique
subConfig
,
exportFilter
=
[
ByBranchSize
$
_sc_exportFilter
subConfig
]
}
defaultConfig
::
Config
------------------------------------------------------------------------
defaultConfig
::
PhyloConfig
defaultConfig
=
defaultConfig
=
Config
{
corpusPath
=
"corpus.csv"
-- useful for commandline only
Phylo
Config
{
corpusPath
=
"corpus.csv"
-- useful for commandline only
,
listPath
=
"list.csv"
-- useful for commandline only
,
listPath
=
"list.csv"
-- useful for commandline only
,
outputPath
=
"data/"
,
outputPath
=
"data/"
,
corpusParser
=
Csv
100000
,
corpusParser
=
Csv
100000
...
@@ -225,8 +244,15 @@ defaultConfig =
...
@@ -225,8 +244,15 @@ defaultConfig =
,
exportFilter
=
[
ByBranchSize
3
]
,
exportFilter
=
[
ByBranchSize
3
]
}
}
instance
FromJSON
Config
-- Main Instances
instance
ToJSON
Config
instance
ToSchema
PhyloConfig
instance
ToSchema
PhyloSubConfig
instance
FromJSON
PhyloConfig
instance
ToJSON
PhyloConfig
instance
FromJSON
PhyloSubConfig
instance
ToJSON
PhyloSubConfig
instance
FromJSON
CorpusParser
instance
FromJSON
CorpusParser
instance
ToJSON
CorpusParser
instance
ToJSON
CorpusParser
...
@@ -298,7 +324,7 @@ defaultSoftware =
...
@@ -298,7 +324,7 @@ defaultSoftware =
data
PhyloParam
=
data
PhyloParam
=
PhyloParam
{
_phyloParam_version
::
Text
PhyloParam
{
_phyloParam_version
::
Text
,
_phyloParam_software
::
Software
,
_phyloParam_software
::
Software
,
_phyloParam_config
::
Config
,
_phyloParam_config
::
Phylo
Config
}
deriving
(
Generic
,
Show
,
Eq
)
}
deriving
(
Generic
,
Show
,
Eq
)
instance
ToSchema
PhyloParam
where
instance
ToSchema
PhyloParam
where
...
@@ -564,7 +590,8 @@ instance ToSchema PhyloExport where
...
@@ -564,7 +590,8 @@ instance ToSchema PhyloExport where
-- | Lenses | --
-- | Lenses | --
----------------
----------------
makeLenses
''
C
onfig
makeLenses
''
P
hyloConfig
makeLenses
''
P
hyloSubConfig
makeLenses
''
P
roximity
makeLenses
''
P
roximity
makeLenses
''
S
eaElevation
makeLenses
''
S
eaElevation
makeLenses
''
Q
uality
makeLenses
''
Q
uality
...
...
src/Gargantext/Core/Viz/Phylo/API.hs
View file @
b5aec299
...
@@ -17,10 +17,6 @@ Portability : POSIX
...
@@ -17,10 +17,6 @@ Portability : POSIX
module
Gargantext.Core.Viz.Phylo.API
module
Gargantext.Core.Viz.Phylo.API
where
where
-- import Control.Lens ((^.))
-- import Gargantext.Core.Viz.Phylo.Example
-- import Gargantext.Database.Schema.Node (node_hyperdata)
--import Control.Monad.Reader (ask)
import
Data.Aeson
import
Data.Aeson
import
Data.Either
import
Data.Either
import
Data.Maybe
(
fromMaybe
)
import
Data.Maybe
(
fromMaybe
)
...
@@ -94,12 +90,17 @@ type GetPhylo = QueryParam "listId" ListId
...
@@ -94,12 +90,17 @@ type GetPhylo = QueryParam "listId" ListId
-- Fix Filter parameters
-- Fix Filter parameters
-- TODO fix parameters to default config that should be in Node
-- TODO fix parameters to default config that should be in Node
getPhylo
::
PhyloId
->
GargServer
GetPhylo
getPhylo
::
PhyloId
->
GargServer
GetPhylo
getPhylo
phyloId
_lId
_level
_minSizeBranch
=
do
getPhylo
phyloId
_lId
_level
_minSizeBranch
=
getPhyloDataJson
phyloId
getPhyloDataJson
::
PhyloId
->
GargNoServer
Value
getPhyloDataJson
phyloId
=
do
maybePhyloData
<-
getPhyloData
phyloId
maybePhyloData
<-
getPhyloData
phyloId
let
phyloData
=
fromMaybe
phyloExample
maybePhyloData
let
phyloData
=
fromMaybe
phyloExample
maybePhyloData
phyloJson
<-
liftBase
$
phylo2dot2json
phyloData
phyloJson
<-
liftBase
$
phylo2dot2json
phyloData
pure
phyloJson
pure
phyloJson
-- getPhylo phId _lId l msb = do
-- getPhylo phId _lId l msb = do
-- let
-- let
-- level = fromMaybe 2 l
-- level = fromMaybe 2 l
...
...
src/Gargantext/Core/Viz/Phylo/API/Tools.hs
View file @
b5aec299
...
@@ -29,7 +29,7 @@ import Gargantext.API.Prelude (GargNoServer)
...
@@ -29,7 +29,7 @@ import Gargantext.API.Prelude (GargNoServer)
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Types
(
Context
)
import
Gargantext.Core.Types
(
Context
)
import
Gargantext.Core.Types.Main
(
ListType
(
MapTerm
))
import
Gargantext.Core.Types.Main
(
ListType
(
MapTerm
))
import
Gargantext.Core.Viz.Phylo
(
TimeUnit
(
..
),
Date
,
Document
(
..
),
Config
(
..
),
Phylo
)
import
Gargantext.Core.Viz.Phylo
(
TimeUnit
(
..
),
Date
,
Document
(
..
),
Phylo
Config
(
..
),
Phylo
)
import
Gargantext.Core.Viz.Phylo.PhyloExport
(
toPhyloExport
,
dotToFile
)
import
Gargantext.Core.Viz.Phylo.PhyloExport
(
toPhyloExport
,
dotToFile
)
import
Gargantext.Core.Viz.Phylo.PhyloMaker
(
toPhylo
,
toPhyloStep
)
import
Gargantext.Core.Viz.Phylo.PhyloMaker
(
toPhylo
,
toPhyloStep
)
import
Gargantext.Core.Viz.Phylo.PhyloTools
(
{-printIOMsg, printIOComment,-}
setConfig
)
import
Gargantext.Core.Viz.Phylo.PhyloTools
(
{-printIOMsg, printIOComment,-}
setConfig
)
...
@@ -72,8 +72,8 @@ phylo2dot2json phylo = do
...
@@ -72,8 +72,8 @@ phylo2dot2json phylo = do
file_to_json
=
"/tmp/toPhylo.json"
file_to_json
=
"/tmp/toPhylo.json"
_
<-
dotToFile
file_from
(
toPhyloExport
phylo
)
_
<-
dotToFile
file_from
(
toPhyloExport
phylo
)
_
<-
Shell
.
callProcess
"
/usr/bin/
dot"
[
"-Tdot"
,
"-o"
,
file_dot
,
file_from
]
_
<-
Shell
.
callProcess
"dot"
[
"-Tdot"
,
"-o"
,
file_dot
,
file_from
]
_
<-
Shell
.
callProcess
"
/usr/bin/
dot"
[
"-Txdot_json"
,
"-o"
,
file_to_json
,
file_dot
]
_
<-
Shell
.
callProcess
"dot"
[
"-Txdot_json"
,
"-o"
,
file_to_json
,
file_dot
]
maybeValue
<-
decodeFileStrict
file_to_json
maybeValue
<-
decodeFileStrict
file_to_json
...
@@ -85,7 +85,7 @@ phylo2dot2json phylo = do
...
@@ -85,7 +85,7 @@ phylo2dot2json phylo = do
flowPhyloAPI
::
Config
->
CorpusId
->
GargNoServer
Phylo
flowPhyloAPI
::
Phylo
Config
->
CorpusId
->
GargNoServer
Phylo
flowPhyloAPI
config
cId
=
do
flowPhyloAPI
config
cId
=
do
(
mapList
,
corpus
)
<-
corpusIdtoDocuments
(
timeUnit
config
)
cId
(
mapList
,
corpus
)
<-
corpusIdtoDocuments
(
timeUnit
config
)
cId
phyloWithCliques
<-
pure
$
toPhyloStep
corpus
mapList
config
phyloWithCliques
<-
pure
$
toPhyloStep
corpus
mapList
config
...
@@ -149,12 +149,10 @@ toMonths y m d = fromIntegral $ cdMonths
...
@@ -149,12 +149,10 @@ toMonths y m d = fromIntegral $ cdMonths
$
diffGregorianDurationClip
(
fromGregorian
y
m
d
)
$
diffGregorianDurationClip
(
fromGregorian
y
m
d
)
(
fromGregorian
0000
0
0
)
(
fromGregorian
0000
0
0
)
toDays
::
Integer
->
Int
->
Int
->
Date
toDays
::
Integer
->
Int
->
Int
->
Date
toDays
y
m
d
=
fromIntegral
toDays
y
m
d
=
fromIntegral
$
diffDays
(
fromGregorian
y
m
d
)
(
fromGregorian
0000
0
0
)
$
diffDays
(
fromGregorian
y
m
d
)
(
fromGregorian
0000
0
0
)
toPhyloDate
::
Int
->
Int
->
Int
->
TimeUnit
->
Date
toPhyloDate
::
Int
->
Int
->
Int
->
TimeUnit
->
Date
toPhyloDate
y
m
d
tu
=
case
tu
of
toPhyloDate
y
m
d
tu
=
case
tu
of
Year
_
_
_
->
y
Year
_
_
_
->
y
...
@@ -192,5 +190,3 @@ readJson :: FilePath -> IO Lazy.ByteString
...
@@ -192,5 +190,3 @@ readJson :: FilePath -> IO Lazy.ByteString
readJson
path
=
Lazy
.
readFile
path
readJson
path
=
Lazy
.
readFile
path
src/Gargantext/Core/Viz/Phylo/Example.hs
View file @
b5aec299
...
@@ -89,14 +89,16 @@ phyloCooc = docsToTimeScaleCooc docs (foundations ^. foundations_roots)
...
@@ -89,14 +89,16 @@ phyloCooc = docsToTimeScaleCooc docs (foundations ^. foundations_roots)
periods
::
[(
Date
,
Date
)]
periods
::
[(
Date
,
Date
)]
periods
=
toPeriods
(
sort
$
nub
$
map
date
docs
)
(
getTimePeriod
$
timeUnit
config
)
(
getTimeStep
$
timeUnit
config
)
periods
=
toPeriods
(
sort
$
nub
$
map
date
docs
)
(
getTimePeriod
$
timeUnit
config
)
(
getTimeStep
$
timeUnit
config
)
nbDocsByYear
::
Map
Date
Double
nbDocsByYear
::
Map
Date
Double
nbDocsByYear
=
docsToTimeScaleNb
docs
nbDocsByYear
=
docsToTimeScaleNb
docs
config
::
Config
config
::
Phylo
Config
config
=
config
=
defaultConfig
{
phyloName
=
"Cesar et Cleopatre"
defaultConfig
{
phyloName
=
"Cesar et Cleopatre"
,
phyloLevel
=
2
,
phyloLevel
=
2
...
@@ -106,7 +108,7 @@ config =
...
@@ -106,7 +108,7 @@ config =
docs
::
[
Document
]
docs
::
[
Document
]
docs
=
map
(
\
(
d
,
t
)
docs
=
map
(
\
(
d
,
t
)
->
Document
d
->
Document
(
d
+
102
)
""
""
(
filter
(
\
n
->
isRoots
n
(
foundations
^.
foundations_roots
))
$
monoTexts
t
)
(
filter
(
\
n
->
isRoots
n
(
foundations
^.
foundations_roots
))
$
monoTexts
t
)
Nothing
Nothing
...
...
src/Gargantext/Core/Viz/Phylo/PhyloMaker.hs
View file @
b5aec299
...
@@ -45,7 +45,7 @@ data Phylo' = PhyloBase { _phylo'_phyloBase :: Phylo}
...
@@ -45,7 +45,7 @@ data Phylo' = PhyloBase { _phylo'_phyloBase :: Phylo}
| PhyloN { _phylo'_phylo1 :: Phylo}
| PhyloN { _phylo'_phylo1 :: Phylo}
toPhylo' :: Phylo' -> [Document] -> TermList -> Config -> Phylo
toPhylo' :: Phylo' -> [Document] -> TermList ->
Phylo
Config -> Phylo
toPhylo' (PhyloN phylo) = toPhylo'
toPhylo' (PhyloN phylo) = toPhylo'
toPhylo' (PhyloBase phylo) = toPhylo
toPhylo' (PhyloBase phylo) = toPhylo
-}
-}
...
@@ -160,7 +160,7 @@ indexDates' m = map (\docs ->
...
@@ -160,7 +160,7 @@ indexDates' m = map (\docs ->
-- To build the first phylo step from docs and terms
-- To build the first phylo step from docs and terms
-- QL: backend entre phyloBase et phyloClique
-- QL: backend entre phyloBase et phyloClique
toPhyloStep
::
[
Document
]
->
TermList
->
Config
->
Phylo
toPhyloStep
::
[
Document
]
->
TermList
->
Phylo
Config
->
Phylo
toPhyloStep
docs
lst
conf
=
case
(
getSeaElevation
phyloBase
)
of
toPhyloStep
docs
lst
conf
=
case
(
getSeaElevation
phyloBase
)
of
Constante
_
_
->
appendGroups
cliqueToGroup
1
phyloClique
(
updatePeriods
(
indexDates'
docs'
)
phyloBase
)
Constante
_
_
->
appendGroups
cliqueToGroup
1
phyloClique
(
updatePeriods
(
indexDates'
docs'
)
phyloBase
)
Adaptative
_
->
toGroupsProxi
1
Adaptative
_
->
toGroupsProxi
1
...
@@ -362,7 +362,7 @@ initPhyloLevels lvlMax pId =
...
@@ -362,7 +362,7 @@ initPhyloLevels lvlMax pId =
-- To init the basic elements of a Phylo
-- To init the basic elements of a Phylo
toPhyloBase
::
[
Document
]
->
TermList
->
Config
->
Phylo
toPhyloBase
::
[
Document
]
->
TermList
->
Phylo
Config
->
Phylo
toPhyloBase
docs
lst
conf
=
toPhyloBase
docs
lst
conf
=
let
foundations
=
PhyloFoundations
(
Vector
.
fromList
$
nub
$
concat
$
map
text
docs
)
lst
let
foundations
=
PhyloFoundations
(
Vector
.
fromList
$
nub
$
concat
$
map
text
docs
)
lst
docsSources
=
PhyloSources
(
Vector
.
fromList
$
nub
$
concat
$
map
sources
docs
)
docsSources
=
PhyloSources
(
Vector
.
fromList
$
nub
$
concat
$
map
sources
docs
)
...
...
src/Gargantext/Core/Viz/Phylo/PhyloTools.hs
View file @
b5aec299
...
@@ -400,11 +400,11 @@ getSeaElevation :: Phylo -> SeaElevation
...
@@ -400,11 +400,11 @@ getSeaElevation :: Phylo -> SeaElevation
getSeaElevation
phylo
=
seaElevation
(
getConfig
phylo
)
getSeaElevation
phylo
=
seaElevation
(
getConfig
phylo
)
getConfig
::
Phylo
->
Config
getConfig
::
Phylo
->
Phylo
Config
getConfig
phylo
=
(
phylo
^.
phylo_param
)
^.
phyloParam_config
getConfig
phylo
=
(
phylo
^.
phylo_param
)
^.
phyloParam_config
setConfig
::
Config
->
Phylo
->
Phylo
setConfig
::
Phylo
Config
->
Phylo
->
Phylo
setConfig
config
phylo
=
phylo
setConfig
config
phylo
=
phylo
&
phylo_param
.~
(
PhyloParam
&
phylo_param
.~
(
PhyloParam
((
phylo
^.
phylo_param
)
^.
phyloParam_version
)
((
phylo
^.
phylo_param
)
^.
phyloParam_version
)
...
...
src/Gargantext/Database/Action/Share.hs
View file @
b5aec299
...
@@ -27,7 +27,7 @@ import Gargantext.Database.Query.Tree.Root (getRootId)
...
@@ -27,7 +27,7 @@ import Gargantext.Database.Query.Tree.Root (getRootId)
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Node
import
Gargantext.Prelude
import
Gargantext.Prelude
-- | TODO move in Config of Gargantext
-- | TODO move in
Phylo
Config of Gargantext
publicNodeTypes
::
[
NodeType
]
publicNodeTypes
::
[
NodeType
]
publicNodeTypes
=
[
NodeDashboard
,
NodeGraph
,
NodePhylo
,
NodeFile
]
publicNodeTypes
=
[
NodeDashboard
,
NodeGraph
,
NodePhylo
,
NodeFile
]
...
...
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