2 Module : Gargantext.Types.Nodes
3 Description : Main Types of Nodes
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 terms.
15 The main type is Phylo which is synonym of Phylomemy (only difference is
18 Phylomemy was first described in [REF].
21 {-# LANGUAGE DeriveGeneric #-}
22 {-# LANGUAGE TemplateHaskell #-}
23 {-# LANGUAGE OverloadedStrings #-}
24 {-# LANGUAGE FlexibleInstances #-}
26 module Gargantext.Types.Phylo where
28 import Data.Aeson (ToJSON, FromJSON)
29 import Data.Maybe (Maybe)
30 import Data.Text (Text)
31 import Data.Time (UTCTime)
33 import GHC.Generics (Generic)
35 import Gargantext.Prelude
37 ------------------------------------------------------------------------
38 -- | Phylo datatype descriptors:
39 -- Period: time Segment of the whole phylomemy in UTCTime format (start,end)
40 -- Terms : list of all (possible) terms contained in the phylomemy (with their id)
41 -- Steps : list of all steps to build the phylomemy
42 data Phylo = Phylo { _phyloPeriod :: (Start, End)
43 , _phyloNgrams :: [Ngram]
44 , _phyloSteps :: [PhyloStep]
47 type Ngram = (NgramId, Text)
53 -- | PhyloStep data type descriptor
54 -- Period: tuple (start date, end date) of the step of the phylomemy
55 -- Levels: levels of granularity
56 data PhyloStep = PhyloStep { _phyloStepPeriod :: (Start, End)
57 , _phyloStepLevels :: [Level]
60 -- | Level of a step of a Phylomemy
61 -- Label: maybe has a label as text
62 -- Terms: set of terms that build the group
63 -- Temporal Parents: directed and weighted link to Parents
64 -- Levels description:
65 -- Level 0: Ngram equals itself (by identity) == _phyloNgrams
66 -- Level 1: Semantic grouping (by stems + by qualitative expert meaning)
67 -- Level 2: Frequent Item Set groups (by statistics)
68 -- Level 3: Clustering (by statistics)
69 data Level = Level { _levelLabel :: Maybe Text
70 , _levelTerms :: [NgramId]
72 , _levelTemporalParents :: [NgramId]
73 , _levelTemporalChilds :: [NgramId]
75 , _levelGranularityParents :: [NgramId]
76 , _levelGranularityChilds :: [NgramId]
80 instance FromJSON Phylo
83 instance FromJSON PhyloStep
84 instance ToJSON PhyloStep
86 instance FromJSON Level