2 Module : Gargantext.Viz.Phylo
3 Description : Phylomemy definitions and types.
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 Specifications of Phylomemy format.
12 Phylomemy can be described as a Temporal Graph with different scale of
13 granularity of group of ngrams (terms and multi-terms).
15 The main type is Phylo which is synonym of Phylomemy (only difference is
19 Chavalarias, D., Cointet, J.-P., 2013. Phylomemetic patterns
20 in science evolution — the rise and fall of scientific fields. PloS
25 {-# LANGUAGE DeriveGeneric #-}
26 {-# LANGUAGE NoImplicitPrelude #-}
27 {-# LANGUAGE TemplateHaskell #-}
29 module Gargantext.Viz.Phylo where
31 import Data.Aeson.TH (deriveJSON)
32 import Data.Maybe (Maybe)
33 import Data.Text (Text)
34 import Data.Time.Clock.POSIX (POSIXTime)
35 import GHC.Generics (Generic)
36 import Gargantext.Database.Schema.Ngrams (NgramsId)
37 import Gargantext.Core.Utils.Prefix (unPrefix)
38 import Gargantext.Prelude
40 ------------------------------------------------------------------------
41 -- | Phylo datatype descriptor of a phylomemy
42 -- Duration : time Segment of the whole phylomemy (start,end)
43 -- Ngrams : list of all (possible) terms contained in the phylomemy (with their id)
44 -- Steps : list of all steps to build the phylomemy
46 Phylo { _phylo_puration :: (Start, End)
47 , _phylo_ngrams :: [Ngram]
48 , _phylo_periods :: [PhyloPeriod]
52 -- | UTCTime in seconds since UNIX epoch
53 type Start = POSIXTime
57 type Ngram = (NgramsId, Text)
59 -- | PhyloStep : steps of phylomemy on temporal axis
60 -- Period: tuple (start date, end date) of the step of the phylomemy
61 -- Levels: levels of granularity
63 PhyloPeriod { _phylo_periodId :: PhyloPeriodId
64 , _phylo_periodLevels :: [PhyloLevel]
68 type PhyloPeriodId = (Start, End)
70 -- | PhyloLevel : levels of phylomemy on level axis
71 -- Levels description:
72 -- Level -1: Ngram equals itself (by identity) == _phylo_Ngrams
73 -- Level 0: Group of synonyms (by stems + by qualitative expert meaning)
74 -- Level 1: First level of clustering
75 -- Level N: Nth level of clustering
77 PhyloLevel { _phylo_levelId :: PhyloLevelId
78 , _phylo_levelGroups :: [PhyloGroup]
82 type PhyloLevelId = (PhyloPeriodId, Int)
84 -- | PhyloGroup : group of ngrams at each level and step
85 -- Label : maybe has a label as text
86 -- Ngrams: set of terms that build the group
87 -- Period Parents|Childs: weighted link to Parents|Childs (Temporal Period axis)
88 -- Level Parents|Childs: weighted link to Parents|Childs (Level Granularity axis)
90 PhyloGroup { _phylo_groupId :: PhyloGroupId
91 , _phylo_groupLabel :: Maybe Text
92 , _phylo_groupNgrams :: [NgramsId]
94 , _phylo_groupPeriodParents :: [Edge]
95 , _phylo_groupPeriodChilds :: [Edge]
97 , _phylo_groupLevelParents :: [Edge]
98 , _phylo_groupLevelChilds :: [Edge]
102 type PhyloGroupId = (PhyloLevelId, Int)
103 type Edge = (PhyloGroupId, Weight)
107 $(deriveJSON (unPrefix "_phylo_" ) ''Phylo )
108 $(deriveJSON (unPrefix "_phylo_period" ) ''PhyloPeriod )
109 $(deriveJSON (unPrefix "_phylo_level" ) ''PhyloLevel )
110 $(deriveJSON (unPrefix "_phylo_group" ) ''PhyloGroup )