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.Core.Utils.Prefix (unPrefix)
37 import Gargantext.Prelude
39 ------------------------------------------------------------------------
40 -- | Phylo datatype descriptor of a phylomemy
41 -- Duration : time Segment of the whole phylomemy (start,end)
42 -- Ngrams : list of all (possible) terms contained in the phylomemy (with their id)
43 -- Steps : list of all steps to build the phylomemy
45 Phylo { _phylo_Duration :: (Start, End)
46 , _phylo_Ngrams :: [Ngram]
47 , _phylo_Periods :: [PhyloPeriod]
51 -- | UTCTime in seconds since UNIX epoch
52 type Start = POSIXTime
56 type Ngram = (NgramId, 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 :: [NgramId]
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 )