Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
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
Przemyslaw Kaminski
haskell-gargantext
Commits
24958659
Commit
24958659
authored
Apr 05, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PHYLO.API] Adding REST functions.
parent
242f56d2
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
98 additions
and
89 deletions
+98
-89
Node.hs
src/Gargantext/API/Node.hs
+2
-0
Node.hs
src/Gargantext/Database/Types/Node.hs
+2
-1
Phylo.hs
src/Gargantext/Viz/Phylo.hs
+34
-28
Example.hs
src/Gargantext/Viz/Phylo/Example.hs
+3
-3
LevelMaker.hs
src/Gargantext/Viz/Phylo/LevelMaker.hs
+7
-7
Tools.hs
src/Gargantext/Viz/Phylo/Tools.hs
+24
-24
Display.hs
src/Gargantext/Viz/Phylo/View/Display.hs
+3
-3
Filters.hs
src/Gargantext/Viz/Phylo/View/Filters.hs
+7
-7
Metrics.hs
src/Gargantext/Viz/Phylo/View/Metrics.hs
+2
-2
Sort.hs
src/Gargantext/Viz/Phylo/View/Sort.hs
+1
-1
Taggers.hs
src/Gargantext/Viz/Phylo/View/Taggers.hs
+4
-4
ViewMaker.hs
src/Gargantext/Viz/Phylo/View/ViewMaker.hs
+9
-9
No files found.
src/Gargantext/API/Node.hs
View file @
24958659
...
...
@@ -63,6 +63,8 @@ import Gargantext.API.Settings
import
Gargantext.Text.Metrics
(
Scored
(
..
))
import
Gargantext.Viz.Graph
hiding
(
Node
)
-- (Graph(_graph_metadata),LegendField(..), GraphMetadata(..),readGraphFromJson,defaultGraph)
import
Gargantext.Viz.Graph.Tools
(
cooc2graph
)
import
Gargantext.Viz.Phylo.API
(
getPhylo
)
import
Gargantext.Viz.Phylo
hiding
(
Tree
)
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
...
...
src/Gargantext/Database/Types/Node.hs
View file @
24958659
...
...
@@ -82,7 +82,6 @@ instance Arbitrary NodeId where
arbitrary
=
NodeId
<$>
arbitrary
type
ParentId
=
NodeId
type
GraphId
=
NodeId
type
CorpusId
=
NodeId
type
ListId
=
NodeId
type
DocumentId
=
NodeId
...
...
@@ -91,6 +90,8 @@ type RootId = NodeId
type
MasterCorpusId
=
CorpusId
type
UserCorpusId
=
CorpusId
type
GraphId
=
NodeId
type
PhyloId
=
NodeId
type
AnnuaireId
=
NodeId
type
ContactId
=
NodeId
...
...
src/Gargantext/Viz/Phylo.hs
View file @
24958659
...
...
@@ -52,7 +52,7 @@ import Gargantext.Prelude
data
PhyloParam
=
PhyloParam
{
_phyloParam_version
::
Text
-- Double ?
,
_phyloParam_software
::
Software
,
_phyloParam_query
::
PhyloQuery
,
_phyloParam_query
::
PhyloQuery
Build
}
deriving
(
Generic
,
Show
,
Eq
)
...
...
@@ -326,7 +326,7 @@ data Order = Asc | Desc deriving (Show)
-- | A Phyloquery describes a phylomemic reconstruction
data
PhyloQuery
=
PhyloQuery
data
PhyloQuery
Build
=
PhyloQueryBuild
{
_q_phyloTitle
::
Text
,
_q_phyloDesc
::
Text
...
...
@@ -352,7 +352,6 @@ data PhyloQuery = PhyloQuery
data
Filiation
=
Ascendant
|
Descendant
|
Merge
|
Complete
deriving
(
Show
)
data
EdgeType
=
PeriodEdge
|
LevelEdge
deriving
(
Show
)
-------------------
-- | PhyloView | --
-------------------
...
...
@@ -360,39 +359,39 @@ data EdgeType = PeriodEdge | LevelEdge deriving (Show)
-- | A PhyloView is the output type of a Phylo
data
PhyloView
=
PhyloView
{
_p
hylo_viewP
aram
::
PhyloParam
,
_p
hylo_viewT
itle
::
Text
,
_p
hylo_viewD
escription
::
Text
,
_p
hylo_viewF
iliation
::
Filiation
,
_p
hylo_viewM
etrics
::
Map
Text
[
Double
]
,
_p
hylo_viewB
ranches
::
[
PhyloBranch
]
,
_p
hylo_viewN
odes
::
[
PhyloNode
]
,
_p
hylo_viewE
dges
::
[
PhyloEdge
]
{
_p
v_p
aram
::
PhyloParam
,
_p
v_t
itle
::
Text
,
_p
v_d
escription
::
Text
,
_p
v_f
iliation
::
Filiation
,
_p
v_m
etrics
::
Map
Text
[
Double
]
,
_p
v_b
ranches
::
[
PhyloBranch
]
,
_p
v_n
odes
::
[
PhyloNode
]
,
_p
v_e
dges
::
[
PhyloEdge
]
}
deriving
(
Show
)
-- | A phyloview is made of PhyloBranches, edges and nodes
data
PhyloBranch
=
PhyloBranch
{
_p
hylo_branchI
d
::
PhyloBranchId
,
_p
hylo_branchL
abel
::
Text
,
_p
hylo_branchM
etrics
::
Map
Text
[
Double
]
{
_p
b_i
d
::
PhyloBranchId
,
_p
b_l
abel
::
Text
,
_p
b_m
etrics
::
Map
Text
[
Double
]
}
deriving
(
Show
)
data
PhyloEdge
=
PhyloEdge
{
_p
hylo_edgeS
ource
::
PhyloGroupId
,
_p
hylo_edgeT
arget
::
PhyloGroupId
,
_p
hylo_edgeT
ype
::
EdgeType
,
_p
hylo_edgeW
eight
::
Weight
{
_p
e_s
ource
::
PhyloGroupId
,
_p
e_t
arget
::
PhyloGroupId
,
_p
e_t
ype
::
EdgeType
,
_p
e_w
eight
::
Weight
}
deriving
(
Show
)
data
PhyloNode
=
PhyloNode
{
_p
hylo_nodeI
d
::
PhyloGroupId
,
_p
hylo_nodeBranchI
d
::
Maybe
PhyloBranchId
,
_p
hylo_nodeL
abel
::
Text
,
_p
hylo_nodeNgramsI
dx
::
[
Int
]
,
_p
hylo_nodeN
grams
::
Maybe
[
Ngrams
]
,
_p
hylo_nodeM
etrics
::
Map
Text
[
Double
]
,
_p
hylo_nodeLevelP
arents
::
Maybe
[
PhyloGroupId
]
,
_p
hylo_nodeLevelC
hilds
::
[
PhyloNode
]
{
_p
n_i
d
::
PhyloGroupId
,
_p
n_bi
d
::
Maybe
PhyloBranchId
,
_p
n_l
abel
::
Text
,
_p
n_i
dx
::
[
Int
]
,
_p
n_n
grams
::
Maybe
[
Ngrams
]
,
_p
n_m
etrics
::
Map
Text
[
Double
]
,
_p
n_p
arents
::
Maybe
[
PhyloGroupId
]
,
_p
n_c
hilds
::
[
PhyloNode
]
}
deriving
(
Show
)
...
...
@@ -448,7 +447,7 @@ makeLenses ''Proximity
makeLenses
''
C
luster
makeLenses
''
F
ilter
--
makeLenses
''
P
hyloQuery
makeLenses
''
P
hyloQuery
Build
makeLenses
''
P
hyloQueryView
--
makeLenses
''
P
hyloView
...
...
@@ -485,7 +484,14 @@ $(deriveJSON (unPrefix "_rc_" ) ''RCParams )
$
(
deriveJSON
(
unPrefix
"_wlj_"
)
''
W
LJParams
)
$
(
deriveJSON
(
unPrefix
"_sb_"
)
''
S
BParams
)
--
$
(
deriveJSON
(
unPrefix
"_q_"
)
''
P
hyloQuery
)
$
(
deriveJSON
(
unPrefix
"_q_"
)
''
P
hyloQueryBuild
)
$
(
deriveJSON
(
unPrefix
"_pv_"
)
''
P
hyloView
)
$
(
deriveJSON
(
unPrefix
"_pb_"
)
''
P
hyloBranch
)
$
(
deriveJSON
(
unPrefix
"_pe_"
)
''
P
hyloEdge
)
$
(
deriveJSON
(
unPrefix
"_pn_"
)
''
P
hyloNode
)
$
(
deriveJSON
defaultOptions
''
F
iliation
)
$
(
deriveJSON
defaultOptions
''
E
dgeType
)
----------------------------
...
...
src/Gargantext/Viz/Phylo/Example.hs
View file @
24958659
...
...
@@ -81,7 +81,7 @@ phyloFromQuery :: Phylo
phyloFromQuery
=
toPhylo
(
queryParser
queryEx
)
corpus
actants
actantsTrees
-- | To do : create a request handler and a query parser
queryParser
::
[
Char
]
->
PhyloQuery
queryParser
::
[
Char
]
->
PhyloQuery
Build
queryParser
_q
=
phyloQuery
queryEx
::
[
Char
]
...
...
@@ -94,8 +94,8 @@ queryEx = "title=Cesar et Cleôpatre"
++
"nthCluster=RelatedComponents"
++
"nthProximity=Filiation"
phyloQuery
::
PhyloQuery
phyloQuery
=
PhyloQuery
"Cesar et Cleôpatre"
"An example of Phylomemy (french without accent)"
phyloQuery
::
PhyloQuery
Build
phyloQuery
=
PhyloQuery
Build
"Cesar et Cleôpatre"
"An example of Phylomemy (french without accent)"
5
3
defaultFis
[]
[]
defaultWeightedLogJaccard
3
defaultRelatedComponents
...
...
src/Gargantext/Viz/Phylo/LevelMaker.hs
View file @
24958659
...
...
@@ -25,7 +25,7 @@ import Data.Map (Map, (!), empty, restrictKeys, filterWithKe
import
Data.Text
(
Text
)
import
Data.Tuple.Extra
import
Data.Vector
(
Vector
)
import
Gargantext.Prelude
hiding
(
head
)
import
Gargantext.Prelude
hiding
(
head
)
import
Gargantext.Viz.Phylo
import
Gargantext.Viz.Phylo.Aggregates.Cluster
import
Gargantext.Viz.Phylo.Aggregates.Cooc
...
...
@@ -145,8 +145,8 @@ toNthLevel lvlMax prox clus p
|
lvl
>=
lvlMax
=
p
|
otherwise
=
toNthLevel
lvlMax
prox
clus
$
setPhyloBranches
(
lvl
+
1
)
$
interTempoMatching
Descendant
(
lvl
+
1
)
prox
$
interTempoMatching
Ascendant
(
lvl
+
1
)
prox
$
interTempoMatching
Descendant
(
lvl
+
1
)
prox
$
interTempoMatching
Ascendant
(
lvl
+
1
)
prox
$
setLevelLinks
(
lvl
,
lvl
+
1
)
$
addPhyloLevel
(
lvl
+
1
)
(
phyloToClusters
lvl
(
getProximity
clus
)
clus
p
)
p
...
...
@@ -162,7 +162,7 @@ toPhylo1 :: Cluster -> Proximity -> [Metric] -> [Filter] -> Map (Date, Date) [Do
toPhylo1
clus
prox
metrics
filters
d
p
=
case
clus
of
Fis
(
FisParams
k
s
)
->
setPhyloBranches
1
$
interTempoMatching
Descendant
1
prox
$
interTempoMatching
Ascendant
1
prox
$
interTempoMatching
Ascendant
1
prox
$
setLevelLinks
(
0
,
1
)
$
setLevelLinks
(
1
,
0
)
$
addPhyloLevel
1
phyloFis
p
...
...
@@ -181,7 +181,7 @@ toPhylo0 d p = addPhyloLevel 0 d p
-- | To reconstruct the Base of a Phylo
toPhyloBase
::
PhyloQuery
->
PhyloParam
->
[(
Date
,
Text
)]
->
[
Ngrams
]
->
[
Tree
Ngrams
]
->
Phylo
toPhyloBase
::
PhyloQuery
Build
->
PhyloParam
->
[(
Date
,
Text
)]
->
[
Ngrams
]
->
[
Tree
Ngrams
]
->
Phylo
toPhyloBase
q
p
c
a
ts
=
initPhyloBase
periods
foundations
peaks
p
where
--------------------------------------
...
...
@@ -197,8 +197,8 @@ toPhyloBase q p c a ts = initPhyloBase periods foundations peaks p
--------------------------------------
-- | To reconstruct a Phylomemy from a PhyloQuery, a Corpus and a list of actants
toPhylo
::
PhyloQuery
->
[(
Date
,
Text
)]
->
[
Ngrams
]
->
[
Tree
Ngrams
]
->
Phylo
-- | To reconstruct a Phylomemy from a PhyloQuery
Build
, a Corpus and a list of actants
toPhylo
::
PhyloQuery
Build
->
[(
Date
,
Text
)]
->
[
Ngrams
]
->
[
Tree
Ngrams
]
->
Phylo
toPhylo
q
c
a
ts
=
toNthLevel
(
getNthLevel
q
)
(
getInterTemporalMatching
q
)
(
getNthCluster
q
)
phylo1
where
--------------------------------------
...
...
src/Gargantext/Viz/Phylo/Tools.hs
View file @
24958659
...
...
@@ -145,7 +145,7 @@ initPhyloBase :: [(Date, Date)] -> Vector Ngrams -> PhyloPeaks -> PhyloParam ->
initPhyloBase
pds
fds
pks
prm
=
Phylo
((
fst
.
head
)
pds
,
(
snd
.
last
)
pds
)
fds
pks
(
map
(
\
pd
->
initPhyloPeriod
pd
[]
)
pds
)
prm
-- | To init the param of a Phylo
initPhyloParam
::
Maybe
Text
->
Maybe
Software
->
Maybe
PhyloQuery
->
PhyloParam
initPhyloParam
::
Maybe
Text
->
Maybe
Software
->
Maybe
PhyloQuery
Build
->
PhyloParam
initPhyloParam
(
def
defaultPhyloVersion
->
v
)
(
def
defaultSoftware
->
s
)
(
def
defaultQuery
->
q
)
=
PhyloParam
v
s
q
-- | To get the foundations of a Phylo
...
...
@@ -495,14 +495,14 @@ getNeighbours directed g e = case directed of
-- | To get the PhyloBranchId of PhyloNode if it exists
getNodeBranchId
::
PhyloNode
->
PhyloBranchId
getNodeBranchId
n
=
case
n
^.
p
hylo_nodeBranchI
d
of
getNodeBranchId
n
=
case
n
^.
p
n_bi
d
of
Nothing
->
panic
"[ERR][Viz.Phylo.Tools.getNodeBranchId] branchId not found"
Just
i
->
i
-- | To get the PhyloGroupId of a PhyloNode
getNodeId
::
PhyloNode
->
PhyloGroupId
getNodeId
n
=
n
^.
p
hylo_nodeI
d
getNodeId
n
=
n
^.
p
n_i
d
-- | To get the Level of a PhyloNode
...
...
@@ -513,12 +513,12 @@ getNodeLevel n = (snd . fst) $ getNodeId n
-- | To get the Parent Node of a PhyloNode in a PhyloView
getNodeParent
::
PhyloNode
->
PhyloView
->
[
PhyloNode
]
getNodeParent
n
v
=
filter
(
\
n'
->
elem
(
getNodeId
n'
)
(
getNodeParentsId
n
))
$
v
^.
p
hylo_viewN
odes
$
v
^.
p
v_n
odes
-- | To get the Parent Node id of a PhyloNode if it exists
getNodeParentsId
::
PhyloNode
->
[
PhyloGroupId
]
getNodeParentsId
n
=
case
n
^.
p
hylo_nodeLevelP
arents
of
getNodeParentsId
n
=
case
n
^.
p
n_p
arents
of
Nothing
->
panic
"[ERR][Viz.Phylo.Tools.getNodeParentsId] node parent not found"
Just
ids
->
ids
...
...
@@ -536,18 +536,18 @@ getNodesByBranches v = zip bIds $ map (\id -> filter (\n -> (getNodeBranchId n)
-- | To get a list of PhyloNodes owned by any PhyloBranches in a PhyloView
getNodesInBranches
::
PhyloView
->
[
PhyloNode
]
getNodesInBranches
v
=
filter
(
\
n
->
isJust
$
n
^.
p
hylo_nodeBranchI
d
)
$
v
^.
p
hylo_viewN
odes
getNodesInBranches
v
=
filter
(
\
n
->
isJust
$
n
^.
p
n_bi
d
)
$
v
^.
p
v_n
odes
-- | To get the PhyloGroupId of the Source of a PhyloEdge
getSourceId
::
PhyloEdge
->
PhyloGroupId
getSourceId
e
=
e
^.
p
hylo_edgeS
ource
getSourceId
e
=
e
^.
p
e_s
ource
-- | To get the PhyloGroupId of the Target of a PhyloEdge
getTargetId
::
PhyloEdge
->
PhyloGroupId
getTargetId
e
=
e
^.
p
hylo_edgeT
arget
getTargetId
e
=
e
^.
p
e_t
arget
---------------------
...
...
@@ -557,7 +557,7 @@ getTargetId e = e ^. phylo_edgeTarget
-- | To get the PhyloBranchId of a PhyloBranch
getBranchId
::
PhyloBranch
->
PhyloBranchId
getBranchId
b
=
b
^.
p
hylo_branchI
d
getBranchId
b
=
b
^.
p
b_i
d
-- | To get a list of PhyloBranchIds given a Level in a Phylo
...
...
@@ -569,12 +569,12 @@ getBranchIdsWith lvl p = sortOn snd
-- | To get the Meta value of a PhyloBranch
getBranchMeta
::
Text
->
PhyloBranch
->
[
Double
]
getBranchMeta
k
b
=
(
b
^.
p
hylo_branchM
etrics
)
!
k
getBranchMeta
k
b
=
(
b
^.
p
b_m
etrics
)
!
k
-- | To get all the PhyloBranchIds of a PhyloView
getViewBranchIds
::
PhyloView
->
[
PhyloBranchId
]
getViewBranchIds
v
=
map
getBranchId
$
v
^.
p
hylo_viewB
ranches
getViewBranchIds
v
=
map
getBranchId
$
v
^.
p
v_b
ranches
--------------------------------
...
...
@@ -582,47 +582,47 @@ getViewBranchIds v = map getBranchId $ v ^. phylo_viewBranches
--------------------------------
-- | To get the first clustering method to apply to get the contextual units of a Phylo
getContextualUnit
::
PhyloQuery
->
Cluster
getContextualUnit
::
PhyloQuery
Build
->
Cluster
getContextualUnit
q
=
q
^.
q_contextualUnit
-- | To get the metrics to apply to contextual units
getContextualUnitMetrics
::
PhyloQuery
->
[
Metric
]
getContextualUnitMetrics
::
PhyloQuery
Build
->
[
Metric
]
getContextualUnitMetrics
q
=
q
^.
q_contextualUnitMetrics
-- | To get the filters to apply to contextual units
getContextualUnitFilters
::
PhyloQuery
->
[
Filter
]
getContextualUnitFilters
::
PhyloQuery
Build
->
[
Filter
]
getContextualUnitFilters
q
=
q
^.
q_contextualUnitFilters
-- | To get the cluster methods to apply to the Nths levels of a Phylo
getNthCluster
::
PhyloQuery
->
Cluster
getNthCluster
::
PhyloQuery
Build
->
Cluster
getNthCluster
q
=
q
^.
q_nthCluster
-- | To get the Sup Level of a reconstruction of a Phylo from a PhyloQuery
getNthLevel
::
PhyloQuery
->
Level
getNthLevel
::
PhyloQuery
Build
->
Level
getNthLevel
q
=
q
^.
q_nthLevel
-- | To get the Grain of the PhyloPeriods from a PhyloQuery
getPeriodGrain
::
PhyloQuery
->
Int
getPeriodGrain
::
PhyloQuery
Build
->
Int
getPeriodGrain
q
=
q
^.
q_periodGrain
-- | To get the intertemporal matching strategy to apply to a Phylo from a PhyloQuery
getInterTemporalMatching
::
PhyloQuery
->
Proximity
getInterTemporalMatching
::
PhyloQuery
Build
->
Proximity
getInterTemporalMatching
q
=
q
^.
q_interTemporalMatching
-- | To get the Steps of the PhyloPeriods from a PhyloQuery
getPeriodSteps
::
PhyloQuery
->
Int
getPeriodSteps
::
PhyloQuery
Build
->
Int
getPeriodSteps
q
=
q
^.
q_periodSteps
--------------------------------------------------
-- | PhyloQuery & PhyloQueryView Constructors | --
-- | PhyloQuery
Build
& PhyloQueryView Constructors | --
--------------------------------------------------
...
...
@@ -655,10 +655,10 @@ initWeightedLogJaccard (def 0 -> thr) (def 0.01 -> sens) = WLJParams thr sens
-- | To initialize a PhyloQuery from given and default parameters
initPhyloQuery
::
Text
->
Text
->
Maybe
Int
->
Maybe
Int
->
Maybe
Cluster
->
Maybe
[
Metric
]
->
Maybe
[
Filter
]
->
Maybe
Proximity
->
Maybe
Level
->
Maybe
Cluster
->
PhyloQuery
initPhyloQuery
::
Text
->
Text
->
Maybe
Int
->
Maybe
Int
->
Maybe
Cluster
->
Maybe
[
Metric
]
->
Maybe
[
Filter
]
->
Maybe
Proximity
->
Maybe
Level
->
Maybe
Cluster
->
PhyloQuery
Build
initPhyloQuery
name
desc
(
def
5
->
grain
)
(
def
3
->
steps
)
(
def
defaultFis
->
cluster
)
(
def
[]
->
metrics
)
(
def
[]
->
filters
)
(
def
defaultWeightedLogJaccard
->
matching'
)
(
def
2
->
nthLevel
)
(
def
defaultRelatedComponents
->
nthCluster
)
=
PhyloQuery
name
desc
grain
steps
cluster
metrics
filters
matching'
nthLevel
nthCluster
PhyloQuery
Build
name
desc
grain
steps
cluster
metrics
filters
matching'
nthLevel
nthCluster
-- | To initialize a PhyloQueryView default parameters
...
...
@@ -706,7 +706,7 @@ defaultWeightedLogJaccard = WeightedLogJaccard (initWeightedLogJaccard Nothing N
-- Queries
defaultQuery
::
PhyloQuery
defaultQuery
::
PhyloQuery
Build
defaultQuery
=
initPhyloQuery
"Cesar et Cleôpatre"
"An example of Phylomemy (french without accent)"
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
...
...
src/Gargantext/Viz/Phylo/View/Display.hs
View file @
24958659
...
...
@@ -38,7 +38,7 @@ toNestedView ns ns'
nested
::
[
PhyloNode
]
nested
=
foldl
(
\
ns''
n
->
let
nIds'
=
getNodeParentsId
n
in
map
(
\
n'
->
if
elem
(
getNodeId
n'
)
nIds'
then
n'
&
p
hylo_nodeLevelC
hilds
%~
(
++
[
n
])
then
n'
&
p
n_c
hilds
%~
(
++
[
n
])
else
n'
)
ns''
)
ns'
ns
--------------------------------------
...
...
@@ -47,8 +47,8 @@ toNestedView ns ns'
processDisplay
::
DisplayMode
->
PhyloView
->
PhyloView
processDisplay
d
v
=
case
d
of
Flat
->
v
Nested
->
let
ns
=
sortOn
getNodeLevel
$
v
^.
p
hylo_viewN
odes
Nested
->
let
ns
=
sortOn
getNodeLevel
$
v
^.
p
v_n
odes
lvl
=
getNodeLevel
$
head
ns
in
v
&
p
hylo_viewN
odes
.~
toNestedView
(
filter
(
\
n
->
lvl
==
getNodeLevel
n
)
ns
)
in
v
&
p
v_n
odes
.~
toNestedView
(
filter
(
\
n
->
lvl
==
getNodeLevel
n
)
ns
)
(
filter
(
\
n
->
lvl
<
getNodeLevel
n
)
ns
)
--
_
->
panic
"[ERR][Viz.Phylo.Example.processDisplay] display not found"
src/Gargantext/Viz/Phylo/View/Filters.hs
View file @
24958659
...
...
@@ -28,13 +28,13 @@ import Gargantext.Viz.Phylo.Tools
-- | To clean a PhyloView list of Nodes, Edges, etc after having filtered its Branches
cleanNodesEdges
::
PhyloView
->
PhyloView
->
PhyloView
cleanNodesEdges
v
v'
=
v'
&
p
hylo_viewN
odes
%~
(
filter
(
\
n
->
not
$
elem
(
getNodeId
n
)
nIds
))
&
p
hylo_viewNodes
%~
(
map
(
\
n
->
if
isNothing
(
n
^.
phylo_nodeLevelP
arents
)
cleanNodesEdges
v
v'
=
v'
&
p
v_n
odes
%~
(
filter
(
\
n
->
not
$
elem
(
getNodeId
n
)
nIds
))
&
p
v_nodes
%~
(
map
(
\
n
->
if
isNothing
(
n
^.
pn_p
arents
)
then
n
else
if
(
not
.
null
)
$
(
getNodeParentsId
n
)
`
intersect
`
nIds
then
n
&
p
hylo_nodeLevelP
arents
.~
Nothing
then
n
&
p
n_p
arents
.~
Nothing
else
n
))
&
p
hylo_viewE
dges
%~
(
filter
(
\
e
->
(
not
$
elem
(
getSourceId
e
)
nIds
)
&
p
v_e
dges
%~
(
filter
(
\
e
->
(
not
$
elem
(
getSourceId
e
)
nIds
)
&&
(
not
$
elem
(
getTargetId
e
)
nIds
)))
where
--------------------------------------
...
...
@@ -54,9 +54,9 @@ filterSmallBranch inf sup min' prds v = cleanNodesEdges v v'
where
--------------------------------------
v'
::
PhyloView
v'
=
v
&
p
hylo_viewBranches
%~
(
filter
(
\
b
->
let
ns
=
filter
(
\
n
->
(
getBranchId
b
)
==
(
getNodeBranchId
n
))
$
getNodesInBranches
v
prds'
=
nub
$
map
(
\
n
->
(
fst
.
fst
)
$
getNodeId
n
)
ns
v'
=
v
&
p
v_branches
%~
(
filter
(
\
b
->
let
ns
=
filter
(
\
n
->
(
getBranchId
b
)
==
(
getNodeBranchId
n
))
$
getNodesInBranches
v
prds'
=
nub
$
map
(
\
n
->
(
fst
.
fst
)
$
getNodeId
n
)
ns
in
not
(
isLone
ns
prds'
)))
--------------------------------------
isLone
::
[
PhyloNode
]
->
[
PhyloPeriodId
]
->
Bool
...
...
src/Gargantext/Viz/Phylo/View/Metrics.hs
View file @
24958659
...
...
@@ -29,10 +29,10 @@ import Gargantext.Viz.Phylo.Tools
-- | To add a new meta Metric to a PhyloBranch
addBranchMetrics
::
PhyloBranchId
->
Text
->
Double
->
PhyloView
->
PhyloView
addBranchMetrics
id
lbl
val
v
=
over
(
p
hylo_viewB
ranches
addBranchMetrics
id
lbl
val
v
=
over
(
p
v_b
ranches
.
traverse
)
(
\
b
->
if
getBranchId
b
==
id
then
b
&
p
hylo_branchM
etrics
%~
insert
lbl
[
val
]
then
b
&
p
b_m
etrics
%~
insert
lbl
[
val
]
else
b
)
v
...
...
src/Gargantext/Viz/Phylo/View/Sort.hs
View file @
24958659
...
...
@@ -27,7 +27,7 @@ import Gargantext.Viz.Phylo.Tools
-- | To sort a PhyloView by Age
sortBranchByAge
::
Order
->
PhyloView
->
PhyloView
sortBranchByAge
o
v
=
v
&
p
hylo_viewB
ranches
%~
f
sortBranchByAge
o
v
=
v
&
p
v_b
ranches
%~
f
where
--------------------------------------
f
::
[
PhyloBranch
]
->
[
PhyloBranch
]
...
...
src/Gargantext/Viz/Phylo/View/Taggers.hs
View file @
24958659
...
...
@@ -66,10 +66,10 @@ mostOccNgrams thr group = (nub . concat )
-- | To alter the label of a PhyloBranch
alterBranchLabel
::
(
PhyloBranchId
,
Text
)
->
PhyloView
->
PhyloView
alterBranchLabel
(
id
,
lbl
)
v
=
over
(
p
hylo_viewB
ranches
alterBranchLabel
(
id
,
lbl
)
v
=
over
(
p
v_b
ranches
.
traverse
)
(
\
b
->
if
getBranchId
b
==
id
then
b
&
p
hylo_branchL
abel
.~
lbl
then
b
&
p
b_l
abel
.~
lbl
else
b
)
v
...
...
@@ -83,12 +83,12 @@ branchLabelFreq v thr p = foldl (\v' (id,lbl) -> alterBranchLabel (id,lbl) v') v
-- | To set the label of a PhyloNode as the nth most coocurent terms of its PhyloNodes
nodeLabelCooc
::
PhyloView
->
Int
->
Phylo
->
PhyloView
nodeLabelCooc
v
thr
p
=
over
(
p
hylo_viewN
odes
nodeLabelCooc
v
thr
p
=
over
(
p
v_n
odes
.
traverse
)
(
\
n
->
let
lbl
=
ngramsToLabel
(
getPeaksLabels
p
)
$
mostOccNgrams
thr
$
head
$
getGroupsFromIds
[
getNodeId
n
]
p
in
n
&
p
hylo_nodeL
abel
.~
lbl
)
v
in
n
&
p
n_l
abel
.~
lbl
)
v
-- | To process a sorted list of Taggers to a PhyloView
...
...
src/Gargantext/Viz/Phylo/View/ViewMaker.hs
View file @
24958659
...
...
@@ -76,16 +76,16 @@ groupsToNodes isR isV ns gs = map (\g -> let idxs = getGroupNgrams g
mergeEdges
::
[
PhyloEdge
]
->
[
PhyloEdge
]
->
[
PhyloEdge
]
mergeEdges
lAsc
lDes
=
elems
$
unionWithKey
(
\
_k
vAsc
vDes
->
vDes
&
p
hylo_edgeWeight
.~
(
max
(
vAsc
^.
phylo_edgeWeight
)
(
vDes
^.
phylo_edgeW
eight
)))
mAsc
mDes
$
unionWithKey
(
\
_k
vAsc
vDes
->
vDes
&
p
e_weight
.~
(
max
(
vAsc
^.
pe_weight
)
(
vDes
^.
pe_w
eight
)))
mAsc
mDes
where
--------------------------------------
mAsc
::
Map
(
PhyloGroupId
,
PhyloGroupId
)
PhyloEdge
mAsc
=
fromList
$
zip
(
map
(
\
e
->
(
e
^.
p
hylo_edgeTarget
,
e
^.
phylo_edgeS
ource
))
lAsc
)
lAsc
$
zip
(
map
(
\
e
->
(
e
^.
p
e_target
,
e
^.
pe_s
ource
))
lAsc
)
lAsc
--------------------------------------
mDes
::
Map
(
PhyloGroupId
,
PhyloGroupId
)
PhyloEdge
mDes
=
fromList
$
zip
(
map
(
\
e
->
(
e
^.
p
hylo_edgeSource
,
e
^.
phylo_edgeT
arget
))
lDes
)
lDes
$
zip
(
map
(
\
e
->
(
e
^.
p
e_source
,
e
^.
pe_t
arget
))
lDes
)
lDes
--------------------------------------
...
...
@@ -117,11 +117,11 @@ addChildNodes shouldDo lvl lvlMin vb fl p v =
if
(
not
shouldDo
)
||
(
lvl
==
lvlMin
)
then
v
else
addChildNodes
shouldDo
(
lvl
-
1
)
lvlMin
vb
fl
p
$
v
&
p
hylo_viewB
ranches
%~
(
++
(
phyloToBranches
(
lvl
-
1
)
p
))
&
p
hylo_viewN
odes
%~
(
++
(
groupsToNodes
False
vb
(
getPeaksLabels
p
)
gs'
))
&
p
hylo_viewE
dges
%~
(
++
(
groupsToEdges
fl
PeriodEdge
gs'
))
&
p
hylo_viewE
dges
%~
(
++
(
groupsToEdges
Descendant
LevelEdge
gs
))
&
p
hylo_viewE
dges
%~
(
++
(
groupsToEdges
Ascendant
LevelEdge
gs'
))
$
v
&
p
v_b
ranches
%~
(
++
(
phyloToBranches
(
lvl
-
1
)
p
))
&
p
v_n
odes
%~
(
++
(
groupsToNodes
False
vb
(
getPeaksLabels
p
)
gs'
))
&
p
v_e
dges
%~
(
++
(
groupsToEdges
fl
PeriodEdge
gs'
))
&
p
v_e
dges
%~
(
++
(
groupsToEdges
Descendant
LevelEdge
gs
))
&
p
v_e
dges
%~
(
++
(
groupsToEdges
Ascendant
LevelEdge
gs'
))
where
--------------------------------------
gs
::
[
PhyloGroup
]
...
...
@@ -135,7 +135,7 @@ addChildNodes shouldDo lvl lvlMin vb fl p v =
-- | To transform a PhyloQuery into a PhyloView
toPhyloView
::
PhyloQueryView
->
Phylo
->
PhyloView
toPhyloView
q
p
=
processDisplay
(
q
^.
qv_display
)
$
processSort
(
q
^.
qv_sort
)
p
$
processSort
(
q
^.
qv_sort
)
p
$
processTaggers
(
q
^.
qv_taggers
)
p
$
processFilters
(
q
^.
qv_filters
)
p
$
processMetrics
(
q
^.
qv_metrics
)
p
...
...
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