Commit 04232270 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[PHYLO] adding groups.

parent 463f55dd
...@@ -19,10 +19,11 @@ Phylomemy was first described in [REF]. ...@@ -19,10 +19,11 @@ Phylomemy was first described in [REF].
-} -}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module Gargantext.Types.Phylo where module Gargantext.Types.Phylo where
import Data.Aeson (ToJSON, FromJSON) import Data.Aeson.TH (deriveJSON)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Data.Text (Text) import Data.Text (Text)
import Data.Time (UTCTime) import Data.Time (UTCTime)
...@@ -30,12 +31,13 @@ import Data.Time (UTCTime) ...@@ -30,12 +31,13 @@ import Data.Time (UTCTime)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Utils.Prefix (unPrefix)
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Phylo datatype descriptor -- | Phylo datatype descriptor of a phylomemy
-- Period: time Segment of the whole phylomemy in UTCTime format (start,end) -- Period : time Segment of the whole phylomemy in UTCTime format (start,end)
-- Ngrams : list of all (possible) terms contained in the phylomemy (with their id) -- Ngrams : list of all (possible) terms contained in the phylomemy (with their id)
-- Steps : list of all steps to build the phylomemy -- Steps : list of all steps to build the phylomemy
data Phylo = Phylo { _phyloPeriod :: (Start, End) data Phylo = Phylo { _phyloPeriod :: (Start, End)
, _phyloNgrams :: [Ngram] , _phyloNgrams :: [Ngram]
, _phyloSteps :: [PhyloStep] , _phyloSteps :: [PhyloStep]
...@@ -47,39 +49,41 @@ type End = UTCTime ...@@ -47,39 +49,41 @@ type End = UTCTime
type Ngram = (NgramId, Text) type Ngram = (NgramId, Text)
type NgramId = Int type NgramId = Int
-- | PhyloStep datatype descriptor -- | 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
data PhyloStep = PhyloStep { _phyloStepPeriod :: (Start, End) data PhyloStep = PhyloStep { _phyloStepPeriod :: (Start, End)
, _phyloStepLevels :: [Level] , _phyloStepLevels :: [PhyloLevel]
} deriving (Generic) } deriving (Generic)
-- | Level of a step of a Phylomemy descriptor -- | PhyloLevel : levels of phylomemy on level axis
-- Levels description:
-- Level 0: Ngram equals itself (by identity) == _phyloNgrams
-- Level 1: Group gathers synonyms (by stems + by qualitative expert meaning)
-- Level 2: Group is Frequent Item Set (by statistics)
-- Level 3: Group is a cluster or community (by statistics)
type PhyloLevel = [PhyloGroup]
-- | 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
-- Temporal Parents: directed and weighted link to Parents -- Temporal Parents|Childs: directed and weighted link to Parents|Childs (Temporal axis)
-- Levels description: -- Granularity Parents|Childs: directed and weighted link to Parents|Childs (Granularity axis)
-- Level 0: Ngram equals itself (by identity) == _phyloNgrams data PhyloGroup = PhyloGroup { _phyloGroupLabel :: Maybe Text
-- Level 1: Semantic grouping (by stems + by qualitative expert meaning) , _phyloGroupNgrams :: [NgramId]
-- Level 2: Frequent Item Set groups (by statistics)
-- Level 3: Clustering (by statistics)
data Level = Level { _levelLabel :: Maybe Text
, _levelNgrams :: [NgramId]
, _levelTemporalParents :: [NgramId] , _phyloGroupTemporalParents :: [Edge]
, _levelTemporalChilds :: [NgramId] , _phyloGroupTemporalChilds :: [Edge]
, _levelGranularityParents :: [NgramId] , _phyloGroupGranularityParents :: [Edge]
, _levelGranularityChilds :: [NgramId] , _phyloGroupGranularityChilds :: [Edge]
} deriving (Generic) } deriving (Generic)
-- | JSON instances type Edge = (NgramId, Weight)
instance FromJSON Phylo type Weight = Double
instance ToJSON Phylo
instance FromJSON PhyloStep
instance ToJSON PhyloStep
instance FromJSON Level
instance ToJSON Level
-- | JSON instances
$(deriveJSON (unPrefix "_phylo") ''Phylo)
$(deriveJSON (unPrefix "_phyloStep") ''PhyloStep)
$(deriveJSON (unPrefix "_phyloGroup") ''PhyloGroup)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment