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
156
Issues
156
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
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
66f96f84
Commit
66f96f84
authored
Mar 06, 2023
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MERGE]
parent
54d94963
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
603 additions
and
559 deletions
+603
-559
gargantext.cabal
gargantext.cabal
+1
-1
Phylo.hs
src/Gargantext/Core/Viz/Phylo.hs
+11
-11
Example.hs
src/Gargantext/Core/Viz/Phylo/Example.hs
+29
-32
PhyloExport.hs
src/Gargantext/Core/Viz/Phylo/PhyloExport.hs
+16
-16
PhyloMaker.hs
src/Gargantext/Core/Viz/Phylo/PhyloMaker.hs
+75
-109
PhyloTools.hs
src/Gargantext/Core/Viz/Phylo/PhyloTools.hs
+24
-26
SynchronicClustering.hs
src/Gargantext/Core/Viz/Phylo/SynchronicClustering.hs
+48
-49
TemporalMatching.hs
src/Gargantext/Core/Viz/Phylo/TemporalMatching.hs
+399
-315
No files found.
gargantext.cabal
View file @
66f96f84
...
@@ -5,7 +5,7 @@ cabal-version: 1.12
...
@@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack
-- see: https://github.com/sol/hpack
name: gargantext
name: gargantext
version: 0.0.6.9.5
version:
0.0.6.9.5
synopsis: Search, map, share
synopsis: Search, map, share
description: Please see README.md
description: Please see README.md
category: Data
category: Data
...
...
src/Gargantext/Core/Viz/Phylo.hs
View file @
66f96f84
...
@@ -30,8 +30,7 @@ import Control.DeepSeq (NFData)
...
@@ -30,8 +30,7 @@ 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.Strict
(
Map
)
import
Data.Map
(
Map
)
import
Data.Set
(
Set
)
import
Data.Swagger
import
Data.Swagger
import
Data.Text
(
Text
,
pack
)
import
Data.Text
(
Text
,
pack
)
import
Data.Vector
(
Vector
)
import
Data.Vector
(
Vector
)
...
@@ -64,9 +63,9 @@ instance ToSchema ListParser
...
@@ -64,9 +63,9 @@ instance ToSchema ListParser
data
SeaElevation
=
data
SeaElevation
=
Constante
Constante
{
_cons_start
::
Double
{
_cons_start
::
Double
,
_cons_
gap
::
Double
}
,
_cons_
step
::
Double
}
|
Adaptative
|
Adaptative
{
_adap_
steps
::
Double
}
{
_adap_
granularity
::
Double
}
deriving
(
Show
,
Generic
,
Eq
)
deriving
(
Show
,
Generic
,
Eq
)
instance
ToSchema
SeaElevation
instance
ToSchema
SeaElevation
...
@@ -78,8 +77,8 @@ data Proximity =
...
@@ -78,8 +77,8 @@ data Proximity =
|
WeightedLogSim
|
WeightedLogSim
{
_wls_sensibility
::
Double
{
_wls_sensibility
::
Double
,
_wls_minSharedNgrams
::
Int
}
,
_wls_minSharedNgrams
::
Int
}
|
Hamming
|
Hamming
{
_hmg_sensibility
::
Double
{
_hmg_sensibility
::
Double
,
_hmg_minSharedNgrams
::
Int
}
,
_hmg_minSharedNgrams
::
Int
}
deriving
(
Show
,
Generic
,
Eq
)
deriving
(
Show
,
Generic
,
Eq
)
...
@@ -205,7 +204,7 @@ data PhyloSubConfig =
...
@@ -205,7 +204,7 @@ data PhyloSubConfig =
subConfig2config
::
PhyloSubConfig
->
PhyloConfig
subConfig2config
::
PhyloSubConfig
->
PhyloConfig
subConfig2config
subConfig
=
defaultConfig
{
phyloProximity
=
WeightedLogJaccard
(
_sc_phyloProximity
subConfig
)
1
subConfig2config
subConfig
=
defaultConfig
{
phyloProximity
=
WeightedLogJaccard
(
_sc_phyloProximity
subConfig
)
1
,
phyloSynchrony
=
ByProximityThreshold
(
_sc_phyloSynchrony
subConfig
)
0
AllBranches
MergeAllGroups
,
phyloSynchrony
=
ByProximityThreshold
(
_sc_phyloSynchrony
subConfig
)
0
AllBranches
MergeAllGroups
,
phyloQuality
=
Quality
(
_sc_phyloQuality
subConfig
)
1
,
phyloQuality
=
Quality
(
_sc_phyloQuality
subConfig
)
1
,
timeUnit
=
_sc_timeUnit
subConfig
,
timeUnit
=
_sc_timeUnit
subConfig
...
@@ -307,8 +306,8 @@ instance ToSchema Software where
...
@@ -307,8 +306,8 @@ instance ToSchema Software where
defaultSoftware
::
Software
defaultSoftware
::
Software
defaultSoftware
=
defaultSoftware
=
Software
{
_software_name
=
pack
"Gargan
T
ext"
Software
{
_software_name
=
pack
"Gargan
t
ext"
,
_software_version
=
pack
"v
5
"
}
,
_software_version
=
pack
"v
4
"
}
-- | Global parameters of a Phylo
-- | Global parameters of a Phylo
...
@@ -325,7 +324,7 @@ instance ToSchema PhyloParam where
...
@@ -325,7 +324,7 @@ instance ToSchema PhyloParam where
defaultPhyloParam
::
PhyloParam
defaultPhyloParam
::
PhyloParam
defaultPhyloParam
=
defaultPhyloParam
=
PhyloParam
{
_phyloParam_version
=
pack
"v
3
"
PhyloParam
{
_phyloParam_version
=
pack
"v
2.adaptative
"
,
_phyloParam_software
=
defaultSoftware
,
_phyloParam_software
=
defaultSoftware
,
_phyloParam_config
=
defaultConfig
}
,
_phyloParam_config
=
defaultConfig
}
...
@@ -410,7 +409,8 @@ data Phylo =
...
@@ -410,7 +409,8 @@ data Phylo =
,
_phylo_timeDocs
::
!
(
Map
Date
Double
)
,
_phylo_timeDocs
::
!
(
Map
Date
Double
)
,
_phylo_termFreq
::
!
(
Map
Int
Double
)
,
_phylo_termFreq
::
!
(
Map
Int
Double
)
,
_phylo_lastTermFreq
::
!
(
Map
Int
Double
)
,
_phylo_lastTermFreq
::
!
(
Map
Int
Double
)
,
_phylo_diaSimScan
::
Set
Double
,
_phylo_horizon
::
!
(
Map
(
PhyloGroupId
,
PhyloGroupId
)
Double
)
,
_phylo_groupsProxi
::
!
(
Map
(
PhyloGroupId
,
PhyloGroupId
)
Double
)
,
_phylo_param
::
PhyloParam
,
_phylo_param
::
PhyloParam
,
_phylo_periods
::
Map
Period
PhyloPeriod
,
_phylo_periods
::
Map
Period
PhyloPeriod
,
_phylo_quality
::
Double
,
_phylo_quality
::
Double
...
...
src/Gargantext/Core/Viz/Phylo/Example.hs
View file @
66f96f84
This diff is collapsed.
Click to expand it.
src/Gargantext/Core/Viz/Phylo/PhyloExport.hs
View file @
66f96f84
...
@@ -19,7 +19,7 @@ import Data.GraphViz.Attributes.Complete hiding (EdgeType, Order)
...
@@ -19,7 +19,7 @@ import Data.GraphViz.Attributes.Complete hiding (EdgeType, Order)
import
Data.GraphViz.Types.Generalised
(
DotGraph
)
import
Data.GraphViz.Types.Generalised
(
DotGraph
)
import
Data.GraphViz.Types.Monadic
import
Data.GraphViz.Types.Monadic
import
Data.List
((
++
),
sort
,
nub
,
null
,
concat
,
sortOn
,
groupBy
,
union
,
(
\\
),
(
!!
),
init
,
partition
,
notElem
,
unwords
,
nubBy
,
inits
,
elemIndex
)
import
Data.List
((
++
),
sort
,
nub
,
null
,
concat
,
sortOn
,
groupBy
,
union
,
(
\\
),
(
!!
),
init
,
partition
,
notElem
,
unwords
,
nubBy
,
inits
,
elemIndex
)
import
Data.Map
.Strict
(
Map
,
fromList
,
empty
,
fromListWith
,
insert
,
(
!
),
elems
,
unionWith
,
findWithDefault
,
toList
,
member
)
import
Data.Map
(
Map
,
fromList
,
empty
,
fromListWith
,
insert
,
(
!
),
elems
,
unionWith
,
findWithDefault
,
toList
,
member
)
import
Data.Text.Lazy
(
fromStrict
,
pack
,
unpack
)
import
Data.Text.Lazy
(
fromStrict
,
pack
,
unpack
)
import
Data.Vector
(
Vector
)
import
Data.Vector
(
Vector
)
import
Debug.Trace
(
trace
)
import
Debug.Trace
(
trace
)
...
@@ -375,7 +375,7 @@ processSort sort' elev export = case sort' of
...
@@ -375,7 +375,7 @@ processSort sort' elev export = case sort' of
ByBirthDate
o
->
sortByBirthDate
o
export
ByBirthDate
o
->
sortByBirthDate
o
export
ByHierarchy
_
->
case
elev
of
ByHierarchy
_
->
case
elev
of
Constante
s
s'
->
export
&
export_branches
.~
(
branchToIso'
s
s'
$
sortByHierarchy
0
(
export
^.
export_branches
))
Constante
s
s'
->
export
&
export_branches
.~
(
branchToIso'
s
s'
$
sortByHierarchy
0
(
export
^.
export_branches
))
Adaptative
_
->
export
&
export_branches
.~
(
branchToIso
$
sortByHierarchy
0
(
export
^.
export_branches
))
Adaptative
_
->
export
&
export_branches
.~
(
branchToIso
$
sortByHierarchy
0
(
export
^.
export_branches
))
-----------------
-----------------
-- | Metrics | --
-- | Metrics | --
...
@@ -546,10 +546,9 @@ processLabels labels foundations freq export =
...
@@ -546,10 +546,9 @@ processLabels labels foundations freq export =
-- | Dynamics | --
-- | Dynamics | --
------------------
------------------
-- utiliser & creer une Map FdtId [PhyloGroup]
-- n = index of the current term
toDynamics
::
Int
->
[
PhyloGroup
]
->
PhyloGroup
->
Map
Int
(
Date
,
Date
)
->
Double
toDynamics
::
FdtId
->
[
PhyloGroup
]
->
PhyloGroup
->
Map
FdtId
(
Date
,
Date
)
->
Double
toDynamics
n
parents
g
m
=
toDynamics
n
elders
g
m
=
let
prd
=
g
^.
phylo_groupPeriod
let
prd
=
g
^.
phylo_groupPeriod
end
=
last'
"dynamics"
(
sort
$
map
snd
$
elems
m
)
end
=
last'
"dynamics"
(
sort
$
map
snd
$
elems
m
)
in
if
(((
snd
prd
)
==
(
snd
$
m
!
n
))
&&
(
snd
prd
/=
end
))
in
if
(((
snd
prd
)
==
(
snd
$
m
!
n
))
&&
(
snd
prd
/=
end
))
...
@@ -565,18 +564,18 @@ toDynamics n elders g m =
...
@@ -565,18 +564,18 @@ toDynamics n elders g m =
where
where
--------------------------------------
--------------------------------------
isNew
::
Bool
isNew
::
Bool
isNew
=
not
$
elem
n
$
concat
$
map
_phylo_groupNgrams
elders
isNew
=
not
$
elem
n
$
concat
$
map
_phylo_groupNgrams
parents
type
FdtId
=
Int
processDynamics
::
[
PhyloGroup
]
->
[
PhyloGroup
]
processDynamics
::
[
PhyloGroup
]
->
[
PhyloGroup
]
processDynamics
groups
=
processDynamics
groups
=
map
(
\
g
->
map
(
\
g
->
let
elder
s
=
filter
(
\
g'
->
(
g
^.
phylo_groupBranchId
==
g'
^.
phylo_groupBranchId
)
let
parent
s
=
filter
(
\
g'
->
(
g
^.
phylo_groupBranchId
==
g'
^.
phylo_groupBranchId
)
&&
((
fst
$
g
^.
phylo_groupPeriod
)
>
(
fst
$
g'
^.
phylo_groupPeriod
)))
groups
&&
((
fst
$
g
^.
phylo_groupPeriod
)
>
(
fst
$
g'
^.
phylo_groupPeriod
)))
groups
in
g
&
phylo_groupMeta
%~
insert
"dynamics"
(
map
(
\
n
->
toDynamics
n
elder
s
g
mapNgrams
)
$
g
^.
phylo_groupNgrams
)
)
groups
in
g
&
phylo_groupMeta
%~
insert
"dynamics"
(
map
(
\
n
->
toDynamics
n
parent
s
g
mapNgrams
)
$
g
^.
phylo_groupNgrams
)
)
groups
where
where
--------------------------------------
--------------------------------------
mapNgrams
::
Map
FdtId
(
Date
,
Date
)
mapNgrams
::
Map
Int
(
Date
,
Date
)
mapNgrams
=
map
(
\
dates
->
mapNgrams
=
map
(
\
dates
->
let
dates'
=
sort
dates
let
dates'
=
sort
dates
in
(
head'
"dynamics"
dates'
,
last'
"dynamics"
dates'
))
in
(
head'
"dynamics"
dates'
,
last'
"dynamics"
dates'
))
...
@@ -622,7 +621,7 @@ toHorizon phylo =
...
@@ -622,7 +621,7 @@ toHorizon phylo =
$
concat
$
concat
$
tracePhyloAncestors
newGroups
)
phylo
$
tracePhyloAncestors
newGroups
)
phylo
reBranched
=
fromList
$
map
(
\
g
->
(
getGroupId
g
,
g
))
$
concat
reBranched
=
fromList
$
map
(
\
g
->
(
getGroupId
g
,
g
))
$
concat
$
groupsToBranches'
$
fromList
$
map
(
\
g
->
(
getGroupId
g
,
g
))
$
getGroupsFrom
Scale
scale
phyloAncestor
$
groupsToBranches'
$
fromList
$
map
(
\
g
->
(
getGroupId
g
,
g
))
$
getGroupsFrom
Level
scale
phyloAncestor
in
updatePhyloGroups
scale
reBranched
phylo
in
updatePhyloGroups
scale
reBranched
phylo
where
where
-- | 1) for each periods
-- | 1) for each periods
...
@@ -637,7 +636,7 @@ toHorizon phylo =
...
@@ -637,7 +636,7 @@ toHorizon phylo =
-- | 2) find ancestors between groups without parents
-- | 2) find ancestors between groups without parents
mapGroups
::
[[
PhyloGroup
]]
mapGroups
::
[[
PhyloGroup
]]
mapGroups
=
map
(
\
prd
->
mapGroups
=
map
(
\
prd
->
let
groups
=
getGroupsFrom
Scale
Periods
scale
[
prd
]
phylo
let
groups
=
getGroupsFrom
Level
Periods
scale
[
prd
]
phylo
childs
=
getPreviousChildIds
scale
frame
prd
periods
phylo
childs
=
getPreviousChildIds
scale
frame
prd
periods
phylo
-- maybe add a better filter for non isolated ancestors
-- maybe add a better filter for non isolated ancestors
heads
=
filter
(
\
g
->
(
not
.
null
)
$
(
g
^.
phylo_groupPeriodChilds
))
heads
=
filter
(
\
g
->
(
not
.
null
)
$
(
g
^.
phylo_groupPeriodChilds
))
...
@@ -661,7 +660,7 @@ toHorizon phylo =
...
@@ -661,7 +660,7 @@ toHorizon phylo =
getPreviousChildIds
::
Scale
->
Int
->
Period
->
[
Period
]
->
Phylo
->
[
PhyloGroupId
]
getPreviousChildIds
::
Scale
->
Int
->
Period
->
[
Period
]
->
Phylo
->
[
PhyloGroupId
]
getPreviousChildIds
lvl
frame
curr
prds
phylo
=
getPreviousChildIds
lvl
frame
curr
prds
phylo
=
concat
$
map
((
map
fst
)
.
_phylo_groupPeriodChilds
)
concat
$
map
((
map
fst
)
.
_phylo_groupPeriodChilds
)
$
getGroupsFrom
Scale
Periods
lvl
(
getNextPeriods
ToParents
frame
curr
prds
)
phylo
$
getGroupsFrom
Level
Periods
lvl
(
getNextPeriods
ToParents
frame
curr
prds
)
phylo
---------------------
---------------------
-- | phyloExport | --
-- | phyloExport | --
...
@@ -696,10 +695,10 @@ toPhyloExport phylo = exportToDot phylo
...
@@ -696,10 +695,10 @@ toPhyloExport phylo = exportToDot phylo
--------------------------------------
--------------------------------------
groups
::
[
PhyloGroup
]
groups
::
[
PhyloGroup
]
groups
=
traceExportGroups
groups
=
traceExportGroups
-- necessaire ?
$
processDynamics
$
processDynamics
$
getGroupsFrom
Scale
(
phyloScale
$
getConfig
phylo
)
$
getGroupsFrom
Level
(
phyloScale
$
getConfig
phylo
)
$
tracePhyloInfo
phylo
$
tracePhyloInfo
phylo
-- \$ toHorizon phylo
traceExportBranches
::
[
PhyloBranch
]
->
[
PhyloBranch
]
traceExportBranches
::
[
PhyloBranch
]
->
[
PhyloBranch
]
...
@@ -722,3 +721,4 @@ traceExportGroups groups = trace ("\n" <> "-- | Export "
...
@@ -722,3 +721,4 @@ traceExportGroups groups = trace ("\n" <> "-- | Export "
<>
show
(
length
groups
)
<>
" groups and "
<>
show
(
length
groups
)
<>
" groups and "
<>
show
(
length
$
nub
$
concat
$
map
(
\
g
->
g
^.
phylo_groupNgrams
)
groups
)
<>
" terms"
<>
show
(
length
$
nub
$
concat
$
map
(
\
g
->
g
^.
phylo_groupNgrams
)
groups
)
<>
" terms"
)
groups
)
groups
src/Gargantext/Core/Viz/Phylo/PhyloMaker.hs
View file @
66f96f84
This diff is collapsed.
Click to expand it.
src/Gargantext/Core/Viz/Phylo/PhyloTools.hs
View file @
66f96f84
...
@@ -14,7 +14,7 @@ module Gargantext.Core.Viz.Phylo.PhyloTools where
...
@@ -14,7 +14,7 @@ module Gargantext.Core.Viz.Phylo.PhyloTools where
import
Control.Lens
hiding
(
Level
)
import
Control.Lens
hiding
(
Level
)
import
Data.List
(
sort
,
concat
,
null
,
union
,
(
++
),
tails
,
sortOn
,
nub
,
init
,
tail
,
partition
,
tails
,
nubBy
,
group
,
notElem
)
import
Data.List
(
sort
,
concat
,
null
,
union
,
(
++
),
tails
,
sortOn
,
nub
,
init
,
tail
,
partition
,
tails
,
nubBy
,
group
,
notElem
)
import
Data.Map
.Strict
(
Map
,
elems
,
fromList
,
unionWith
,
keys
,
member
,
(
!
),
filterWithKey
,
fromListWith
,
empty
,
restrictKeys
)
import
Data.Map
(
Map
,
elems
,
fromList
,
unionWith
,
keys
,
member
,
(
!
),
filterWithKey
,
fromListWith
,
empty
,
restrictKeys
)
import
Data.Set
(
Set
,
disjoint
)
import
Data.Set
(
Set
,
disjoint
)
import
Data.String
(
String
)
import
Data.String
(
String
)
import
Data.Text
(
Text
,
unpack
)
import
Data.Text
(
Text
,
unpack
)
...
@@ -25,6 +25,7 @@ import Gargantext.Prelude
...
@@ -25,6 +25,7 @@ import Gargantext.Prelude
import
Prelude
(
floor
,
read
)
import
Prelude
(
floor
,
read
)
import
Text.Printf
import
Text.Printf
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
Text
import
qualified
Data.Text
as
Text
import
qualified
Data.Vector
as
Vector
import
qualified
Data.Vector
as
Vector
...
@@ -139,7 +140,6 @@ periodsToYears periods = (Set.fromList . sort . concat)
...
@@ -139,7 +140,6 @@ periodsToYears periods = (Set.fromList . sort . concat)
findBounds
::
[
Date
]
->
(
Date
,
Date
)
findBounds
::
[
Date
]
->
(
Date
,
Date
)
findBounds
[]
=
panic
"[G.C.V.P.PhyloTools] empty dates for find bounds"
findBounds
dates
=
findBounds
dates
=
let
dates'
=
sort
dates
let
dates'
=
sort
dates
in
(
head'
"findBounds"
dates'
,
last'
"findBounds"
dates'
)
in
(
head'
"findBounds"
dates'
,
last'
"findBounds"
dates'
)
...
@@ -387,10 +387,10 @@ getLevelParentId :: PhyloGroup -> PhyloGroupId
...
@@ -387,10 +387,10 @@ getLevelParentId :: PhyloGroup -> PhyloGroupId
getLevelParentId
g
=
fst
$
head'
"getLevelParentId"
$
g
^.
phylo_groupScaleParents
getLevelParentId
g
=
fst
$
head'
"getLevelParentId"
$
g
^.
phylo_groupScaleParents
getLastLevel
::
Phylo
->
Scale
getLastLevel
::
Phylo
->
Scale
getLastLevel
phylo
=
last'
"lastLevel"
$
get
Scale
s
phylo
getLastLevel
phylo
=
last'
"lastLevel"
$
get
Level
s
phylo
get
Scale
s
::
Phylo
->
[
Scale
]
get
Level
s
::
Phylo
->
[
Scale
]
get
Scale
s
phylo
=
nub
get
Level
s
phylo
=
nub
$
map
snd
$
map
snd
$
keys
$
view
(
phylo_periods
$
keys
$
view
(
phylo_periods
.
traverse
.
traverse
...
@@ -408,7 +408,7 @@ getPhyloSeaRiseStart phylo = case (getSeaElevation phylo) of
...
@@ -408,7 +408,7 @@ getPhyloSeaRiseStart phylo = case (getSeaElevation phylo) of
getPhyloSeaRiseSteps
::
Phylo
->
Double
getPhyloSeaRiseSteps
::
Phylo
->
Double
getPhyloSeaRiseSteps
phylo
=
case
(
getSeaElevation
phylo
)
of
getPhyloSeaRiseSteps
phylo
=
case
(
getSeaElevation
phylo
)
of
Constante
_
s
->
s
Constante
_
s
->
s
Adaptative
s
->
s
Adaptative
s
->
s
getConfig
::
Phylo
->
PhyloConfig
getConfig
::
Phylo
->
PhyloConfig
...
@@ -431,16 +431,14 @@ getRoots phylo = (phylo ^. phylo_foundations) ^. foundations_roots
...
@@ -431,16 +431,14 @@ getRoots phylo = (phylo ^. phylo_foundations) ^. foundations_roots
getSources
::
Phylo
->
Vector
Text
getSources
::
Phylo
->
Vector
Text
getSources
phylo
=
_sources
(
phylo
^.
phylo_sources
)
getSources
phylo
=
_sources
(
phylo
^.
phylo_sources
)
phyloToLastBranches
::
Phylo
->
[[
PhyloGroup
]]
-- get the groups distributed by branches at the last scale
phyloToLastBranches
phylo
=
elems
phyloLastScale
::
Phylo
->
[[
PhyloGroup
]]
phyloLastScale
phylo
=
elems
$
fromListWith
(
++
)
$
fromListWith
(
++
)
$
map
(
\
g
->
(
g
^.
phylo_groupBranchId
,
[
g
]))
$
map
(
\
g
->
(
g
^.
phylo_groupBranchId
,
[
g
]))
$
getGroupsFrom
Scale
(
last'
"byBranches"
$
getScale
s
phylo
)
phylo
$
getGroupsFrom
Level
(
last'
"byBranches"
$
getLevel
s
phylo
)
phylo
getGroupsFrom
Scale
::
Scale
->
Phylo
->
[
PhyloGroup
]
getGroupsFrom
Level
::
Scale
->
Phylo
->
[
PhyloGroup
]
getGroupsFrom
Scale
lvl
phylo
=
getGroupsFrom
Level
lvl
phylo
=
elems
$
view
(
phylo_periods
elems
$
view
(
phylo_periods
.
traverse
.
traverse
.
phylo_periodScales
.
phylo_periodScales
...
@@ -449,8 +447,8 @@ getGroupsFromScale lvl phylo =
...
@@ -449,8 +447,8 @@ getGroupsFromScale lvl phylo =
.
phylo_scaleGroups
)
phylo
.
phylo_scaleGroups
)
phylo
getGroupsFrom
Scale
Periods
::
Scale
->
[
Period
]
->
Phylo
->
[
PhyloGroup
]
getGroupsFrom
Level
Periods
::
Scale
->
[
Period
]
->
Phylo
->
[
PhyloGroup
]
getGroupsFrom
Scale
Periods
lvl
periods
phylo
=
getGroupsFrom
Level
Periods
lvl
periods
phylo
=
elems
$
view
(
phylo_periods
elems
$
view
(
phylo_periods
.
traverse
.
traverse
.
filtered
(
\
phyloPrd
->
elem
(
phyloPrd
^.
phylo_periodPeriod
)
periods
)
.
filtered
(
\
phyloPrd
->
elem
(
phyloPrd
^.
phylo_periodPeriod
)
periods
)
...
@@ -496,14 +494,14 @@ updatePeriods periods' phylo =
...
@@ -496,14 +494,14 @@ updatePeriods periods' phylo =
)
phylo
)
phylo
updateQuality
::
Double
->
Phylo
->
Phylo
updateQuality
::
Double
->
Phylo
->
Phylo
updateQuality
quality
phylo
=
phylo
{
_phylo_quality
=
quality
}
updateQuality
quality
phylo
=
phylo
{
_phylo_quality
=
quality
}
traceToPhylo
::
Scale
->
Phylo
->
Phylo
traceToPhylo
::
Scale
->
Phylo
->
Phylo
traceToPhylo
lvl
phylo
=
traceToPhylo
lvl
phylo
=
trace
(
"
\n
"
<>
"-- | End of phylo making at level "
<>
show
(
lvl
)
<>
" with "
trace
(
"
\n
"
<>
"-- | End of phylo making at level "
<>
show
(
lvl
)
<>
" with "
<>
show
(
length
$
getGroupsFrom
Scale
lvl
phylo
)
<>
" groups and "
<>
show
(
length
$
getGroupsFrom
Level
lvl
phylo
)
<>
" groups and "
<>
show
(
length
$
nub
$
map
_phylo_groupBranchId
$
getGroupsFrom
Scale
lvl
phylo
)
<>
" branches"
<>
"
\n
"
)
phylo
<>
show
(
length
$
nub
$
map
_phylo_groupBranchId
$
getGroupsFrom
Level
lvl
phylo
)
<>
" branches"
<>
"
\n
"
)
phylo
--------------------
--------------------
-- | Clustering | --
-- | Clustering | --
...
@@ -566,15 +564,15 @@ toRelatedComponents nodes edges =
...
@@ -566,15 +564,15 @@ toRelatedComponents nodes edges =
traceSynchronyEnd
::
Phylo
->
Phylo
traceSynchronyEnd
::
Phylo
->
Phylo
traceSynchronyEnd
phylo
=
traceSynchronyEnd
phylo
=
trace
(
"-- | End synchronic clustering at level "
<>
show
(
getLastLevel
phylo
)
trace
(
"-- | End synchronic clustering at level "
<>
show
(
getLastLevel
phylo
)
<>
" with "
<>
show
(
length
$
getGroupsFrom
Scale
(
getLastLevel
phylo
)
phylo
)
<>
" groups"
<>
" with "
<>
show
(
length
$
getGroupsFrom
Level
(
getLastLevel
phylo
)
phylo
)
<>
" groups"
<>
" and "
<>
show
(
length
$
nub
$
map
_phylo_groupBranchId
$
getGroupsFrom
Scale
(
getLastLevel
phylo
)
phylo
)
<>
" branches"
<>
" and "
<>
show
(
length
$
nub
$
map
_phylo_groupBranchId
$
getGroupsFrom
Level
(
getLastLevel
phylo
)
phylo
)
<>
" branches"
<>
"
\n
"
)
phylo
<>
"
\n
"
)
phylo
traceSynchronyStart
::
Phylo
->
Phylo
traceSynchronyStart
::
Phylo
->
Phylo
traceSynchronyStart
phylo
=
traceSynchronyStart
phylo
=
trace
(
"
\n
"
<>
"-- | Start synchronic clustering at level "
<>
show
(
getLastLevel
phylo
)
trace
(
"
\n
"
<>
"-- | Start synchronic clustering at level "
<>
show
(
getLastLevel
phylo
)
<>
" with "
<>
show
(
length
$
getGroupsFrom
Scale
(
getLastLevel
phylo
)
phylo
)
<>
" groups"
<>
" with "
<>
show
(
length
$
getGroupsFrom
Level
(
getLastLevel
phylo
)
phylo
)
<>
" groups"
<>
" and "
<>
show
(
length
$
nub
$
map
_phylo_groupBranchId
$
getGroupsFrom
Scale
(
getLastLevel
phylo
)
phylo
)
<>
" branches"
<>
" and "
<>
show
(
length
$
nub
$
map
_phylo_groupBranchId
$
getGroupsFrom
Level
(
getLastLevel
phylo
)
phylo
)
<>
" branches"
<>
"
\n
"
)
phylo
<>
"
\n
"
)
phylo
...
@@ -592,7 +590,7 @@ getMinSharedNgrams :: Proximity -> Int
...
@@ -592,7 +590,7 @@ getMinSharedNgrams :: Proximity -> Int
getMinSharedNgrams
proxi
=
case
proxi
of
getMinSharedNgrams
proxi
=
case
proxi
of
WeightedLogJaccard
_
m
->
m
WeightedLogJaccard
_
m
->
m
WeightedLogSim
_
m
->
m
WeightedLogSim
_
m
->
m
Hamming
_
_
->
undefined
Hamming
_
_
->
undefined
----------------
----------------
-- | Branch | --
-- | Branch | --
...
@@ -661,6 +659,6 @@ traceTemporalMatching groups =
...
@@ -661,6 +659,6 @@ traceTemporalMatching groups =
trace
(
"
\n
"
<>
"-- | Start temporal matching for "
<>
show
(
length
groups
)
<>
" groups"
<>
"
\n
"
)
groups
trace
(
"
\n
"
<>
"-- | Start temporal matching for "
<>
show
(
length
groups
)
<>
" groups"
<>
"
\n
"
)
groups
traceGroupsProxi
::
[
Double
]
->
[
Double
]
traceGroupsProxi
::
Map
(
PhyloGroupId
,
PhyloGroupId
)
Double
->
Map
(
PhyloGroupId
,
PhyloGroupId
)
Double
traceGroupsProxi
l
=
traceGroupsProxi
m
=
trace
(
"
\n
"
<>
"-- | "
<>
show
(
List
.
length
l
)
<>
" computed pairs of groups proximity"
<>
"
\n
"
)
l
trace
(
"
\n
"
<>
"-- | "
<>
show
(
Map
.
size
m
)
<>
" computed pairs of groups proximity"
<>
"
\n
"
)
m
src/Gargantext/Core/Viz/Phylo/SynchronicClustering.hs
View file @
66f96f84
This diff is collapsed.
Click to expand it.
src/Gargantext/Core/Viz/Phylo/TemporalMatching.hs
View file @
66f96f84
This diff is collapsed.
Click to expand it.
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