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
e9693985
Commit
e9693985
authored
May 12, 2020
by
qlobbe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
horizon & ancestor ok
parent
3d505e99
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
27 deletions
+44
-27
AdaptativePhylo.hs
src/Gargantext/Viz/AdaptativePhylo.hs
+13
-2
PhyloExport.hs
src/Gargantext/Viz/Phylo/PhyloExport.hs
+24
-2
PhyloTools.hs
src/Gargantext/Viz/Phylo/PhyloTools.hs
+6
-0
SynchronicClustering.hs
src/Gargantext/Viz/Phylo/SynchronicClustering.hs
+1
-23
No files found.
src/Gargantext/Viz/AdaptativePhylo.hs
View file @
e9693985
...
@@ -354,6 +354,16 @@ data PhyloClique = PhyloClique
...
@@ -354,6 +354,16 @@ data PhyloClique = PhyloClique
}
deriving
(
Generic
,
NFData
,
Show
,
Eq
)
}
deriving
(
Generic
,
NFData
,
Show
,
Eq
)
------------------------
-- | Phylo Ancestor | --
------------------------
data
PhyloAncestor
=
PhyloAncestor
{
_phyloAncestor_id
::
Int
,
_phyloAncestor_ngrams
::
[
Int
]
,
_phyloAncestor_groups
::
[
PhyloGroupId
]
}
deriving
(
Generic
,
NFData
,
Show
,
Eq
)
----------------
----------------
-- | Export | --
-- | Export | --
----------------
----------------
...
@@ -396,6 +406,7 @@ data PhyloExport =
...
@@ -396,6 +406,7 @@ data PhyloExport =
PhyloExport
PhyloExport
{
_export_groups
::
[
PhyloGroup
]
{
_export_groups
::
[
PhyloGroup
]
,
_export_branches
::
[
PhyloBranch
]
,
_export_branches
::
[
PhyloBranch
]
,
_export_ancestors
::
[
PhyloAncestor
]
}
deriving
(
Generic
,
Show
)
}
deriving
(
Generic
,
Show
)
----------------
----------------
...
...
src/Gargantext/Viz/Phylo/PhyloExport.hs
View file @
e9693985
...
@@ -35,6 +35,7 @@ import Data.Text.Lazy (fromStrict, pack, unpack)
...
@@ -35,6 +35,7 @@ import Data.Text.Lazy (fromStrict, pack, unpack)
import
System.FilePath
import
System.FilePath
import
Debug.Trace
(
trace
)
import
Debug.Trace
(
trace
)
import
qualified
Data.Map
as
Map
import
qualified
Data.Text
as
Text
import
qualified
Data.Text
as
Text
import
qualified
Data.Vector
as
Vector
import
qualified
Data.Vector
as
Vector
import
qualified
Data.Text.Lazy
as
Lazy
import
qualified
Data.Text.Lazy
as
Lazy
...
@@ -476,6 +477,27 @@ processDynamics groups =
...
@@ -476,6 +477,27 @@ processDynamics groups =
$
(
g
^.
phylo_groupNgrams
)))
[]
groups
$
(
g
^.
phylo_groupNgrams
)))
[]
groups
-----------------
-- | horizon | --
-----------------
horizonToAncestors
::
Double
->
Phylo
->
[
PhyloAncestor
]
horizonToAncestors
delta
phylo
=
let
horizon
=
Map
.
toList
$
Map
.
filter
(
\
v
->
v
>
delta
)
$
phylo
^.
phylo_horizon
ct0
=
fromList
$
map
(
\
g
->
(
getGroupId
g
,
g
))
$
getGroupsFromLevelPeriods
1
(
take
1
(
getPeriodIds
phylo
))
phylo
aDelta
=
toRelatedComponents
(
elems
ct0
)
(
map
(
\
((
g
,
g'
),
v
)
->
((
ct0
!
g
,
ct0
!
g'
),
v
))
horizon
)
in
map
(
\
(
id
,
groups
)
->
toAncestor
id
groups
)
$
zip
[
1
..
]
aDelta
where
-- | note : possible bug if we sync clus more than once
-- | horizon is calculated at level 1, ancestors have to be related to the last level
toAncestor
::
Int
->
[
PhyloGroup
]
->
PhyloAncestor
toAncestor
id
groups
=
PhyloAncestor
id
(
foldl'
(
\
acc
g
->
union
acc
(
g
^.
phylo_groupNgrams
))
[]
groups
)
(
concat
$
map
(
\
g
->
map
fst
(
g
^.
phylo_groupLevelParents
))
groups
)
---------------------
---------------------
-- | phyloExport | --
-- | phyloExport | --
---------------------
---------------------
...
@@ -488,7 +510,7 @@ toPhyloExport phylo = exportToDot phylo
...
@@ -488,7 +510,7 @@ toPhyloExport phylo = exportToDot phylo
$
processMetrics
export
$
processMetrics
export
where
where
export
::
PhyloExport
export
::
PhyloExport
export
=
PhyloExport
groups
branches
export
=
PhyloExport
groups
branches
(
horizonToAncestors
0
phylo
)
--------------------------------------
--------------------------------------
branches
::
[
PhyloBranch
]
branches
::
[
PhyloBranch
]
branches
=
map
(
\
g
->
branches
=
map
(
\
g
->
...
...
src/Gargantext/Viz/Phylo/PhyloTools.hs
View file @
e9693985
...
@@ -398,6 +398,12 @@ relatedComponents graph = foldl' (\acc groups ->
...
@@ -398,6 +398,12 @@ relatedComponents graph = foldl' (\acc groups ->
let
acc'
=
partition
(
\
groups'
->
disjoint
(
Set
.
fromList
groups'
)
(
Set
.
fromList
groups
))
acc
let
acc'
=
partition
(
\
groups'
->
disjoint
(
Set
.
fromList
groups'
)
(
Set
.
fromList
groups
))
acc
in
(
fst
acc'
)
++
[
nub
$
concat
$
(
snd
acc'
)
++
[
groups
]])
[]
graph
in
(
fst
acc'
)
++
[
nub
$
concat
$
(
snd
acc'
)
++
[
groups
]])
[]
graph
toRelatedComponents
::
[
PhyloGroup
]
->
[((
PhyloGroup
,
PhyloGroup
),
Double
)]
->
[[
PhyloGroup
]]
toRelatedComponents
nodes
edges
=
let
ref
=
fromList
$
map
(
\
g
->
(
getGroupId
g
,
g
))
nodes
clusters
=
relatedComponents
$
((
map
(
\
((
g
,
g'
),
_
)
->
[
getGroupId
g
,
getGroupId
g'
])
edges
)
++
(
map
(
\
g
->
[
getGroupId
g
])
nodes
))
in
map
(
\
cluster
->
map
(
\
gId
->
ref
!
gId
)
cluster
)
clusters
traceSynchronyEnd
::
Phylo
->
Phylo
traceSynchronyEnd
::
Phylo
->
Phylo
traceSynchronyEnd
phylo
=
traceSynchronyEnd
phylo
=
...
...
src/Gargantext/Viz/Phylo/SynchronicClustering.hs
View file @
e9693985
...
@@ -22,7 +22,7 @@ import Gargantext.Viz.Phylo.TemporalMatching (weightedLogJaccard', filterDiago,
...
@@ -22,7 +22,7 @@ import Gargantext.Viz.Phylo.TemporalMatching (weightedLogJaccard', filterDiago,
import
Gargantext.Viz.Phylo.PhyloExport
(
processDynamics
)
import
Gargantext.Viz.Phylo.PhyloExport
(
processDynamics
)
import
Data.List
((
++
),
null
,
intersect
,
nub
,
concat
,
sort
,
sortOn
,
all
,
groupBy
,
group
,
maximum
)
import
Data.List
((
++
),
null
,
intersect
,
nub
,
concat
,
sort
,
sortOn
,
all
,
groupBy
,
group
,
maximum
)
import
Data.Map
(
Map
,
fromList
,
fromListWith
,
foldlWithKey
,
(
!
),
insert
,
empty
,
restrictKeys
,
elems
,
mapWithKey
,
member
,
keys
)
import
Data.Map
(
Map
,
fromList
,
fromListWith
,
foldlWithKey
,
(
!
),
insert
,
empty
,
restrictKeys
,
elems
,
mapWithKey
,
member
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Control.Lens
hiding
(
Level
)
import
Control.Lens
hiding
(
Level
)
...
@@ -177,14 +177,6 @@ groupsToEdges prox sync nbDocs diago groups =
...
@@ -177,14 +177,6 @@ groupsToEdges prox sync nbDocs diago groups =
(
g
^.
phylo_groupNgrams
)
(
g'
^.
phylo_groupNgrams
)))
edges
(
g
^.
phylo_groupNgrams
)
(
g'
^.
phylo_groupNgrams
)))
edges
_
->
undefined
_
->
undefined
toRelatedComponents
::
[
PhyloGroup
]
->
[((
PhyloGroup
,
PhyloGroup
),
Double
)]
->
[[
PhyloGroup
]]
toRelatedComponents
nodes
edges
=
let
ref
=
fromList
$
map
(
\
g
->
(
getGroupId
g
,
g
))
nodes
clusters
=
relatedComponents
$
((
map
(
\
((
g
,
g'
),
_
)
->
[
getGroupId
g
,
getGroupId
g'
])
edges
)
++
(
map
(
\
g
->
[
getGroupId
g
])
nodes
))
in
map
(
\
cluster
->
map
(
\
gId
->
ref
!
gId
)
cluster
)
clusters
toParentId
::
PhyloGroup
->
PhyloGroupId
toParentId
::
PhyloGroup
->
PhyloGroupId
toParentId
child
=
((
child
^.
phylo_groupPeriod
,
child
^.
phylo_groupLevel
+
1
),
child
^.
phylo_groupIndex
)
toParentId
child
=
((
child
^.
phylo_groupPeriod
,
child
^.
phylo_groupLevel
+
1
),
child
^.
phylo_groupIndex
)
...
@@ -234,20 +226,6 @@ synchronicClustering phylo =
...
@@ -234,20 +226,6 @@ synchronicClustering phylo =
in
toNextLevel'
phylo
$
concat
newBranches'
in
toNextLevel'
phylo
$
concat
newBranches'
-----------------
-- | horizon | --
-----------------
horizonToAncestors
::
Double
->
Phylo
->
Map
[
PhyloGroupId
]
[
Int
]
horizonToAncestors
thr
phylo
=
let
horizon
=
Map
.
filter
(
\
v
->
v
>=
thr
)
$
phylo
^.
phylo_horizon
groups
=
fromList
$
map
(
\
g
->
(
getGroupId
g
,
g
))
$
getGroupsFromLevelPeriods
1
(
take
1
(
getPeriodIds
phylo
))
phylo
graph
=
toRelatedComponents
(
elems
groups
)
(
map
(
\
((
k
,
k'
),
v
)
->
((
groups
!
k
,
groups
!
k'
),
v
))
$
Map
.
toList
horizon
)
-- in fromList $ map (\ancestors -> (map getGroupId ancestors, unionWith (++) $ map _phylo_groupNgrams ancestors)) graph
in
undefined
-- synchronicDistance :: Phylo -> Level -> String
-- synchronicDistance :: Phylo -> Level -> String
-- synchronicDistance phylo lvl =
-- synchronicDistance phylo lvl =
-- foldl' (\acc branch ->
-- foldl' (\acc branch ->
...
...
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