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
6b566317
Commit
6b566317
authored
Apr 02, 2019
by
Quentin Lobbé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the PhyloParam to the Phylo constructor
parent
0b69015c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
444 additions
and
321 deletions
+444
-321
Phylo.hs
src/Gargantext/Viz/Phylo.hs
+61
-19
Cooc.hs
src/Gargantext/Viz/Phylo/Aggregates/Cooc.hs
+5
-1
Example.hs
src/Gargantext/Viz/Phylo/Example.hs
+64
-65
LevelMaker.hs
src/Gargantext/Viz/Phylo/LevelMaker.hs
+3
-13
Tools.hs
src/Gargantext/Viz/Phylo/Tools.hs
+298
-214
ViewMaker.hs
src/Gargantext/Viz/Phylo/View/ViewMaker.hs
+13
-9
No files found.
src/Gargantext/Viz/Phylo.hs
View file @
6b566317
...
@@ -42,30 +42,31 @@ import Gargantext.Database.Schema.Ngrams (NgramsId)
...
@@ -42,30 +42,31 @@ import Gargantext.Database.Schema.Ngrams (NgramsId)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Prelude
import
Gargantext.Prelude
------------------------------------------------------------------------
data
PhyloExport
=
PhyloExport
{
_phyloExport_param
::
PhyloParam
,
_phyloExport_data
::
Phylo
}
deriving
(
Generic
,
Show
)
-- | .phylo parameters
--------------------
-- | PhyloParam | --
--------------------
-- | Global parameters of a Phylo
data
PhyloParam
=
data
PhyloParam
=
PhyloParam
{
_phyloParam_version
::
Text
-- Double ?
PhyloParam
{
_phyloParam_version
::
Text
-- Double ?
,
_phyloParam_software
::
Software
,
_phyloParam_software
::
Software
,
_phyloParam_params
::
Hash
,
_phyloParam_query
::
PhyloQuery
,
_phyloParam_query
::
Maybe
PhyloQuery
}
deriving
(
Generic
,
Show
)
}
deriving
(
Generic
,
Show
)
type
Hash
=
Text
-- | Software
-- | Software parameters
-- TODO move somewhere since it is generic
data
Software
=
data
Software
=
Software
{
_software_name
::
Text
Software
{
_software_name
::
Text
,
_software_version
::
Text
,
_software_version
::
Text
}
deriving
(
Generic
,
Show
)
}
deriving
(
Generic
,
Show
)
------------------------------------------------------------------------
---------------
-- | Phylo | --
---------------
-- | Phylo datatype of a phylomemy
-- | Phylo datatype of a phylomemy
-- Duration : time Segment of the whole Phylo
-- Duration : time Segment of the whole Phylo
...
@@ -75,6 +76,7 @@ data Phylo =
...
@@ -75,6 +76,7 @@ data Phylo =
Phylo
{
_phylo_duration
::
(
Start
,
End
)
Phylo
{
_phylo_duration
::
(
Start
,
End
)
,
_phylo_foundations
::
Vector
Ngrams
,
_phylo_foundations
::
Vector
Ngrams
,
_phylo_periods
::
[
PhyloPeriod
]
,
_phylo_periods
::
[
PhyloPeriod
]
,
_phylo_param
::
PhyloParam
}
}
deriving
(
Generic
,
Show
)
deriving
(
Generic
,
Show
)
...
@@ -88,6 +90,12 @@ type Date = Int
...
@@ -88,6 +90,12 @@ type Date = Int
type
Start
=
Date
type
Start
=
Date
type
End
=
Date
type
End
=
Date
---------------------
-- | PhyloPeriod | --
---------------------
-- | PhyloStep : steps of phylomemy on temporal axis
-- | PhyloStep : steps of phylomemy on temporal axis
-- Period: tuple (start date, end date) of the step of the phylomemy
-- Period: tuple (start date, end date) of the step of the phylomemy
-- Levels: levels of granularity
-- Levels: levels of granularity
...
@@ -98,6 +106,11 @@ data PhyloPeriod =
...
@@ -98,6 +106,11 @@ data PhyloPeriod =
deriving
(
Generic
,
Show
)
deriving
(
Generic
,
Show
)
--------------------
-- | PhyloLevel | --
--------------------
-- | PhyloLevel : levels of phylomemy on level axis
-- | PhyloLevel : levels of phylomemy on level axis
-- Levels description:
-- Levels description:
-- Level -1: Ngram equals itself (by identity) == _phylo_Ngrams
-- Level -1: Ngram equals itself (by identity) == _phylo_Ngrams
...
@@ -111,6 +124,11 @@ data PhyloLevel =
...
@@ -111,6 +124,11 @@ data PhyloLevel =
deriving
(
Generic
,
Show
)
deriving
(
Generic
,
Show
)
--------------------
-- | PhyloGroup | --
--------------------
-- | PhyloGroup : group of ngrams at each level and step
-- | PhyloGroup : group of ngrams at each level and step
-- Label : maybe has a label as text
-- Label : maybe has a label as text
-- Ngrams: set of terms that build the group
-- Ngrams: set of terms that build the group
...
@@ -155,7 +173,9 @@ type Pointer = (PhyloGroupId, Weight)
...
@@ -155,7 +173,9 @@ type Pointer = (PhyloGroupId, Weight)
type
Ngrams
=
Text
type
Ngrams
=
Text
--------------------
-- | Aggregates | --
-- | Aggregates | --
--------------------
-- | Document : a piece of Text linked to a Date
-- | Document : a piece of Text linked to a Date
...
@@ -189,14 +209,17 @@ type GroupGraph = (GroupNodes,GroupEdges)
...
@@ -189,14 +209,17 @@ type GroupGraph = (GroupNodes,GroupEdges)
-- | Error | --
-- | Error | --
---------------
---------------
data
PhyloError
=
LevelDoesNotExist
data
PhyloError
=
LevelDoesNotExist
|
LevelUnassigned
|
LevelUnassigned
deriving
(
Show
)
deriving
(
Show
)
-----------------
-----------------
-- | Cluster | --
-- | Cluster | --
-----------------
-----------------
-- | Cluster constructors
-- | Cluster constructors
data
Cluster
=
Fis
FisParams
data
Cluster
=
Fis
FisParams
|
RelatedComponents
RCParams
|
RelatedComponents
RCParams
...
@@ -218,10 +241,12 @@ data RCParams = RCParams
...
@@ -218,10 +241,12 @@ data RCParams = RCParams
data
LouvainParams
=
LouvainParams
data
LouvainParams
=
LouvainParams
{
_louvain_proximity
::
Proximity
}
deriving
(
Show
)
{
_louvain_proximity
::
Proximity
}
deriving
(
Show
)
-------------------
-------------------
-- | Proximity | --
-- | Proximity | --
-------------------
-------------------
-- | Proximity constructors
-- | Proximity constructors
data
Proximity
=
WeightedLogJaccard
WLJParams
data
Proximity
=
WeightedLogJaccard
WLJParams
|
Hamming
HammingParams
|
Hamming
HammingParams
...
@@ -238,10 +263,12 @@ data WLJParams = WLJParams
...
@@ -238,10 +263,12 @@ data WLJParams = WLJParams
data
HammingParams
=
HammingParams
data
HammingParams
=
HammingParams
{
_hamming_threshold
::
Double
}
deriving
(
Show
)
{
_hamming_threshold
::
Double
}
deriving
(
Show
)
----------------
----------------
-- | Filter | --
-- | Filter | --
----------------
----------------
-- | Filter constructors
-- | Filter constructors
data
Filter
=
LonelyBranch
LBParams
deriving
(
Show
)
data
Filter
=
LonelyBranch
LBParams
deriving
(
Show
)
...
@@ -251,36 +278,44 @@ data LBParams = LBParams
...
@@ -251,36 +278,44 @@ data LBParams = LBParams
,
_lb_periodsSup
::
Int
,
_lb_periodsSup
::
Int
,
_lb_minNodes
::
Int
}
deriving
(
Show
)
,
_lb_minNodes
::
Int
}
deriving
(
Show
)
----------------
----------------
-- | Metric | --
-- | Metric | --
----------------
----------------
-- | Metric constructors
-- | Metric constructors
data
Metric
=
BranchAge
deriving
(
Show
)
data
Metric
=
BranchAge
deriving
(
Show
)
----------------
----------------
-- | Tagger | --
-- | Tagger | --
----------------
----------------
-- | Tagger constructors
-- | Tagger constructors
data
Tagger
=
BranchLabelFreq
|
GroupLabelCooc
|
GroupDynamics
deriving
(
Show
)
data
Tagger
=
BranchLabelFreq
|
GroupLabelCooc
|
GroupDynamics
deriving
(
Show
)
--------------
--------------
-- | Sort | --
-- | Sort | --
--------------
--------------
-- | Sort constructors
-- | Sort constructors
data
Sort
=
ByBranchAge
deriving
(
Show
)
data
Sort
=
ByBranchAge
deriving
(
Show
)
data
Order
=
Asc
|
Desc
deriving
(
Show
)
data
Order
=
Asc
|
Desc
deriving
(
Show
)
--------------------
--------------------
-- | PhyloQuery | --
-- | PhyloQuery | --
--------------------
--------------------
-- | A Phyloquery describes a phylomemic reconstruction
-- | A Phyloquery describes a phylomemic reconstruction
data
PhyloQuery
=
PhyloQuery
data
PhyloQuery
=
PhyloQuery
{
_q_phylo
Nam
e
::
Text
{
_q_phylo
Titl
e
::
Text
,
_q_phyloDesc
::
Text
,
_q_phyloDesc
::
Text
-- Grain and Steps for the PhyloPeriods
-- Grain and Steps for the PhyloPeriods
,
_q_periodGrain
::
Int
,
_q_periodGrain
::
Int
...
@@ -301,14 +336,16 @@ data PhyloQuery = PhyloQuery
...
@@ -301,14 +336,16 @@ data PhyloQuery = PhyloQuery
data
Filiation
=
Ascendant
|
Descendant
|
Complete
deriving
(
Show
)
data
Filiation
=
Ascendant
|
Descendant
|
Complete
deriving
(
Show
)
data
EdgeType
=
PeriodEdge
|
LevelEdge
deriving
(
Show
)
data
EdgeType
=
PeriodEdge
|
LevelEdge
deriving
(
Show
)
-------------------
-------------------
-- | PhyloView | --
-- | PhyloView | --
-------------------
-------------------
-- | A PhyloView is the output type of a Phylo
-- | A PhyloView is the output type of a Phylo
data
PhyloView
=
PhyloView
data
PhyloView
=
PhyloView
{
_phylo_viewParam
::
PhyloParam
{
_phylo_viewParam
::
PhyloParam
,
_phylo_view
Label
::
Text
,
_phylo_view
Title
::
Text
,
_phylo_viewDescription
::
Text
,
_phylo_viewDescription
::
Text
,
_phylo_viewFiliation
::
Filiation
,
_phylo_viewFiliation
::
Filiation
,
_phylo_viewMeta
::
Map
Text
Double
,
_phylo_viewMeta
::
Map
Text
Double
...
@@ -342,10 +379,12 @@ data PhyloNode = PhyloNode
...
@@ -342,10 +379,12 @@ data PhyloNode = PhyloNode
,
_phylo_nodeChilds
::
[
PhyloNode
]
,
_phylo_nodeChilds
::
[
PhyloNode
]
}
deriving
(
Show
)
}
deriving
(
Show
)
------------------------
------------------------
-- | PhyloQueryView | --
-- | PhyloQueryView | --
------------------------
------------------------
data
DisplayMode
=
Flat
|
Nested
data
DisplayMode
=
Flat
|
Nested
-- | A PhyloQueryView describes a Phylo as an output view
-- | A PhyloQueryView describes a Phylo as an output view
...
@@ -373,12 +412,13 @@ data PhyloQueryView = PhyloQueryView
...
@@ -373,12 +412,13 @@ data PhyloQueryView = PhyloQueryView
,
_qv_verbose
::
Bool
,
_qv_verbose
::
Bool
}
}
----------------
----------------
-- | Lenses | --
-- | Lenses | --
----------------
----------------
makeLenses
''
P
hyloParam
makeLenses
''
P
hyloParam
makeLenses
''
P
hyloExport
makeLenses
''
S
oftware
makeLenses
''
S
oftware
--
--
makeLenses
''
P
hylo
makeLenses
''
P
hylo
...
@@ -398,10 +438,12 @@ makeLenses ''PhyloBranch
...
@@ -398,10 +438,12 @@ makeLenses ''PhyloBranch
makeLenses
''
P
hyloNode
makeLenses
''
P
hyloNode
makeLenses
''
P
hyloEdge
makeLenses
''
P
hyloEdge
------------------------
------------------------
-- | JSON instances | --
-- | JSON instances | --
------------------------
------------------------
$
(
deriveJSON
(
unPrefix
"_phylo_"
)
''
P
hylo
)
$
(
deriveJSON
(
unPrefix
"_phylo_"
)
''
P
hylo
)
$
(
deriveJSON
(
unPrefix
"_phylo_period"
)
''
P
hyloPeriod
)
$
(
deriveJSON
(
unPrefix
"_phylo_period"
)
''
P
hyloPeriod
)
$
(
deriveJSON
(
unPrefix
"_phylo_level"
)
''
P
hyloLevel
)
$
(
deriveJSON
(
unPrefix
"_phylo_level"
)
''
P
hyloLevel
)
...
@@ -409,7 +451,6 @@ $(deriveJSON (unPrefix "_phylo_group" ) ''PhyloGroup )
...
@@ -409,7 +451,6 @@ $(deriveJSON (unPrefix "_phylo_group" ) ''PhyloGroup )
--
--
$
(
deriveJSON
(
unPrefix
"_software_"
)
''
S
oftware
)
$
(
deriveJSON
(
unPrefix
"_software_"
)
''
S
oftware
)
$
(
deriveJSON
(
unPrefix
"_phyloParam_"
)
''
P
hyloParam
)
$
(
deriveJSON
(
unPrefix
"_phyloParam_"
)
''
P
hyloParam
)
$
(
deriveJSON
(
unPrefix
"_phyloExport_"
)
''
P
hyloExport
)
--
--
$
(
deriveJSON
defaultOptions
''
C
luster
)
$
(
deriveJSON
defaultOptions
''
C
luster
)
$
(
deriveJSON
defaultOptions
''
P
roximity
)
$
(
deriveJSON
defaultOptions
''
P
roximity
)
...
@@ -422,6 +463,7 @@ $(deriveJSON (unPrefix "_wlj_" ) ''WLJParams )
...
@@ -422,6 +463,7 @@ $(deriveJSON (unPrefix "_wlj_" ) ''WLJParams )
--
--
$
(
deriveJSON
(
unPrefix
"_q_"
)
''
P
hyloQuery
)
$
(
deriveJSON
(
unPrefix
"_q_"
)
''
P
hyloQuery
)
----------------------------
----------------------------
-- | TODO XML instances | --
-- | TODO XML instances | --
----------------------------
----------------------------
...
...
src/Gargantext/Viz/Phylo/Aggregates/Cooc.hs
View file @
6b566317
...
@@ -49,4 +49,8 @@ fisToCooc m p = map (/docs)
...
@@ -49,4 +49,8 @@ fisToCooc m p = map (/docs)
--------------------------------------
--------------------------------------
cooc
::
Map
(
Int
,
Int
)
(
Double
)
cooc
::
Map
(
Int
,
Int
)
(
Double
)
cooc
=
Map
.
fromList
$
map
(
\
x
->
(
x
,
0
))
(
listToUnDirectedCombiWith
(
\
x
->
getIdxInFoundations
x
p
)
fisNgrams
)
cooc
=
Map
.
fromList
$
map
(
\
x
->
(
x
,
0
))
(
listToUnDirectedCombiWith
(
\
x
->
getIdxInFoundations
x
p
)
fisNgrams
)
--------------------------------------
--------------------------------------
\ No newline at end of file
-- phyloCooc :: Map (Int, Int) Double
-- phyloCooc = fisToCooc phyloFis phylo1_0_1
\ No newline at end of file
src/Gargantext/Viz/Phylo/Example.hs
View file @
6b566317
This diff is collapsed.
Click to expand it.
src/Gargantext/Viz/Phylo/LevelMaker.hs
View file @
6b566317
...
@@ -144,16 +144,6 @@ toPhyloLevel lvl m p = alterPhyloPeriods
...
@@ -144,16 +144,6 @@ toPhyloLevel lvl m p = alterPhyloPeriods
)
period
)
p
)
period
)
p
-- | To init a Phylo
initPhylo
::
Grain
->
Step
->
[(
Date
,
Text
)]
->
[
Ngrams
]
->
(
Ngrams
->
Ngrams
)
->
Phylo
initPhylo
g
s
c
a
f
=
addPhyloLevel
0
(
corpusToDocs
f
c
base
)
base
where
--------------------------------------
base
::
Phylo
base
=
initPhyloBase
(
initPeriods
g
s
$
both
fst
(
head
c
,
last
c
))
(
initFoundations
a
)
--------------------------------------
-- | To incrementally add new Levels to a Phylo by making all the linking and aggregation tasks
-- | To incrementally add new Levels to a Phylo by making all the linking and aggregation tasks
toNthLevel
::
Level
->
Proximity
->
Cluster
->
Phylo
->
Phylo
toNthLevel
::
Level
->
Proximity
->
Cluster
->
Phylo
->
Phylo
toNthLevel
lvlMax
prox
clus
p
toNthLevel
lvlMax
prox
clus
p
...
@@ -198,8 +188,8 @@ toPhylo0 d p = addPhyloLevel 0 d p
...
@@ -198,8 +188,8 @@ toPhylo0 d p = addPhyloLevel 0 d p
-- | To reconstruct the Base of a Phylo
-- | To reconstruct the Base of a Phylo
toPhyloBase
::
PhyloQuery
->
[(
Date
,
Text
)]
->
[
Ngrams
]
->
Phylo
toPhyloBase
::
PhyloQuery
->
PhyloParam
->
[(
Date
,
Text
)]
->
[
Ngrams
]
->
Phylo
toPhyloBase
q
c
a
=
initPhyloBase
periods
foundations
toPhyloBase
q
p
c
a
=
initPhyloBase
periods
foundations
p
where
where
--------------------------------------
--------------------------------------
periods
::
[(
Date
,
Date
)]
periods
::
[(
Date
,
Date
)]
...
@@ -226,5 +216,5 @@ toPhylo q c a = toNthLevel (getNthLevel q) (getInterTemporalMatching q) (getNthC
...
@@ -226,5 +216,5 @@ toPhylo q c a = toNthLevel (getNthLevel q) (getInterTemporalMatching q) (getNthC
phyloDocs
=
corpusToDocs
groupNgramsWithTrees
c
phyloBase
phyloDocs
=
corpusToDocs
groupNgramsWithTrees
c
phyloBase
--------------------------------------
--------------------------------------
phyloBase
::
Phylo
phyloBase
::
Phylo
phyloBase
=
toPhyloBase
q
c
a
phyloBase
=
toPhyloBase
q
(
initPhyloParam
(
Just
defaultPhyloVersion
)
(
Just
defaultSoftware
)
(
Just
q
))
c
a
--------------------------------------
--------------------------------------
\ No newline at end of file
src/Gargantext/Viz/Phylo/Tools.hs
View file @
6b566317
This diff is collapsed.
Click to expand it.
src/Gargantext/Viz/Phylo/View/ViewMaker.hs
View file @
6b566317
...
@@ -125,21 +125,25 @@ addChildNodes shouldDo lvl lvlMin vb fl p v =
...
@@ -125,21 +125,25 @@ addChildNodes shouldDo lvl lvlMin vb fl p v =
-- | To transform a PhyloQuery into a PhyloView
-- | To transform a PhyloQuery into a PhyloView
queryT
oView
::
PhyloQueryView
->
Phylo
->
PhyloView
toPhyl
oView
::
PhyloQueryView
->
Phylo
->
PhyloView
queryT
oView
q
p
=
processDisplay
(
q
^.
qv_display
)
toPhyl
oView
q
p
=
processDisplay
(
q
^.
qv_display
)
$
processSort
(
q
^.
qv_sort
)
p
$
processSort
(
q
^.
qv_sort
)
p
$
processTaggers
(
q
^.
qv_taggers
)
p
$
processTaggers
(
q
^.
qv_taggers
)
p
$
processFilters
(
q
^.
qv_filters
)
p
$
processFilters
(
q
^.
qv_filters
)
p
$
processMetrics
(
q
^.
qv_metrics
)
p
$
processMetrics
(
q
^.
qv_metrics
)
p
$
addChildNodes
(
q
^.
qv_childs
)
(
q
^.
qv_lvl
)
(
q
^.
qv_childsDepth
)
(
q
^.
qv_verbose
)
(
q
^.
qv_filiation
)
p
$
addChildNodes
(
q
^.
qv_childs
)
(
q
^.
qv_lvl
)
(
q
^.
qv_childsDepth
)
(
q
^.
qv_verbose
)
(
q
^.
qv_filiation
)
p
$
initPhyloView
(
q
^.
qv_lvl
)
"Phylo2000"
"This is a Phylo"
(
q
^.
qv_filiation
)
(
q
^.
qv_verbose
)
p
$
initPhyloView
(
q
^.
qv_lvl
)
(
getPhyloTitle
p
)
(
getPhyloDescription
p
)
(
q
^.
qv_filiation
)
(
q
^.
qv_verbose
)
p
-- | dirty params
phyloParams
::
PhyloParam
phyloParams
=
PhyloParam
"v0.1"
(
Software
"Gargantext"
"v4"
)
""
Nothing
-- | To get the PhyloParam of a Phylo
-- | To do : effectively get the PhyloParams of a Phylo
getPhyloParams
::
Phylo
->
PhyloParam
getPhyloParams
::
Phylo
->
PhyloParam
getPhyloParams
p
=
phyloParams
getPhyloParams
=
_phylo_param
\ No newline at end of file
-- | To get the title of a Phylo
getPhyloTitle
::
Phylo
->
Text
getPhyloTitle
p
=
_q_phyloTitle
$
_phyloParam_query
$
getPhyloParams
p
-- | To get the desc of a Phylo
getPhyloDescription
::
Phylo
->
Text
getPhyloDescription
p
=
_q_phyloTitle
$
_phyloParam_query
$
getPhyloParams
p
\ No newline at end of file
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