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
198
Issues
198
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
572e7fa2
Commit
572e7fa2
authored
Jun 18, 2023
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
[MERGE] Phylo
parents
22b14f56
6502c4c6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
203 additions
and
181 deletions
+203
-181
gargantext.cabal
gargantext.cabal
+1
-1
Phylo.hs
src/Gargantext/Core/Viz/Phylo.hs
+4
-5
API.hs
src/Gargantext/Core/Viz/Phylo/API.hs
+0
-1
PhyloExport.hs
src/Gargantext/Core/Viz/Phylo/PhyloExport.hs
+82
-57
PhyloMaker.hs
src/Gargantext/Core/Viz/Phylo/PhyloMaker.hs
+77
-78
PhyloTools.hs
src/Gargantext/Core/Viz/Phylo/PhyloTools.hs
+39
-39
No files found.
gargantext.cabal
View file @
572e7fa2
src/Gargantext/Core/Viz/Phylo.hs
View file @
572e7fa2
...
@@ -430,7 +430,6 @@ data Phylo =
...
@@ -430,7 +430,6 @@ data Phylo =
instance
ToSchema
Phylo
where
instance
ToSchema
Phylo
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_phylo_"
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_phylo_"
)
----------------
----------------
-- | Period | --
-- | Period | --
----------------
----------------
...
...
src/Gargantext/Core/Viz/Phylo/API.hs
View file @
572e7fa2
...
@@ -188,4 +188,3 @@ instance ToParamSchema Metric
...
@@ -188,4 +188,3 @@ instance ToParamSchema Metric
instance
ToParamSchema
Order
instance
ToParamSchema
Order
instance
ToParamSchema
Sort
instance
ToParamSchema
Sort
instance
ToSchema
Order
instance
ToSchema
Order
src/Gargantext/Core/Viz/Phylo/PhyloExport.hs
View file @
572e7fa2
...
@@ -66,19 +66,21 @@ toAttr :: AttributeName -> Lazy.Text -> CustomAttribute
...
@@ -66,19 +66,21 @@ toAttr :: AttributeName -> Lazy.Text -> CustomAttribute
toAttr
k
v
=
customAttribute
k
v
toAttr
k
v
=
customAttribute
k
v
metaToAttr
::
Map
Text
.
Text
[
Double
]
->
[
CustomAttribute
]
metaToAttr
::
Map
Text
.
Text
[
Double
]
->
[
CustomAttribute
]
metaToAttr
meta
=
map
(
\
(
k
,
v
)
->
toAttr
(
fromStrict
k
)
$
(
pack
.
unwords
)
$
map
show
v
)
$
toList
meta
metaToAttr
meta
=
map
(
\
(
k
,
v
)
->
toAttr
(
fromStrict
k
)
$
(
pack
.
unwords
)
$
map
show
v
)
$
toList
meta
groupIdToDotId
::
PhyloGroupId
->
DotId
groupIdToDotId
::
PhyloGroupId
->
DotId
groupIdToDotId
(((
d
,
d'
),
lvl
),
idx
)
=
(
fromStrict
.
Text
.
pack
)
$
(
"group"
<>
(
show
d
)
<>
(
show
d'
)
<>
(
show
lvl
)
<>
(
show
idx
))
groupIdToDotId
(((
d
,
d'
),
lvl
),
idx
)
=
(
fromStrict
.
Text
.
pack
)
$
"group"
<>
show
d
<>
show
d'
<>
show
lvl
<>
show
idx
branchIdToDotId
::
PhyloBranchId
->
DotId
branchIdToDotId
::
PhyloBranchId
->
DotId
branchIdToDotId
bId
=
(
fromStrict
.
Text
.
pack
)
$
(
"branch"
<>
show
(
snd
bId
)
)
branchIdToDotId
bId
=
(
fromStrict
.
Text
.
pack
)
$
"branch"
<>
show
(
snd
bId
)
periodIdToDotId
::
Period
->
DotId
periodIdToDotId
::
Period
->
DotId
periodIdToDotId
prd
=
(
fromStrict
.
Text
.
pack
)
$
(
"period"
<>
show
(
fst
prd
)
<>
show
(
snd
prd
)
)
periodIdToDotId
prd
=
(
fromStrict
.
Text
.
pack
)
$
"period"
<>
show
(
fst
prd
)
<>
show
(
snd
prd
)
groupToTable
::
Vector
Ngrams
->
PhyloGroup
->
H
.
Label
groupToTable
::
Vector
Ngrams
->
PhyloGroup
->
H
.
Label
groupToTable
fdt
g
=
H
.
Table
H
.
HTable
groupToTable
fdt
g
=
H
.
Table
H
.
HTable
{
H
.
tableFontAttrs
=
Just
[
H
.
PointSize
14
,
H
.
Align
H
.
HLeft
]
{
H
.
tableFontAttrs
=
Just
[
H
.
PointSize
14
,
H
.
Align
H
.
HLeft
]
,
H
.
tableAttrs
=
[
H
.
Border
0
,
H
.
CellBorder
0
,
H
.
BGColor
(
toColor
White
)]
,
H
.
tableAttrs
=
[
H
.
Border
0
,
H
.
CellBorder
0
,
H
.
BGColor
(
toColor
White
)]
,
H
.
tableRows
=
[
header
]
,
H
.
tableRows
=
[
header
]
...
@@ -90,7 +92,8 @@ groupToTable fdt g = H.Table H.HTable
...
@@ -90,7 +92,8 @@ groupToTable fdt g = H.Table H.HTable
where
where
--------------------------------------
--------------------------------------
ngramsToRow
::
[(
Ngrams
,
(
Double
,
Double
))]
->
H
.
Row
ngramsToRow
::
[(
Ngrams
,
(
Double
,
Double
))]
->
H
.
Row
ngramsToRow
ns
=
H
.
Cells
$
map
(
\
(
n
,(
d
,
_
))
->
ngramsToRow
ns
=
H
.
Cells
$
map
(
\
(
n
,
(
d
,
_
))
->
H
.
LabelCell
[
H
.
Align
H
.
HLeft
H
.
LabelCell
[
H
.
Align
H
.
HLeft
,
dynamicToColor
$
floor
d
]
$
H
.
Text
[
H
.
Str
$
fromStrict
n
])
ns
,
dynamicToColor
$
floor
d
]
$
H
.
Text
[
H
.
Str
$
fromStrict
n
])
ns
--------------------------------------
--------------------------------------
...
@@ -109,7 +112,12 @@ groupToTable fdt g = H.Table H.HTable
...
@@ -109,7 +112,12 @@ groupToTable fdt g = H.Table H.HTable
branchToDotNode
::
PhyloBranch
->
Int
->
Dot
DotId
branchToDotNode
::
PhyloBranch
->
Int
->
Dot
DotId
branchToDotNode
b
bId
=
branchToDotNode
b
bId
=
node
(
branchIdToDotId
$
b
^.
branch_id
)
node
(
branchIdToDotId
$
b
^.
branch_id
)
([
FillColor
[
toWColor
CornSilk
],
FontName
"Arial"
,
FontSize
40
,
Shape
Egg
,
Style
[
SItem
Bold
[]
],
Label
(
toDotLabel
$
b
^.
branch_label
)]
(
[
FillColor
[
toWColor
CornSilk
]
,
FontName
"Arial"
,
FontSize
40
,
Shape
Egg
,
Style
[
SItem
Bold
[]
]
,
Label
(
toDotLabel
$
b
^.
branch_label
)
]
<>
(
metaToAttr
$
b
^.
branch_meta
)
<>
(
metaToAttr
$
b
^.
branch_meta
)
<>
[
toAttr
"nodeType"
"branch"
<>
[
toAttr
"nodeType"
"branch"
,
toAttr
"bId"
(
pack
$
show
bId
)
,
toAttr
"bId"
(
pack
$
show
bId
)
...
@@ -121,19 +129,24 @@ branchToDotNode b bId =
...
@@ -121,19 +129,24 @@ branchToDotNode b bId =
periodToDotNode
::
(
Date
,
Date
)
->
(
Text
.
Text
,
Text
.
Text
)
->
Dot
DotId
periodToDotNode
::
(
Date
,
Date
)
->
(
Text
.
Text
,
Text
.
Text
)
->
Dot
DotId
periodToDotNode
prd
prd'
=
periodToDotNode
prd
prd'
=
node
(
periodIdToDotId
prd
)
node
(
periodIdToDotId
prd
)
$
([
Shape
BoxShape
,
FontSize
50
,
Label
(
toDotLabel
$
Text
.
pack
(
show
(
fst
prd
)
<>
" "
<>
show
(
snd
prd
)))]
[
Shape
BoxShape
,
FontSize
50
,
Label
$
toDotLabel
$
Text
.
pack
$
show
(
fst
prd
)
<>
" "
<>
show
(
snd
prd
)
]
<>
[
toAttr
"nodeType"
"period"
<>
[
toAttr
"nodeType"
"period"
,
toAttr
"strFrom"
(
fromStrict
$
Text
.
pack
$
(
show
$
fst
prd'
))
,
toAttr
"strFrom"
$
fromStrict
$
Text
.
pack
$
show
$
fst
prd'
,
toAttr
"strTo"
(
fromStrict
$
Text
.
pack
$
(
show
$
snd
prd'
))
,
toAttr
"strTo"
$
fromStrict
$
Text
.
pack
$
show
$
snd
prd'
,
toAttr
"from"
(
fromStrict
$
Text
.
pack
$
(
show
$
fst
prd
))
,
toAttr
"from"
$
fromStrict
$
Text
.
pack
$
show
$
fst
prd
,
toAttr
"to"
(
fromStrict
$
Text
.
pack
$
(
show
$
snd
prd
))])
,
toAttr
"to"
$
fromStrict
$
Text
.
pack
$
show
$
snd
prd
]
groupToDotNode
::
Vector
Ngrams
->
PhyloGroup
->
Int
->
Dot
DotId
groupToDotNode
::
Vector
Ngrams
->
PhyloGroup
->
Int
->
Dot
DotId
groupToDotNode
fdt
g
bId
=
groupToDotNode
fdt
g
bId
=
node
(
groupIdToDotId
$
getGroupId
g
)
node
(
groupIdToDotId
$
getGroupId
g
)
([
FontName
"Arial"
,
Shape
Square
,
penWidth
4
,
toLabel
(
groupToTable
fdt
g
)]
(
[
FontName
"Arial"
,
Shape
Square
,
penWidth
4
,
toLabel
(
groupToTable
fdt
g
)
]
<>
[
toAttr
"nodeType"
"group"
<>
[
toAttr
"nodeType"
"group"
,
toAttr
"gid"
(
groupIdToDotId
$
getGroupId
g
)
,
toAttr
"gid"
(
groupIdToDotId
$
getGroupId
g
)
,
toAttr
"from"
(
pack
$
show
(
fst
$
g
^.
phylo_groupPeriod
))
,
toAttr
"from"
(
pack
$
show
(
fst
$
g
^.
phylo_groupPeriod
))
...
@@ -598,7 +611,13 @@ getGroupThr step g =
...
@@ -598,7 +611,13 @@ getGroupThr step g =
breaks
=
(
g
^.
phylo_groupMeta
)
!
"breaks"
breaks
=
(
g
^.
phylo_groupMeta
)
!
"breaks"
in
(
last'
"export"
(
take
(
round
$
(
last'
"export"
breaks
)
+
1
)
seaLvl
))
-
step
in
(
last'
"export"
(
take
(
round
$
(
last'
"export"
breaks
)
+
1
)
seaLvl
))
-
step
toAncestor
::
Double
->
Map
Int
Double
->
PhyloSimilarity
->
Double
->
[
PhyloGroup
]
->
PhyloGroup
->
PhyloGroup
toAncestor
::
Double
->
Map
Int
Double
->
PhyloSimilarity
->
Double
->
[
PhyloGroup
]
->
PhyloGroup
->
PhyloGroup
toAncestor
nbDocs
diago
similarity
step
candidates
ego
=
toAncestor
nbDocs
diago
similarity
step
candidates
ego
=
let
curr
=
ego
^.
phylo_groupAncestors
let
curr
=
ego
^.
phylo_groupAncestors
in
ego
&
phylo_groupAncestors
.~
(
curr
++
(
map
(
\
(
g
,
w
)
->
(
getGroupId
g
,
w
))
in
ego
&
phylo_groupAncestors
.~
(
curr
++
(
map
(
\
(
g
,
w
)
->
(
getGroupId
g
,
w
))
...
@@ -607,7 +626,13 @@ toAncestor nbDocs diago similarity step candidates ego =
...
@@ -607,7 +626,13 @@ toAncestor nbDocs diago similarity step candidates ego =
$
filter
(
\
g
->
g
^.
phylo_groupBranchId
/=
ego
^.
phylo_groupBranchId
)
candidates
))
$
filter
(
\
g
->
g
^.
phylo_groupBranchId
/=
ego
^.
phylo_groupBranchId
)
candidates
))
headsToAncestors
::
Double
->
Map
Int
Double
->
PhyloSimilarity
->
Double
->
[
PhyloGroup
]
->
[
PhyloGroup
]
->
[
PhyloGroup
]
headsToAncestors
::
Double
->
Map
Int
Double
->
PhyloSimilarity
->
Double
->
[
PhyloGroup
]
->
[
PhyloGroup
]
->
[
PhyloGroup
]
headsToAncestors
nbDocs
diago
similarity
step
heads
acc
=
headsToAncestors
nbDocs
diago
similarity
step
heads
acc
=
if
(
null
heads
)
if
(
null
heads
)
then
acc
then
acc
...
...
src/Gargantext/Core/Viz/Phylo/PhyloMaker.hs
View file @
572e7fa2
...
@@ -263,7 +263,6 @@ maybeDefaultParams phylo = if (defaultMode (getConfig phylo))
...
@@ -263,7 +263,6 @@ maybeDefaultParams phylo = if (defaultMode (getConfig phylo))
-- 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 Clustering
-- QL: backend entre phyloBase et Clustering
-- tophylowithoutLink
toPhyloWithoutLink
::
[
Document
]
->
PhyloConfig
->
Phylo
toPhyloWithoutLink
::
[
Document
]
->
PhyloConfig
->
Phylo
toPhyloWithoutLink
docs
conf
=
joinRoots
toPhyloWithoutLink
docs
conf
=
joinRoots
$
findSeaLadder
$
findSeaLadder
...
...
src/Gargantext/Core/Viz/Phylo/PhyloTools.hs
View file @
572e7fa2
...
@@ -172,11 +172,11 @@ toLstDate ds = snd
...
@@ -172,11 +172,11 @@ toLstDate ds = snd
getTimeScale
::
Phylo
->
[
Char
]
getTimeScale
::
Phylo
->
[
Char
]
getTimeScale
p
=
case
(
timeUnit
$
getConfig
p
)
of
getTimeScale
p
=
case
(
timeUnit
$
getConfig
p
)
of
Epoch
_
_
_
->
"epoch"
Epoch
{}
->
"epoch"
Year
_
_
_
->
"year"
Year
{}
->
"year"
Month
_
_
_
->
"month"
Month
{}
->
"month"
Week
_
_
_
->
"week"
Week
{}
->
"week"
Day
_
_
_
->
"day"
Day
{}
->
"day"
-- | Get a regular & ascendante timeScale from a given list of dates
-- | Get a regular & ascendante timeScale from a given list of dates
...
@@ -188,27 +188,27 @@ toTimeScale dates step =
...
@@ -188,27 +188,27 @@ toTimeScale dates step =
getTimeStep
::
TimeUnit
->
Int
getTimeStep
::
TimeUnit
->
Int
getTimeStep
time
=
case
time
of
getTimeStep
time
=
case
time
of
Epoch
_
s
_
->
s
Epoch
{
..
}
->
_epoch_step
Year
_
s
_
->
s
Year
{
..
}
->
_year_step
Month
_
s
_
->
s
Month
{
..
}
->
_month_step
Week
_
s
_
->
s
Week
{
..
}
->
_week_step
Day
_
s
_
->
s
Day
{
..
}
->
_day_step
getTimePeriod
::
TimeUnit
->
Int
getTimePeriod
::
TimeUnit
->
Int
getTimePeriod
time
=
case
time
of
getTimePeriod
time
=
case
time
of
Epoch
p
_
_
->
p
Epoch
{
..
}
->
_epoch_period
Year
p
_
_
->
p
Year
{
..
}
->
_year_period
Month
p
_
_
->
p
Month
{
..
}
->
_month_period
Week
p
_
_
->
p
Week
{
..
}
->
_week_period
Day
p
_
_
->
p
Day
{
..
}
->
_day_period
getTimeFrame
::
TimeUnit
->
Int
getTimeFrame
::
TimeUnit
->
Int
getTimeFrame
time
=
case
time
of
getTimeFrame
time
=
case
time
of
Epoch
_
_
f
->
f
Epoch
{
..
}
->
_epoch_matchingFrame
Year
_
_
f
->
f
Year
{
..
}
->
_year_matchingFrame
Month
_
_
f
->
f
Month
{
..
}
->
_month_matchingFrame
Week
_
_
f
->
f
Week
{
..
}
->
_week_matchingFrame
Day
_
_
f
->
f
Day
{
..
}
->
_day_matchingFrame
-------------
-------------
-- | Fis | --
-- | Fis | --
...
@@ -220,7 +220,7 @@ isNested :: Eq a => [a] -> [a] -> Bool
...
@@ -220,7 +220,7 @@ isNested :: Eq a => [a] -> [a] -> Bool
isNested
l
l'
isNested
l
l'
|
null
l'
=
True
|
null
l'
=
True
|
length
l'
>
length
l
=
False
|
length
l'
>
length
l
=
False
|
(
union
l
l'
)
==
l
=
True
|
union
l
l'
==
l
=
True
|
otherwise
=
False
|
otherwise
=
False
...
@@ -251,8 +251,8 @@ traceSupport mFis = foldl (\msg cpt -> msg <> show (countSup cpt supports) <> "
...
@@ -251,8 +251,8 @@ traceSupport mFis = foldl (\msg cpt -> msg <> show (countSup cpt supports) <> "
traceFis
::
[
Char
]
->
Map
(
Date
,
Date
)
[
Clustering
]
->
Map
(
Date
,
Date
)
[
Clustering
]
traceFis
::
[
Char
]
->
Map
(
Date
,
Date
)
[
Clustering
]
->
Map
(
Date
,
Date
)
[
Clustering
]
traceFis
msg
mFis
=
trace
(
"
\n
"
<>
"-- | "
<>
msg
<>
" : "
<>
show
(
sum
$
map
length
$
elems
mFis
)
<>
"
\n
"
traceFis
msg
mFis
=
trace
(
"
\n
"
<>
"-- | "
<>
msg
<>
" : "
<>
show
(
sum
$
map
length
$
elems
mFis
)
<>
"
\n
"
<>
"Support : "
<>
(
traceSupport
mFis
)
<>
"
\n
"
<>
"Support : "
<>
traceSupport
mFis
<>
"
\n
"
<>
"Nb Ngrams : "
<>
(
traceClique
mFis
)
<>
"
\n
"
)
mFis
<>
"Nb Ngrams : "
<>
traceClique
mFis
<>
"
\n
"
)
mFis
----------------
----------------
...
...
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