]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Viz/Phylo/PhyloTools.hs
working on the adaptative matching
[gargantext.git] / src / Gargantext / Viz / Phylo / PhyloTools.hs
1 {-|
2 Module : Gargantext.Viz.Phylo.PhyloTools
3 Description : Module dedicated to all the tools needed for making a Phylo
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9 -}
10
11 {-# LANGUAGE FlexibleContexts #-}
12 {-# LANGUAGE NoImplicitPrelude #-}
13 {-# LANGUAGE OverloadedStrings #-}
14 {-# LANGUAGE RankNTypes #-}
15 {-# LANGUAGE ViewPatterns #-}
16
17 module Gargantext.Viz.Phylo.PhyloTools where
18
19 import Data.Maybe (Maybe, fromMaybe)
20 import Data.Text (Text)
21 import Data.Vector (Vector)
22
23 import Gargantext.Prelude
24 import Gargantext.Viz.AdaptativePhylo
25
26 import GHC.IO (FilePath)
27
28 import qualified Data.Vector as Vector
29
30
31 ----------------
32 -- | Config | --
33 ----------------
34
35 -- | Define a default value
36 def :: a -> Maybe a -> a
37 def = fromMaybe
38
39
40 -- | To init a configuration
41 initConfig :: Maybe FilePath -> Maybe FilePath -> Maybe FilePath -> Maybe CorpusParser -> Maybe Int -> Maybe Text
42 -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Bool -> Config
43 initConfig (def "" -> corpus) (def "" -> mapList) (def "" -> output) (def Csv -> parser) (def 10000 -> limit) (def "A phylomemy" -> name)
44 (def 2 -> level) (def 3 -> period) (def 1 -> step) (def 3 -> support) (def 4 -> clique) (def 3 -> minBranchSize) (def True -> safe) =
45 Config corpus mapList output parser limit name level period step support clique minBranchSize safe
46
47
48 ---------------------
49 -- | Foundations | --
50 ---------------------
51
52
53 -- | Is this Ngrams a Foundations Root ?
54 isRoots :: Ngrams -> Vector Ngrams -> Bool
55 isRoots n ns = Vector.elem n ns