2 Module : Gargantext.Viz.Phylo.Tools
3 Description : Phylomemy Tools to build/manage it
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
13 {-# LANGUAGE NoImplicitPrelude #-}
14 {-# LANGUAGE FlexibleContexts #-}
15 {-# LANGUAGE OverloadedStrings #-}
17 module Gargantext.Viz.Phylo.Tools
20 import Control.Lens hiding (both)
21 import Data.Tuple.Extra
22 import Gargantext.Prelude hiding (head)
23 import Gargantext.Viz.Phylo
24 import qualified Data.List as List
28 -- | To get Ngrams out of a Gargantext.Viz.Phylo.PhyloGroup
29 getNgrams :: PhyloGroup -> [Int]
30 getNgrams = _phylo_groupNgrams
32 getGroups :: Phylo -> [PhyloGroup]
33 getGroups = view (phylo_periods . traverse . phylo_periodLevels . traverse . phylo_levelGroups)
35 getGroupId :: PhyloGroup -> PhyloGroupId
36 getGroupId = view (phylo_groupId)
38 getGroupLvl :: PhyloGroup -> Int
39 getGroupLvl = snd . fst . getGroupId
41 getGroupPeriod :: PhyloGroup -> (Date,Date)
42 getGroupPeriod = fst . fst . getGroupId
44 getGroupsByLevelAndPeriod :: Int -> (Date,Date) -> Phylo -> [PhyloGroup]
45 getGroupsByLevelAndPeriod lvl period p = List.filter testGroup (getGroups p)
47 testGroup group = (getGroupLvl group == lvl )
48 && (getGroupPeriod group == period)