]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Viz/Phylo/Tools.hs
Merge branch 'dev' into dev-phylo
[gargantext.git] / src / Gargantext / Viz / Phylo / Tools.hs
1 {-|
2 Module : Gargantext.Viz.Phylo.Tools
3 Description : Phylomemy tools
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Phylo Toolbox:
11 - functions to build a Phylo
12 - functions to filter the cliques
13 - functions to manage a Phylo
14
15 Group Functions (TODO list)
16 - cohesion sur un groupe
17 - distance au dernier branchement
18 - âge du groupe
19
20 Futre Idea: temporal zoom on Phylo
21 phyloZoomOut :: (PeriodGrain, Phylo) -> [(PeriodGrain, Phylo)]
22 (from smallest granularity, it increases (zoom out) the periods of the Phylo)
23 Moral idea: viz from out to in
24
25 -}
26
27 {-# LANGUAGE NoImplicitPrelude #-}
28 {-# LANGUAGE FlexibleContexts #-}
29 {-# LANGUAGE OverloadedStrings #-}
30
31 module Gargantext.Viz.Phylo.Tools where
32
33 import Data.Set (Set)
34 import Data.Map (Map)
35 import Data.Map as Map hiding (Map)
36 import Gargantext.Prelude
37 import Gargantext.Viz.Phylo
38 import Gargantext.Viz.Phylo.Example
39
40 -- | Some types to help reading
41 type Clique = Set Ngrams
42 type Support = Int
43 type MinSize = Int
44
45 -- | Building a phylo
46 -- (Indicative and schematic function)
47 buildPhylo :: Support -> MinSize
48 -> Map Clique Support -> Phylo
49 buildPhylo s m mcs = level2Phylo
50 . groups2level
51 . clusters2group
52 . map clique2cluster
53 . filterCliques s m
54
55 level2Phylo :: PhyloLevel -> Phylo -> Phylo
56 level2Phylo = undefined
57
58 groups2level :: [PhyloGroup] -> PhyloLevel
59 groups2level = undefined
60
61 clusters2group :: [Cluster Ngrams] -> PhyloGroup
62 clusters2group = undefined
63
64 clique2cluster :: Clique -> Cluster Ngrams
65 clique2cluster = undefined
66
67 -- | Filtering the cliques before bulding the Phylo
68 -- (Support and MinSize as parameter of the finale function to build a phylo)
69 -- idea: log of Corpus size (of docs)
70 filterCliques :: Support -> MinSize
71 -> Map Clique Support -> [Clique]
72 filterCliques s ms = maximalCliques
73 . filterWithSizeSet ms
74 . Map.keys
75 . filterWithSupport s
76
77 -- | Hapaxify / Threshold
78 -- hapax s = 1
79 -- ?
80 filterWithSupport :: Support -> Map Clique Support -> Map Clique Support
81 filterWithSupport s = Map.filter (>s)
82
83 filterWithSizeSet :: MinSize -> [Clique] -> [Clique]
84 filterWithSizeSet = undefined
85
86 -- | filtre les cliques de ngrams compris dans une clique plus grande
87 -- /!\ optim inside
88 maximalCliques :: [Clique] -> [Clique]
89 maximalCliques = undefined
90
91
92
93
94 -- | Phylo management
95
96 -- | PhyloLevel Management
97 viewGroups :: (Start,End) -> PhyloLevel -> Phylo -> [PhyloGroup]
98 viewGroups = undefined
99
100 viewLevels :: (Start,End) -> Phylo -> [PhyloLevel]
101 viewLevels = undefined
102
103 -- | tous les terme des champs, tous les parents et les enfants
104 setGroup :: PhyloGroup -> PhyloGroup -> PhyloGroup
105 setGroup = undefined
106 --removeTerms :: recalculer les cliques pour ces termes
107 --addTerms
108