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
87d00c7e
Commit
87d00c7e
authored
Feb 28, 2019
by
Quentin Lobbé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refactoring
parent
ad087fcb
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
178 additions
and
91 deletions
+178
-91
Phylo.hs
src/Gargantext/Viz/Phylo.hs
+19
-0
Example.hs
src/Gargantext/Viz/Phylo/Example.hs
+92
-88
Tools.hs
src/Gargantext/Viz/Phylo/Tools.hs
+67
-3
No files found.
src/Gargantext/Viz/Phylo.hs
View file @
87d00c7e
...
...
@@ -137,6 +137,7 @@ type Weight = Double
-- | Ngrams : a contiguous sequence of n terms
type
Ngrams
=
Text
-- | PhyloNgrams : Vector of all the Ngrams (PhyloGroup of level -1) used within a Phylo
...
...
@@ -151,6 +152,22 @@ type Support = Int
type
Fis
=
Map
Clique
Support
data
Direction
=
From
|
To
deriving
(
Show
,
Eq
)
data
LevelLabel
=
Level_m1
|
Level_0
|
Level_1
|
Level_mN
|
Level_N
|
Level_pN
deriving
(
Show
,
Eq
,
Enum
,
Bounded
)
data
Level
=
Level
{
_levelLabel
::
LevelLabel
,
_levelValue
::
Int
}
deriving
(
Show
)
data
LevelLink
=
LevelLink
{
_levelFrom
::
Level
,
_levelTo
::
Level
}
deriving
(
Show
)
-- | Lenses
makeLenses
''
P
hylo
makeLenses
''
P
hyloParam
...
...
@@ -159,6 +176,8 @@ makeLenses ''Software
makeLenses
''
P
hyloGroup
makeLenses
''
P
hyloLevel
makeLenses
''
P
hyloPeriod
makeLenses
''
L
evel
makeLenses
''
L
evelLink
-- | JSON instances
$
(
deriveJSON
(
unPrefix
"_phylo_"
)
''
P
hylo
)
...
...
src/Gargantext/Viz/Phylo/Example.hs
View file @
87d00c7e
This diff is collapsed.
Click to expand it.
src/Gargantext/Viz/Phylo/Tools.hs
View file @
87d00c7e
...
...
@@ -17,7 +17,7 @@ Portability : POSIX
module
Gargantext.Viz.Phylo.Tools
where
import
Control.Lens
hiding
(
both
)
import
Control.Lens
hiding
(
both
,
Level
)
import
Data.List
(
filter
,
intersect
,
(
++
),
sort
)
import
Data.Map
(
Map
)
import
Data.Text
(
Text
)
...
...
@@ -49,13 +49,47 @@ initGroup ngrams lbl idx lvl from to p = PhyloGroup
(
Map
.
empty
)
[]
[]
[]
[]
-- | To create a Level
initLevel
::
Int
->
LevelLabel
->
Level
initLevel
lvl
lbl
=
Level
lbl
lvl
-- | To create a LevelLink
initLevelLink
::
Level
->
Level
->
LevelLink
initLevelLink
lvl
lvl'
=
LevelLink
lvl
lvl'
-- | To get the label of a Level
getLevelLabel
::
Level
->
LevelLabel
getLevelLabel
lvl
=
_levelLabel
lvl
-- | To get the value of a Level
getLevelValue
::
Level
->
Int
getLevelValue
lvl
=
_levelValue
lvl
-- | To get the label of a LevelLink based on a Direction
getLevelLinkLabel
::
Direction
->
LevelLink
->
LevelLabel
getLevelLinkLabel
dir
link
=
case
dir
of
From
->
view
(
levelFrom
.
levelLabel
)
link
To
->
view
(
levelTo
.
levelLabel
)
link
_
->
panic
"[ERR][Viz.Phylo.Tools.getLevelLinkLabel] Wrong direction"
-- | To get the value of a LevelLink based on a Direction
getLevelLinkValue
::
Direction
->
LevelLink
->
Int
getLevelLinkValue
dir
link
=
case
dir
of
From
->
view
(
levelFrom
.
levelValue
)
link
To
->
view
(
levelTo
.
levelValue
)
link
_
->
panic
"[ERR][Viz.Phylo.Tools.getLevelLinkValue] Wrong direction"
-- | To transform an Ngrams into its corresponding index in a Phylo
ngramsToIdx
::
Ngrams
->
Phylo
->
Int
ngramsToIdx
x
p
=
getIdx
x
(
_phylo_ngrams
p
)
-- | To get the Ngrams of a Phylo
getPhyloNgrams
::
Phylo
->
PhyloNgrams
getPhyloNgrams
=
_phylo_ngrams
-- | To get the Ngrams of a PhyloGroup
getNgrams
::
PhyloGroup
->
[
Int
]
getNgrams
=
_phylo_groupNgrams
get
Group
Ngrams
::
PhyloGroup
->
[
Int
]
get
Group
Ngrams
=
_phylo_groupNgrams
-- | To get the id of a PhyloGroup
getGroupId
::
PhyloGroup
->
PhyloGroupId
...
...
@@ -88,6 +122,36 @@ getGroupsWithFilters lvl prd p = (filterGroups getGroupLevel lvl p)
`
intersect
`
(
filterGroups
getGroupPeriod
prd
p
)
-- | To create a PhyloLevel
initPhyloLevel
::
PhyloLevelId
->
[
PhyloGroup
]
->
PhyloLevel
initPhyloLevel
id
groups
=
PhyloLevel
id
groups
-- | To set the LevelId of a PhyloLevel and of all its PhyloGroups
setPhyloLevelId
::
Int
->
PhyloLevel
->
PhyloLevel
setPhyloLevelId
lvl'
(
PhyloLevel
(
id
,
lvl
)
groups
)
=
PhyloLevel
(
id
,
lvl'
)
groups'
where
groups'
=
over
(
traverse
.
phylo_groupId
)
(
\
((
period
,
lvl
),
idx
)
->
((
period
,
lvl'
),
idx
))
groups
-- | To get all the Phylolevels of a given PhyloPeriod
getPhyloLevels
::
PhyloPeriod
->
[
PhyloLevel
]
getPhyloLevels
=
view
(
phylo_periodLevels
)
-- | To add a PhyloLevel at the end of a list of PhyloLevels
addPhyloLevel
::
PhyloLevel
->
[
PhyloLevel
]
->
[
PhyloLevel
]
addPhyloLevel
lvl
l
=
l
++
[
lvl
]
-- | To alter a list of PhyloLevels following a given function
alterPhyloLevels
::
([
PhyloLevel
]
->
[
PhyloLevel
])
->
Phylo
->
Phylo
alterPhyloLevels
f
p
=
over
(
phylo_periods
.
traverse
.
phylo_periodLevels
)
f
p
-- | To create a PhyloPeriod
initPhyloPeriod
::
PhyloPeriodId
->
[
PhyloLevel
]
->
PhyloPeriod
initPhyloPeriod
id
l
=
PhyloPeriod
id
l
-- | To alter each PhyloPeriod of a Phylo following a given function
alterPhyloPeriods
::
(
PhyloPeriod
->
PhyloPeriod
)
->
Phylo
->
Phylo
alterPhyloPeriods
f
p
=
over
(
phylo_periods
...
...
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