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
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
bfe0edc4
Commit
bfe0edc4
authored
Feb 20, 2019
by
Quentin Lobbé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to build links from -1 to 0
parent
549c8120
Pipeline
#218
failed with stage
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
11 deletions
+68
-11
Phylo.hs
src/Gargantext/Viz/Phylo.hs
+2
-0
Example.hs
src/Gargantext/Viz/Phylo/Example.hs
+66
-9
Tools.hs
src/Gargantext/Viz/Phylo/Tools.hs
+0
-2
No files found.
src/Gargantext/Viz/Phylo.hs
View file @
bfe0edc4
...
...
@@ -152,6 +152,8 @@ makeLenses ''PhyloParam
makeLenses
''
P
hyloExport
makeLenses
''
S
oftware
makeLenses
''
P
hyloGroup
makeLenses
''
P
hyloLevel
makeLenses
''
P
hyloPeriod
-- | JSON instances
$
(
deriveJSON
(
unPrefix
"_phylo_"
)
''
P
hylo
)
...
...
src/Gargantext/Viz/Phylo/Example.hs
View file @
bfe0edc4
...
...
@@ -70,9 +70,19 @@ type Occurrences = Int
data
Levels
=
Level_m1
|
Level_0
|
Level_1
|
Level_2
|
Level_N
deriving
(
Show
,
Eq
,
Enum
,
Bounded
)
data
LinkLevels
=
Link_m1To0
|
Link_0To1
|
Link_mxTox
data
LinkLvlLabel
=
Link_0_m1
|
Link_1_0
|
Link_x_y
deriving
(
Show
,
Eq
,
Enum
,
Bounded
)
data
LinkLvl
=
LinkLvl
{
linkLvlLabel
::
LinkLvlLabel
,
linkLvlFrom
::
Int
,
linkLvlTo
::
Int
}
deriving
(
Show
)
data
PhyloError
=
LevelDoesNotExist
|
LevelUnassigned
deriving
(
Show
)
...
...
@@ -127,6 +137,21 @@ addPointer :: Semigroup field
addPointer
field
targetPointer
current
=
set
field
(
<>
targetPointer
)
current
addPointerLevelParents
::
[
Pointer
]
->
PhyloGroup
->
PhyloGroup
addPointerLevelParents
pointers
=
over
phylo_groupLevelParents
(
List
.++
pointers
)
addPointerLevelChilds
::
[
Pointer
]
->
PhyloGroup
->
PhyloGroup
addPointerLevelChilds
pointers
=
over
phylo_groupLevelChilds
(
List
.++
pointers
)
getGroupPeriod
::
PhyloGroup
->
PhyloPeriodId
getGroupPeriod
group
=
Tuple
.
fst
$
Tuple
.
fst
$
_phylo_groupId
group
getGroupLevel
::
PhyloGroup
->
Int
getGroupLevel
group
=
Tuple
.
snd
$
Tuple
.
fst
$
_phylo_groupId
group
getGroupIndex
::
PhyloGroup
->
Int
getGroupIndex
group
=
Tuple
.
snd
$
_phylo_groupId
group
containsIdx
::
[
Int
]
->
[
Int
]
->
Bool
containsIdx
l
l'
|
List
.
null
l'
=
False
...
...
@@ -134,13 +159,45 @@ containsIdx l l'
|
List
.
head
l'
`
List
.
elem
`
l
=
True
|
otherwise
=
containsIdx
l
(
List
.
tail
l'
)
shouldLink
::
LinkL
evels
->
PhyloGroup
->
PhyloGroup
->
Bool
shouldLink
lvl
current
target
=
case
lvl
of
Link_
m1To0
->
containsIdx
(
_phylo_groupNgrams
target
)
(
_phylo_groupNgrams
current
)
Link_
0To1
->
containsIdx
(
_phylo_groupNgrams
target
)
(
_phylo_groupNgrams
current
)
Link_
mxTox
->
undefined
shouldLink
::
LinkL
vl
->
[
Int
]
->
[
Int
]
->
Bool
shouldLink
lvl
current
target
=
case
l
inkLvlLabel
l
vl
of
Link_
0_m1
->
containsIdx
target
current
Link_
1_0
->
containsIdx
target
current
Link_
x_y
->
undefined
_
->
panic
(
"error link level to be defined"
)
linkToGroups
::
LinkLvl
->
PhyloGroup
->
[
PhyloGroup
]
->
PhyloGroup
linkToGroups
lvl
current
targets
=
if
(
getGroupLevel
current
)
==
linkLvlFrom
lvl
then
addPointerLevelChilds
links
current
else
addPointerLevelParents
links
current
where
links
=
Maybe
.
mapMaybe
(
\
x
->
if
(
shouldLink
lvl
(
_phylo_groupNgrams
current
)
(
_phylo_groupNgrams
x
))
then
Just
((
_phylo_groupId
x
),
1
)
else
Nothing
)
targets
foo
::
LinkLvl
->
[
PhyloGroup
]
->
[
PhyloGroup
]
->
[
PhyloGroup
]
foo
lvl
current
targets
=
map
(
\
x
->
linkToGroups
lvl
x
targets
)
current
linkLevelToLevel
::
LinkLvl
->
PhyloPeriod
->
PhyloPeriod
linkLevelToLevel
lvl
(
PhyloPeriod
periodId
phyloLevels
)
=
PhyloPeriod
periodId
phyloLevels'
where
phyloLevels'
=
current'
:
target'
:
(
List
.
tail
$
List
.
tail
phyloLevels
)
current
=
List
.
head
phyloLevels
target
=
List
.
head
$
List
.
tail
phyloLevels
current'
=
PhyloLevel
(
_phylo_levelId
current
)
$
foo
lvl
(
_phylo_levelGroups
current
)
(
_phylo_levelGroups
target
)
target'
=
PhyloLevel
(
_phylo_levelId
target
)
$
foo
lvl
(
_phylo_levelGroups
target
)
(
_phylo_levelGroups
current
)
bar
::
LinkLvl
->
Phylo
->
Phylo
bar
lvl
(
Phylo
pDuration
pNgrams
pPeriods
)
=
Phylo
pDuration
pNgrams
pPeriods'
where
pPeriods'
=
map
(
\
x
->
linkLevelToLevel
lvl
x
)
pPeriods
-- idea link from 0 to -1 by looking at idx intersection then link from -1 to 0 by looking at id contained in childs
-- Bad and full of mistakes ...
phyloWithLinks_0_m1
=
bar
(
LinkLvl
Link_0_m1
0
(
-
1
))
phyloWithGroups0
------------------------------------------------------------------------
-- | STEP 5 | -- Build level 0 (for the moment it's just a durty copy of level -1)
...
...
src/Gargantext/Viz/Phylo/Tools.hs
View file @
bfe0edc4
...
...
@@ -86,8 +86,6 @@ maximalCliques :: [Clique] -> [Clique]
maximalCliques
=
undefined
-- | Phylo management
-- | PhyloLevel Management
...
...
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