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
fab0dec2
Commit
fab0dec2
authored
Mar 05, 2019
by
Quentin Lobbé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sub cooc matrix to each PhyloGroup of level 1 and more
parent
18aba26a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
Phylo.hs
src/Gargantext/Viz/Phylo.hs
+1
-0
Example.hs
src/Gargantext/Viz/Phylo/Example.hs
+30
-10
Tools.hs
src/Gargantext/Viz/Phylo/Tools.hs
+1
-0
No files found.
src/Gargantext/Viz/Phylo.hs
View file @
fab0dec2
...
...
@@ -122,6 +122,7 @@ data PhyloGroup =
,
_phylo_groupLabel
::
Text
,
_phylo_groupNgrams
::
[
Int
]
,
_phylo_groupQuality
::
Map
Text
Double
,
_phylo_groupCooc
::
Map
(
Int
,
Int
)
Double
,
_phylo_groupPeriodParents
::
[
Pointer
]
,
_phylo_groupPeriodChilds
::
[
Pointer
]
...
...
src/Gargantext/Viz/Phylo/Example.hs
View file @
fab0dec2
...
...
@@ -31,7 +31,7 @@ import Control.Lens hiding (makeLenses, both, Level)
import
Data.Bool
(
Bool
,
not
)
import
Data.List
(
concat
,
union
,
intersect
,
tails
,
tail
,
head
,
last
,
null
,
zip
,
sort
,
length
,
any
,
(
++
),
(
!!
),
nub
,
sortOn
,
reverse
,
splitAt
,
take
)
import
Data.Map
(
Map
,
elems
,
member
,
adjust
,
singleton
,
(
!
),
keys
,
restrictKeys
,
map
WithKey
)
import
Data.Map
(
Map
,
elems
,
member
,
adjust
,
singleton
,
empty
,
(
!
),
keys
,
restrictKeys
,
mapWithKey
,
filter
WithKey
)
import
Data.Semigroup
(
Semigroup
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
,
unwords
,
toLower
,
words
)
...
...
@@ -82,8 +82,8 @@ getProximity p group group' = case p of
-- | To get the next or previous PhyloPeriod based on a given PhyloPeriodId
getNextPeriods
::
PairTo
->
PhyloPeriodId
->
[
PhyloPeriodId
]
->
[
PhyloPeriodId
]
getNextPeriods
to
id
l
=
case
to
of
Childs
->
(
tail
.
snd
)
next
Parents
->
(
reverse
.
fst
)
next
Childs
->
unNested
id
((
tail
.
snd
)
next
)
Parents
->
unNested
id
((
reverse
.
fst
)
next
)
_
->
panic
(
"[ERR][Viz.Phylo.Example.getNextPeriods] PairTo type not defined"
)
where
--------------------------------------
...
...
@@ -95,6 +95,17 @@ getNextPeriods to id l = case to of
Nothing
->
panic
(
"[ERR][Viz.Phylo.Example.getNextPeriods] PhyloPeriodId not defined"
)
Just
i
->
i
--------------------------------------
-- | To have an non-overlapping next period
unNested
::
PhyloPeriodId
->
[
PhyloPeriodId
]
->
[
PhyloPeriodId
]
unNested
x
l
|
null
l
=
[]
|
nested
(
fst
$
head
l
)
x
=
unNested
x
(
tail
l
)
|
nested
(
snd
$
head
l
)
x
=
unNested
x
(
tail
l
)
|
otherwise
=
l
--------------------------------------
nested
::
Date
->
PhyloPeriodId
->
Bool
nested
d
prd
=
d
>=
fst
prd
&&
d
<=
snd
prd
--------------------------------------
-- | To find the best set (max = 2) of Childs/Parents candidates based on a given Proximity mesure until a maximum depth (max = Period + 5 units )
...
...
@@ -217,15 +228,24 @@ phyloCooc = fisToCooc phyloFisFiltered phyloLinked_0_1
-- | To Cliques into Groups
cliqueToGroup
::
PhyloPeriodId
->
Int
->
Int
->
Ngrams
->
(
Clique
,
Support
)
->
Phylo
->
PhyloGroup
cliqueToGroup
period
lvl
idx
label
fis
p
=
PhyloGroup
((
period
,
lvl
),
idx
)
cliqueToGroup
::
PhyloPeriodId
->
Int
->
Int
->
Ngrams
->
(
Clique
,
Support
)
->
Map
(
Date
,
Date
)
Fis
->
Phylo
->
PhyloGroup
cliqueToGroup
period
lvl
idx
label
fis
m
p
=
PhyloGroup
((
period
,
lvl
),
idx
)
label
(
sort
$
map
(
\
x
->
ngramsToIdx
x
p
)
$
Set
.
toList
$
fst
fis
)
ngrams
(
singleton
"support"
(
fromIntegral
$
snd
fis
))
cooc
[]
[]
[]
[]
where
--------------------------------------
ngrams
::
[
Int
]
ngrams
=
sort
$
map
(
\
x
->
ngramsToIdx
x
p
)
$
Set
.
toList
$
fst
fis
--------------------------------------
cooc
::
Map
(
Int
,
Int
)
Double
cooc
=
filterWithKey
(
\
k
_
->
elem
(
fst
k
)
ngrams
&&
elem
(
snd
k
)
ngrams
)
$
fisToCooc
(
restrictKeys
m
$
Set
.
fromList
[
period
])
p
--------------------------------------
-- | To transform Fis into PhyloLevels
...
...
@@ -236,7 +256,7 @@ fisToPhyloLevel m p = over (phylo_periods . traverse)
fisList
=
zip
[
1
..
]
(
Map
.
toList
(
m
!
periodId
))
in
over
(
phylo_periodLevels
)
(
\
levels
->
let
groups
=
map
(
\
fis
->
cliqueToGroup
periodId
1
(
fst
fis
)
""
(
snd
fis
)
p
)
fisList
let
groups
=
map
(
\
fis
->
cliqueToGroup
periodId
1
(
fst
fis
)
""
(
snd
fis
)
m
p
)
fisList
in
levels
++
[
PhyloLevel
(
periodId
,
1
)
groups
]
)
period
)
p
...
...
src/Gargantext/Viz/Phylo/Tools.hs
View file @
fab0dec2
...
...
@@ -213,6 +213,7 @@ initGroup ngrams lbl idx lvl from to p = PhyloGroup
lbl
(
sort
$
map
(
\
x
->
ngramsToIdx
x
p
)
ngrams
)
(
Map
.
empty
)
(
Map
.
empty
)
[]
[]
[]
[]
...
...
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