{-|
Module      : Gargantext.Core.Viz.AdaptativePhylo
Description : Phylomemy definitions and types.
Copyright   : (c) CNRS, 2017-Present
License     : AGPL + CECILL v3
Maintainer  : team@gargantext.org
Stability   : experimental
Portability : POSIX

Specifications of Phylomemy export format.

Phylomemy can be described as a Temporal Graph with different scale of
granularity of group of ngrams (terms and multi-terms).

The main type is Phylo which is synonym of Phylomemy (only difference is
the number of chars).

References:
Chavalarias, D., Cointet, J.-P., 2013. Phylomemetic patterns
in science evolution — the rise and fall of scientific fields. PloS
one 8, e54847.
-}

{-# LANGUAGE DeriveAnyClass   #-}
{-# LANGUAGE TemplateHaskell   #-}

module Gargantext.Core.Viz.AdaptativePhylo where

import Data.Aeson
import Data.Aeson.TH (deriveJSON)
import Data.Text   (Text, pack)
import Data.Vector (Vector)
import Data.Map (Map)

import Gargantext.Core.Utils.Prefix (unPrefix)
import Gargantext.Prelude
import Gargantext.Core.Text.Context (TermList)

import GHC.Generics
import GHC.IO (FilePath)
import Control.DeepSeq (NFData)
import Control.Lens (makeLenses)

import qualified Data.Text.Lazy as TextLazy


----------------
-- | Config | --
----------------  


data CorpusParser = 
      Wos  {CorpusParser -> Int
_wos_limit  :: Int}
    | Csv  {CorpusParser -> Int
_csv_limit  :: Int}
    | Csv' {CorpusParser -> Int
_csv'_limit :: Int}
    deriving (Int -> CorpusParser -> ShowS
[CorpusParser] -> ShowS
CorpusParser -> String
(Int -> CorpusParser -> ShowS)
-> (CorpusParser -> String)
-> ([CorpusParser] -> ShowS)
-> Show CorpusParser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CorpusParser] -> ShowS
$cshowList :: [CorpusParser] -> ShowS
show :: CorpusParser -> String
$cshow :: CorpusParser -> String
showsPrec :: Int -> CorpusParser -> ShowS
$cshowsPrec :: Int -> CorpusParser -> ShowS
Show,(forall x. CorpusParser -> Rep CorpusParser x)
-> (forall x. Rep CorpusParser x -> CorpusParser)
-> Generic CorpusParser
forall x. Rep CorpusParser x -> CorpusParser
forall x. CorpusParser -> Rep CorpusParser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CorpusParser x -> CorpusParser
$cfrom :: forall x. CorpusParser -> Rep CorpusParser x
Generic,CorpusParser -> CorpusParser -> Bool
(CorpusParser -> CorpusParser -> Bool)
-> (CorpusParser -> CorpusParser -> Bool) -> Eq CorpusParser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CorpusParser -> CorpusParser -> Bool
$c/= :: CorpusParser -> CorpusParser -> Bool
== :: CorpusParser -> CorpusParser -> Bool
$c== :: CorpusParser -> CorpusParser -> Bool
Eq) 

data SeaElevation = 
      Constante  
      { SeaElevation -> Double
_cons_start :: Double
      , SeaElevation -> Double
_cons_step  :: Double }
    | Adaptative 
      { SeaElevation -> Double
_adap_granularity :: Double }
    deriving (Int -> SeaElevation -> ShowS
[SeaElevation] -> ShowS
SeaElevation -> String
(Int -> SeaElevation -> ShowS)
-> (SeaElevation -> String)
-> ([SeaElevation] -> ShowS)
-> Show SeaElevation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SeaElevation] -> ShowS
$cshowList :: [SeaElevation] -> ShowS
show :: SeaElevation -> String
$cshow :: SeaElevation -> String
showsPrec :: Int -> SeaElevation -> ShowS
$cshowsPrec :: Int -> SeaElevation -> ShowS
Show,(forall x. SeaElevation -> Rep SeaElevation x)
-> (forall x. Rep SeaElevation x -> SeaElevation)
-> Generic SeaElevation
forall x. Rep SeaElevation x -> SeaElevation
forall x. SeaElevation -> Rep SeaElevation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SeaElevation x -> SeaElevation
$cfrom :: forall x. SeaElevation -> Rep SeaElevation x
Generic,SeaElevation -> SeaElevation -> Bool
(SeaElevation -> SeaElevation -> Bool)
-> (SeaElevation -> SeaElevation -> Bool) -> Eq SeaElevation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SeaElevation -> SeaElevation -> Bool
$c/= :: SeaElevation -> SeaElevation -> Bool
== :: SeaElevation -> SeaElevation -> Bool
$c== :: SeaElevation -> SeaElevation -> Bool
Eq)

data Proximity = 
      WeightedLogJaccard 
      { Proximity -> Double
_wlj_sensibility   :: Double
{-
      -- , _wlj_thresholdInit :: Double
      -- , _wlj_thresholdStep :: Double
      -- | max height for sea level in temporal matching
      -- , _wlj_elevation     :: Double
-}
      }
    | WeightedLogSim 
      { _wlj_sensibility   :: Double
{-
      -- , _wlj_thresholdInit :: Double
      -- , _wlj_thresholdStep :: Double
      -- | max height for sea level in temporal matching
      -- , _wlj_elevation     :: Double
-}
      } 
    | Hamming 
    deriving (Int -> Proximity -> ShowS
[Proximity] -> ShowS
Proximity -> String
(Int -> Proximity -> ShowS)
-> (Proximity -> String)
-> ([Proximity] -> ShowS)
-> Show Proximity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Proximity] -> ShowS
$cshowList :: [Proximity] -> ShowS
show :: Proximity -> String
$cshow :: Proximity -> String
showsPrec :: Int -> Proximity -> ShowS
$cshowsPrec :: Int -> Proximity -> ShowS
Show,(forall x. Proximity -> Rep Proximity x)
-> (forall x. Rep Proximity x -> Proximity) -> Generic Proximity
forall x. Rep Proximity x -> Proximity
forall x. Proximity -> Rep Proximity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Proximity x -> Proximity
$cfrom :: forall x. Proximity -> Rep Proximity x
Generic,Proximity -> Proximity -> Bool
(Proximity -> Proximity -> Bool)
-> (Proximity -> Proximity -> Bool) -> Eq Proximity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Proximity -> Proximity -> Bool
$c/= :: Proximity -> Proximity -> Bool
== :: Proximity -> Proximity -> Bool
$c== :: Proximity -> Proximity -> Bool
Eq) 


data SynchronyScope = SingleBranch | SiblingBranches | AllBranches deriving (Int -> SynchronyScope -> ShowS
[SynchronyScope] -> ShowS
SynchronyScope -> String
(Int -> SynchronyScope -> ShowS)
-> (SynchronyScope -> String)
-> ([SynchronyScope] -> ShowS)
-> Show SynchronyScope
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SynchronyScope] -> ShowS
$cshowList :: [SynchronyScope] -> ShowS
show :: SynchronyScope -> String
$cshow :: SynchronyScope -> String
showsPrec :: Int -> SynchronyScope -> ShowS
$cshowsPrec :: Int -> SynchronyScope -> ShowS
Show,(forall x. SynchronyScope -> Rep SynchronyScope x)
-> (forall x. Rep SynchronyScope x -> SynchronyScope)
-> Generic SynchronyScope
forall x. Rep SynchronyScope x -> SynchronyScope
forall x. SynchronyScope -> Rep SynchronyScope x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SynchronyScope x -> SynchronyScope
$cfrom :: forall x. SynchronyScope -> Rep SynchronyScope x
Generic,SynchronyScope -> SynchronyScope -> Bool
(SynchronyScope -> SynchronyScope -> Bool)
-> (SynchronyScope -> SynchronyScope -> Bool) -> Eq SynchronyScope
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SynchronyScope -> SynchronyScope -> Bool
$c/= :: SynchronyScope -> SynchronyScope -> Bool
== :: SynchronyScope -> SynchronyScope -> Bool
$c== :: SynchronyScope -> SynchronyScope -> Bool
Eq)

data SynchronyStrategy = MergeRegularGroups | MergeAllGroups deriving (Int -> SynchronyStrategy -> ShowS
[SynchronyStrategy] -> ShowS
SynchronyStrategy -> String
(Int -> SynchronyStrategy -> ShowS)
-> (SynchronyStrategy -> String)
-> ([SynchronyStrategy] -> ShowS)
-> Show SynchronyStrategy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SynchronyStrategy] -> ShowS
$cshowList :: [SynchronyStrategy] -> ShowS
show :: SynchronyStrategy -> String
$cshow :: SynchronyStrategy -> String
showsPrec :: Int -> SynchronyStrategy -> ShowS
$cshowsPrec :: Int -> SynchronyStrategy -> ShowS
Show,(forall x. SynchronyStrategy -> Rep SynchronyStrategy x)
-> (forall x. Rep SynchronyStrategy x -> SynchronyStrategy)
-> Generic SynchronyStrategy
forall x. Rep SynchronyStrategy x -> SynchronyStrategy
forall x. SynchronyStrategy -> Rep SynchronyStrategy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SynchronyStrategy x -> SynchronyStrategy
$cfrom :: forall x. SynchronyStrategy -> Rep SynchronyStrategy x
Generic,SynchronyStrategy -> SynchronyStrategy -> Bool
(SynchronyStrategy -> SynchronyStrategy -> Bool)
-> (SynchronyStrategy -> SynchronyStrategy -> Bool)
-> Eq SynchronyStrategy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SynchronyStrategy -> SynchronyStrategy -> Bool
$c/= :: SynchronyStrategy -> SynchronyStrategy -> Bool
== :: SynchronyStrategy -> SynchronyStrategy -> Bool
$c== :: SynchronyStrategy -> SynchronyStrategy -> Bool
Eq)

data Synchrony = 
      ByProximityThreshold
      { Synchrony -> Double
_bpt_threshold :: Double 
      , Synchrony -> Double
_bpt_sensibility :: Double
      , Synchrony -> SynchronyScope
_bpt_scope :: SynchronyScope
      , Synchrony -> SynchronyStrategy
_bpt_strategy :: SynchronyStrategy }
    | ByProximityDistribution
      { Synchrony -> Double
_bpd_sensibility :: Double
      , Synchrony -> SynchronyStrategy
_bpd_strategy :: SynchronyStrategy } 
    deriving (Int -> Synchrony -> ShowS
[Synchrony] -> ShowS
Synchrony -> String
(Int -> Synchrony -> ShowS)
-> (Synchrony -> String)
-> ([Synchrony] -> ShowS)
-> Show Synchrony
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Synchrony] -> ShowS
$cshowList :: [Synchrony] -> ShowS
show :: Synchrony -> String
$cshow :: Synchrony -> String
showsPrec :: Int -> Synchrony -> ShowS
$cshowsPrec :: Int -> Synchrony -> ShowS
Show,(forall x. Synchrony -> Rep Synchrony x)
-> (forall x. Rep Synchrony x -> Synchrony) -> Generic Synchrony
forall x. Rep Synchrony x -> Synchrony
forall x. Synchrony -> Rep Synchrony x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Synchrony x -> Synchrony
$cfrom :: forall x. Synchrony -> Rep Synchrony x
Generic,Synchrony -> Synchrony -> Bool
(Synchrony -> Synchrony -> Bool)
-> (Synchrony -> Synchrony -> Bool) -> Eq Synchrony
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Synchrony -> Synchrony -> Bool
$c/= :: Synchrony -> Synchrony -> Bool
== :: Synchrony -> Synchrony -> Bool
$c== :: Synchrony -> Synchrony -> Bool
Eq)     


data TimeUnit = 
      Year 
      { TimeUnit -> Int
_year_period :: Int
      , TimeUnit -> Int
_year_step   :: Int
      , TimeUnit -> Int
_year_matchingFrame :: Int }
    | Month 
      { TimeUnit -> Int
_month_period :: Int
      , TimeUnit -> Int
_month_step   :: Int
      , TimeUnit -> Int
_month_matchingFrame :: Int }      
    | Week 
      { TimeUnit -> Int
_week_period :: Int
      , TimeUnit -> Int
_week_step   :: Int
      , TimeUnit -> Int
_week_matchingFrame :: Int }
    | Day 
      { TimeUnit -> Int
_day_period :: Int
      , TimeUnit -> Int
_day_step   :: Int
      , TimeUnit -> Int
_day_matchingFrame :: Int }      
      deriving (Int -> TimeUnit -> ShowS
[TimeUnit] -> ShowS
TimeUnit -> String
(Int -> TimeUnit -> ShowS)
-> (TimeUnit -> String) -> ([TimeUnit] -> ShowS) -> Show TimeUnit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeUnit] -> ShowS
$cshowList :: [TimeUnit] -> ShowS
show :: TimeUnit -> String
$cshow :: TimeUnit -> String
showsPrec :: Int -> TimeUnit -> ShowS
$cshowsPrec :: Int -> TimeUnit -> ShowS
Show,(forall x. TimeUnit -> Rep TimeUnit x)
-> (forall x. Rep TimeUnit x -> TimeUnit) -> Generic TimeUnit
forall x. Rep TimeUnit x -> TimeUnit
forall x. TimeUnit -> Rep TimeUnit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeUnit x -> TimeUnit
$cfrom :: forall x. TimeUnit -> Rep TimeUnit x
Generic,TimeUnit -> TimeUnit -> Bool
(TimeUnit -> TimeUnit -> Bool)
-> (TimeUnit -> TimeUnit -> Bool) -> Eq TimeUnit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeUnit -> TimeUnit -> Bool
$c/= :: TimeUnit -> TimeUnit -> Bool
== :: TimeUnit -> TimeUnit -> Bool
$c== :: TimeUnit -> TimeUnit -> Bool
Eq) 

data CliqueFilter = ByThreshold | ByNeighbours deriving (Int -> CliqueFilter -> ShowS
[CliqueFilter] -> ShowS
CliqueFilter -> String
(Int -> CliqueFilter -> ShowS)
-> (CliqueFilter -> String)
-> ([CliqueFilter] -> ShowS)
-> Show CliqueFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CliqueFilter] -> ShowS
$cshowList :: [CliqueFilter] -> ShowS
show :: CliqueFilter -> String
$cshow :: CliqueFilter -> String
showsPrec :: Int -> CliqueFilter -> ShowS
$cshowsPrec :: Int -> CliqueFilter -> ShowS
Show,(forall x. CliqueFilter -> Rep CliqueFilter x)
-> (forall x. Rep CliqueFilter x -> CliqueFilter)
-> Generic CliqueFilter
forall x. Rep CliqueFilter x -> CliqueFilter
forall x. CliqueFilter -> Rep CliqueFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CliqueFilter x -> CliqueFilter
$cfrom :: forall x. CliqueFilter -> Rep CliqueFilter x
Generic,CliqueFilter -> CliqueFilter -> Bool
(CliqueFilter -> CliqueFilter -> Bool)
-> (CliqueFilter -> CliqueFilter -> Bool) -> Eq CliqueFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CliqueFilter -> CliqueFilter -> Bool
$c/= :: CliqueFilter -> CliqueFilter -> Bool
== :: CliqueFilter -> CliqueFilter -> Bool
$c== :: CliqueFilter -> CliqueFilter -> Bool
Eq)

data Clique = 
      Fis 
      { Clique -> Int
_fis_support :: Int
      , Clique -> Int
_fis_size    :: Int }
    | MaxClique
      { Clique -> Int
_mcl_size      :: Int
      , Clique -> Double
_mcl_threshold :: Double
      , Clique -> CliqueFilter
_mcl_filter    :: CliqueFilter } 
      deriving (Int -> Clique -> ShowS
[Clique] -> ShowS
Clique -> String
(Int -> Clique -> ShowS)
-> (Clique -> String) -> ([Clique] -> ShowS) -> Show Clique
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Clique] -> ShowS
$cshowList :: [Clique] -> ShowS
show :: Clique -> String
$cshow :: Clique -> String
showsPrec :: Int -> Clique -> ShowS
$cshowsPrec :: Int -> Clique -> ShowS
Show,(forall x. Clique -> Rep Clique x)
-> (forall x. Rep Clique x -> Clique) -> Generic Clique
forall x. Rep Clique x -> Clique
forall x. Clique -> Rep Clique x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Clique x -> Clique
$cfrom :: forall x. Clique -> Rep Clique x
Generic,Clique -> Clique -> Bool
(Clique -> Clique -> Bool)
-> (Clique -> Clique -> Bool) -> Eq Clique
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Clique -> Clique -> Bool
$c/= :: Clique -> Clique -> Bool
== :: Clique -> Clique -> Bool
$c== :: Clique -> Clique -> Bool
Eq)      


data Quality = 
     Quality { Quality -> Double
_qua_granularity :: Double
             , Quality -> Int
_qua_minBranch   :: Int }
      deriving (Int -> Quality -> ShowS
[Quality] -> ShowS
Quality -> String
(Int -> Quality -> ShowS)
-> (Quality -> String) -> ([Quality] -> ShowS) -> Show Quality
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Quality] -> ShowS
$cshowList :: [Quality] -> ShowS
show :: Quality -> String
$cshow :: Quality -> String
showsPrec :: Int -> Quality -> ShowS
$cshowsPrec :: Int -> Quality -> ShowS
Show,(forall x. Quality -> Rep Quality x)
-> (forall x. Rep Quality x -> Quality) -> Generic Quality
forall x. Rep Quality x -> Quality
forall x. Quality -> Rep Quality x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Quality x -> Quality
$cfrom :: forall x. Quality -> Rep Quality x
Generic,Quality -> Quality -> Bool
(Quality -> Quality -> Bool)
-> (Quality -> Quality -> Bool) -> Eq Quality
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Quality -> Quality -> Bool
$c/= :: Quality -> Quality -> Bool
== :: Quality -> Quality -> Bool
$c== :: Quality -> Quality -> Bool
Eq)   


data Config = 
     Config { Config -> String
corpusPath     :: FilePath
            , Config -> String
listPath       :: FilePath
            , Config -> String
outputPath     :: FilePath
            , Config -> CorpusParser
corpusParser   :: CorpusParser
            , Config -> Text
phyloName      :: Text
            , Config -> Int
phyloLevel     :: Int
            , Config -> Proximity
phyloProximity :: Proximity
            , Config -> SeaElevation
seaElevation   :: SeaElevation
            , Config -> Bool
findAncestors  :: Bool
            , Config -> Synchrony
phyloSynchrony :: Synchrony
            , Config -> Quality
phyloQuality   :: Quality
            , Config -> TimeUnit
timeUnit       :: TimeUnit
            , Config -> Clique
clique         :: Clique
            , Config -> [PhyloLabel]
exportLabel    :: [PhyloLabel]
            , Config -> Sort
exportSort     :: Sort
            , Config -> [Filter]
exportFilter   :: [Filter]  
            } deriving (Int -> Config -> ShowS
[Config] -> ShowS
Config -> String
(Int -> Config -> ShowS)
-> (Config -> String) -> ([Config] -> ShowS) -> Show Config
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Config] -> ShowS
$cshowList :: [Config] -> ShowS
show :: Config -> String
$cshow :: Config -> String
showsPrec :: Int -> Config -> ShowS
$cshowsPrec :: Int -> Config -> ShowS
Show,(forall x. Config -> Rep Config x)
-> (forall x. Rep Config x -> Config) -> Generic Config
forall x. Rep Config x -> Config
forall x. Config -> Rep Config x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Config x -> Config
$cfrom :: forall x. Config -> Rep Config x
Generic,Config -> Config -> Bool
(Config -> Config -> Bool)
-> (Config -> Config -> Bool) -> Eq Config
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Config -> Config -> Bool
$c/= :: Config -> Config -> Bool
== :: Config -> Config -> Bool
$c== :: Config -> Config -> Bool
Eq)


defaultConfig :: Config
defaultConfig :: Config
defaultConfig = 
     Config :: String
-> String
-> String
-> CorpusParser
-> Text
-> Int
-> Proximity
-> SeaElevation
-> Bool
-> Synchrony
-> Quality
-> TimeUnit
-> Clique
-> [PhyloLabel]
-> Sort
-> [Filter]
-> Config
Config { corpusPath :: String
corpusPath     = String
""
            , listPath :: String
listPath       = String
""
            , outputPath :: String
outputPath     = String
""
            , corpusParser :: CorpusParser
corpusParser   = Int -> CorpusParser
Csv Int
1000
            , phyloName :: Text
phyloName      = String -> Text
pack String
"Default Phylo"
            , phyloLevel :: Int
phyloLevel     = Int
2
            , phyloProximity :: Proximity
phyloProximity = Double -> Proximity
WeightedLogJaccard Double
10
            , seaElevation :: SeaElevation
seaElevation   = Double -> Double -> SeaElevation
Constante Double
0.1 Double
0.1
            , findAncestors :: Bool
findAncestors  = Bool
True
            , phyloSynchrony :: Synchrony
phyloSynchrony = Double
-> Double -> SynchronyScope -> SynchronyStrategy -> Synchrony
ByProximityThreshold Double
0.1 Double
10 SynchronyScope
SiblingBranches SynchronyStrategy
MergeAllGroups
            , phyloQuality :: Quality
phyloQuality   = Double -> Int -> Quality
Quality Double
0 Int
1
            , timeUnit :: TimeUnit
timeUnit       = Int -> Int -> Int -> TimeUnit
Year Int
3 Int
1 Int
5
            , clique :: Clique
clique         = Int -> Double -> CliqueFilter -> Clique
MaxClique Int
0 Double
3 CliqueFilter
ByNeighbours
            , exportLabel :: [PhyloLabel]
exportLabel    = [Tagger -> Int -> PhyloLabel
BranchLabel Tagger
MostEmergentTfIdf Int
2, Tagger -> Int -> PhyloLabel
GroupLabel Tagger
MostEmergentInclusive Int
2]
            , exportSort :: Sort
exportSort     = Sort
ByHierarchy
            , exportFilter :: [Filter]
exportFilter   = [Double -> Filter
ByBranchSize Double
2]  
            }

instance FromJSON Config
instance ToJSON Config
instance FromJSON CorpusParser
instance ToJSON CorpusParser
instance FromJSON Proximity
instance ToJSON Proximity
instance FromJSON SeaElevation
instance ToJSON SeaElevation
instance FromJSON TimeUnit
instance ToJSON TimeUnit
instance FromJSON CliqueFilter
instance ToJSON CliqueFilter
instance FromJSON Clique
instance ToJSON Clique
instance FromJSON PhyloLabel
instance ToJSON PhyloLabel
instance FromJSON Tagger
instance ToJSON Tagger
instance FromJSON Sort
instance ToJSON Sort
instance FromJSON Order
instance ToJSON Order
instance FromJSON Filter
instance ToJSON Filter
instance FromJSON SynchronyScope
instance ToJSON SynchronyScope
instance FromJSON SynchronyStrategy
instance ToJSON SynchronyStrategy
instance FromJSON Synchrony
instance ToJSON Synchrony
instance FromJSON Quality
instance ToJSON Quality


-- | Software parameters
data Software =
     Software { Software -> Text
_software_name    :: Text
              , Software -> Text
_software_version :: Text
     } deriving ((forall x. Software -> Rep Software x)
-> (forall x. Rep Software x -> Software) -> Generic Software
forall x. Rep Software x -> Software
forall x. Software -> Rep Software x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Software x -> Software
$cfrom :: forall x. Software -> Rep Software x
Generic, Int -> Software -> ShowS
[Software] -> ShowS
Software -> String
(Int -> Software -> ShowS)
-> (Software -> String) -> ([Software] -> ShowS) -> Show Software
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Software] -> ShowS
$cshowList :: [Software] -> ShowS
show :: Software -> String
$cshow :: Software -> String
showsPrec :: Int -> Software -> ShowS
$cshowsPrec :: Int -> Software -> ShowS
Show, Software -> Software -> Bool
(Software -> Software -> Bool)
-> (Software -> Software -> Bool) -> Eq Software
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Software -> Software -> Bool
$c/= :: Software -> Software -> Bool
== :: Software -> Software -> Bool
$c== :: Software -> Software -> Bool
Eq)

defaultSoftware :: Software
defaultSoftware :: Software
defaultSoftware = 
      Software :: Text -> Text -> Software
Software { _software_name :: Text
_software_name    = String -> Text
pack String
"Gargantext"
               , _software_version :: Text
_software_version = String -> Text
pack String
"v4" }


-- | Global parameters of a Phylo
data PhyloParam =
     PhyloParam { PhyloParam -> Text
_phyloParam_version  :: Text
                , PhyloParam -> Software
_phyloParam_software :: Software
                , PhyloParam -> Config
_phyloParam_config   :: Config
     } deriving ((forall x. PhyloParam -> Rep PhyloParam x)
-> (forall x. Rep PhyloParam x -> PhyloParam) -> Generic PhyloParam
forall x. Rep PhyloParam x -> PhyloParam
forall x. PhyloParam -> Rep PhyloParam x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloParam x -> PhyloParam
$cfrom :: forall x. PhyloParam -> Rep PhyloParam x
Generic, Int -> PhyloParam -> ShowS
[PhyloParam] -> ShowS
PhyloParam -> String
(Int -> PhyloParam -> ShowS)
-> (PhyloParam -> String)
-> ([PhyloParam] -> ShowS)
-> Show PhyloParam
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloParam] -> ShowS
$cshowList :: [PhyloParam] -> ShowS
show :: PhyloParam -> String
$cshow :: PhyloParam -> String
showsPrec :: Int -> PhyloParam -> ShowS
$cshowsPrec :: Int -> PhyloParam -> ShowS
Show, PhyloParam -> PhyloParam -> Bool
(PhyloParam -> PhyloParam -> Bool)
-> (PhyloParam -> PhyloParam -> Bool) -> Eq PhyloParam
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloParam -> PhyloParam -> Bool
$c/= :: PhyloParam -> PhyloParam -> Bool
== :: PhyloParam -> PhyloParam -> Bool
$c== :: PhyloParam -> PhyloParam -> Bool
Eq)

defaultPhyloParam :: PhyloParam
defaultPhyloParam :: PhyloParam
defaultPhyloParam =
      PhyloParam :: Text -> Software -> Config -> PhyloParam
PhyloParam { _phyloParam_version :: Text
_phyloParam_version  = String -> Text
pack String
"v2.adaptative"
                 , _phyloParam_software :: Software
_phyloParam_software = Software
defaultSoftware
                 , _phyloParam_config :: Config
_phyloParam_config   = Config
defaultConfig }


------------------
-- | Document | --
------------------

-- | Date : a simple Integer
type Date = Int

-- | Ngrams : a contiguous sequence of n terms
type Ngrams = Text

-- Document : a piece of Text linked to a Date
-- date = computational date; date' = original string date yyyy-mm-dd
data Document = Document
      { Document -> Int
date    :: Date
      , Document -> Text
date'   :: Text
      , Document -> [Text]
text    :: [Ngrams]
      , Document -> Maybe Double
weight  :: Maybe Double
      , Document -> [Text]
sources :: [Text]
      } deriving (Document -> Document -> Bool
(Document -> Document -> Bool)
-> (Document -> Document -> Bool) -> Eq Document
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Document -> Document -> Bool
$c/= :: Document -> Document -> Bool
== :: Document -> Document -> Bool
$c== :: Document -> Document -> Bool
Eq,Int -> Document -> ShowS
[Document] -> ShowS
Document -> String
(Int -> Document -> ShowS)
-> (Document -> String) -> ([Document] -> ShowS) -> Show Document
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Document] -> ShowS
$cshowList :: [Document] -> ShowS
show :: Document -> String
$cshow :: Document -> String
showsPrec :: Int -> Document -> ShowS
$cshowsPrec :: Int -> Document -> ShowS
Show,(forall x. Document -> Rep Document x)
-> (forall x. Rep Document x -> Document) -> Generic Document
forall x. Rep Document x -> Document
forall x. Document -> Rep Document x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Document x -> Document
$cfrom :: forall x. Document -> Rep Document x
Generic,Document -> ()
(Document -> ()) -> NFData Document
forall a. (a -> ()) -> NFData a
rnf :: Document -> ()
$crnf :: Document -> ()
NFData)  


--------------------
-- | Foundation | --
--------------------


-- | The Foundations of a Phylo created from a given TermList 
data PhyloFoundations = PhyloFoundations
      { PhyloFoundations -> Vector Text
_foundations_roots   :: !(Vector Ngrams)
      , PhyloFoundations -> TermList
_foundations_mapList :: TermList
      } deriving ((forall x. PhyloFoundations -> Rep PhyloFoundations x)
-> (forall x. Rep PhyloFoundations x -> PhyloFoundations)
-> Generic PhyloFoundations
forall x. Rep PhyloFoundations x -> PhyloFoundations
forall x. PhyloFoundations -> Rep PhyloFoundations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloFoundations x -> PhyloFoundations
$cfrom :: forall x. PhyloFoundations -> Rep PhyloFoundations x
Generic, Int -> PhyloFoundations -> ShowS
[PhyloFoundations] -> ShowS
PhyloFoundations -> String
(Int -> PhyloFoundations -> ShowS)
-> (PhyloFoundations -> String)
-> ([PhyloFoundations] -> ShowS)
-> Show PhyloFoundations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloFoundations] -> ShowS
$cshowList :: [PhyloFoundations] -> ShowS
show :: PhyloFoundations -> String
$cshow :: PhyloFoundations -> String
showsPrec :: Int -> PhyloFoundations -> ShowS
$cshowsPrec :: Int -> PhyloFoundations -> ShowS
Show, PhyloFoundations -> PhyloFoundations -> Bool
(PhyloFoundations -> PhyloFoundations -> Bool)
-> (PhyloFoundations -> PhyloFoundations -> Bool)
-> Eq PhyloFoundations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloFoundations -> PhyloFoundations -> Bool
$c/= :: PhyloFoundations -> PhyloFoundations -> Bool
== :: PhyloFoundations -> PhyloFoundations -> Bool
$c== :: PhyloFoundations -> PhyloFoundations -> Bool
Eq)


data PhyloSources = PhyloSources
      { PhyloSources -> Vector Text
_sources :: !(Vector Text) } deriving ((forall x. PhyloSources -> Rep PhyloSources x)
-> (forall x. Rep PhyloSources x -> PhyloSources)
-> Generic PhyloSources
forall x. Rep PhyloSources x -> PhyloSources
forall x. PhyloSources -> Rep PhyloSources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloSources x -> PhyloSources
$cfrom :: forall x. PhyloSources -> Rep PhyloSources x
Generic, Int -> PhyloSources -> ShowS
[PhyloSources] -> ShowS
PhyloSources -> String
(Int -> PhyloSources -> ShowS)
-> (PhyloSources -> String)
-> ([PhyloSources] -> ShowS)
-> Show PhyloSources
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloSources] -> ShowS
$cshowList :: [PhyloSources] -> ShowS
show :: PhyloSources -> String
$cshow :: PhyloSources -> String
showsPrec :: Int -> PhyloSources -> ShowS
$cshowsPrec :: Int -> PhyloSources -> ShowS
Show, PhyloSources -> PhyloSources -> Bool
(PhyloSources -> PhyloSources -> Bool)
-> (PhyloSources -> PhyloSources -> Bool) -> Eq PhyloSources
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloSources -> PhyloSources -> Bool
$c/= :: PhyloSources -> PhyloSources -> Bool
== :: PhyloSources -> PhyloSources -> Bool
$c== :: PhyloSources -> PhyloSources -> Bool
Eq)


---------------------------
-- | Coocurency Matrix | --
---------------------------


-- | Cooc : a coocurency matrix between two ngrams
type Cooc =  Map (Int,Int) Double


-------------------
-- | Phylomemy | --
-------------------


-- | Phylo datatype of a phylomemy
--  foundations : the foundations of the phylo
--  timeCooc : a Map of coocurency by minimal unit of time (ex: by year)
--  timeDocs : a Map with the numbers of docs by minimal unit of time (ex: by year)
--  param : the parameters of the phylomemy (with the user's configuration)
--  periods : the temporal steps of a phylomemy
data Phylo =
     Phylo { Phylo -> PhyloFoundations
_phylo_foundations  :: PhyloFoundations
           , Phylo -> PhyloSources
_phylo_sources      :: PhyloSources
           , Phylo -> Map Int Cooc
_phylo_timeCooc     :: !(Map Date Cooc)
           , Phylo -> Map Int Double
_phylo_timeDocs     :: !(Map Date Double)
           , Phylo -> Map Int Double
_phylo_termFreq     :: !(Map Int Double)
           , Phylo -> Map Int Double
_phylo_lastTermFreq :: !(Map Int Double)           
           , Phylo -> Map (PhyloGroupId, PhyloGroupId) Double
_phylo_horizon      :: !(Map (PhyloGroupId,PhyloGroupId) Double)           
           , Phylo -> Map (PhyloGroupId, PhyloGroupId) Double
_phylo_groupsProxi  :: !(Map (PhyloGroupId,PhyloGroupId) Double)
           , Phylo -> PhyloParam
_phylo_param        :: PhyloParam
           , Phylo -> Map PhyloPeriodId PhyloPeriod
_phylo_periods      :: Map PhyloPeriodId PhyloPeriod
           }
           deriving ((forall x. Phylo -> Rep Phylo x)
-> (forall x. Rep Phylo x -> Phylo) -> Generic Phylo
forall x. Rep Phylo x -> Phylo
forall x. Phylo -> Rep Phylo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Phylo x -> Phylo
$cfrom :: forall x. Phylo -> Rep Phylo x
Generic, Int -> Phylo -> ShowS
[Phylo] -> ShowS
Phylo -> String
(Int -> Phylo -> ShowS)
-> (Phylo -> String) -> ([Phylo] -> ShowS) -> Show Phylo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Phylo] -> ShowS
$cshowList :: [Phylo] -> ShowS
show :: Phylo -> String
$cshow :: Phylo -> String
showsPrec :: Int -> Phylo -> ShowS
$cshowsPrec :: Int -> Phylo -> ShowS
Show, Phylo -> Phylo -> Bool
(Phylo -> Phylo -> Bool) -> (Phylo -> Phylo -> Bool) -> Eq Phylo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Phylo -> Phylo -> Bool
$c/= :: Phylo -> Phylo -> Bool
== :: Phylo -> Phylo -> Bool
$c== :: Phylo -> Phylo -> Bool
Eq)


-- | PhyloPeriodId : the id of a given period
type PhyloPeriodId = (Date,Date)

-- | PhyloPeriod : steps of a phylomemy on a temporal axis
--  id: tuple (start date, end date) of the temporal step of the phylomemy
--  levels: levels of granularity
data PhyloPeriod =
     PhyloPeriod { PhyloPeriod -> PhyloPeriodId
_phylo_periodPeriod  :: (Date,Date)
                 , PhyloPeriod -> (Text, Text)
_phylo_periodPeriod' :: (Text,Text)
                 , PhyloPeriod -> Map PhyloLevelId PhyloLevel
_phylo_periodLevels  :: Map PhyloLevelId PhyloLevel
                 } deriving ((forall x. PhyloPeriod -> Rep PhyloPeriod x)
-> (forall x. Rep PhyloPeriod x -> PhyloPeriod)
-> Generic PhyloPeriod
forall x. Rep PhyloPeriod x -> PhyloPeriod
forall x. PhyloPeriod -> Rep PhyloPeriod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloPeriod x -> PhyloPeriod
$cfrom :: forall x. PhyloPeriod -> Rep PhyloPeriod x
Generic, Int -> PhyloPeriod -> ShowS
[PhyloPeriod] -> ShowS
PhyloPeriod -> String
(Int -> PhyloPeriod -> ShowS)
-> (PhyloPeriod -> String)
-> ([PhyloPeriod] -> ShowS)
-> Show PhyloPeriod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloPeriod] -> ShowS
$cshowList :: [PhyloPeriod] -> ShowS
show :: PhyloPeriod -> String
$cshow :: PhyloPeriod -> String
showsPrec :: Int -> PhyloPeriod -> ShowS
$cshowsPrec :: Int -> PhyloPeriod -> ShowS
Show, PhyloPeriod -> PhyloPeriod -> Bool
(PhyloPeriod -> PhyloPeriod -> Bool)
-> (PhyloPeriod -> PhyloPeriod -> Bool) -> Eq PhyloPeriod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloPeriod -> PhyloPeriod -> Bool
$c/= :: PhyloPeriod -> PhyloPeriod -> Bool
== :: PhyloPeriod -> PhyloPeriod -> Bool
$c== :: PhyloPeriod -> PhyloPeriod -> Bool
Eq)   


-- | Level : a level of clustering
type Level = Int

-- | PhyloLevelId : the id of a level of clustering in a given period 
type PhyloLevelId  = (PhyloPeriodId,Level)

-- | PhyloLevel : levels of phylomemy on a synchronic axis
-- Levels description:
-- Level 0: The foundations and the base of the phylo
-- Level 1: First level of clustering (the Fis)
-- Level [2..N]: Nth level of synchronic clustering (cluster of Fis)
data PhyloLevel =
     PhyloLevel { PhyloLevel -> PhyloPeriodId
_phylo_levelPeriod  :: (Date,Date)
                , PhyloLevel -> (Text, Text)
_phylo_levelPeriod' :: (Text,Text)
                , PhyloLevel -> Int
_phylo_levelLevel   :: Level 
                , PhyloLevel -> Map PhyloGroupId PhyloGroup
_phylo_levelGroups  :: Map PhyloGroupId PhyloGroup
                } 
                deriving ((forall x. PhyloLevel -> Rep PhyloLevel x)
-> (forall x. Rep PhyloLevel x -> PhyloLevel) -> Generic PhyloLevel
forall x. Rep PhyloLevel x -> PhyloLevel
forall x. PhyloLevel -> Rep PhyloLevel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloLevel x -> PhyloLevel
$cfrom :: forall x. PhyloLevel -> Rep PhyloLevel x
Generic, Int -> PhyloLevel -> ShowS
[PhyloLevel] -> ShowS
PhyloLevel -> String
(Int -> PhyloLevel -> ShowS)
-> (PhyloLevel -> String)
-> ([PhyloLevel] -> ShowS)
-> Show PhyloLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloLevel] -> ShowS
$cshowList :: [PhyloLevel] -> ShowS
show :: PhyloLevel -> String
$cshow :: PhyloLevel -> String
showsPrec :: Int -> PhyloLevel -> ShowS
$cshowsPrec :: Int -> PhyloLevel -> ShowS
Show, PhyloLevel -> PhyloLevel -> Bool
(PhyloLevel -> PhyloLevel -> Bool)
-> (PhyloLevel -> PhyloLevel -> Bool) -> Eq PhyloLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloLevel -> PhyloLevel -> Bool
$c/= :: PhyloLevel -> PhyloLevel -> Bool
== :: PhyloLevel -> PhyloLevel -> Bool
$c== :: PhyloLevel -> PhyloLevel -> Bool
Eq)   


type PhyloGroupId  = (PhyloLevelId, Int)

-- | BranchId : (a level, a sequence of branch index)
-- the sequence is a path of heritage from the most to the less specific branch
type PhyloBranchId = (Level, [Int])

-- | PhyloGroup : group of ngrams at each level and period
data PhyloGroup = 
      PhyloGroup { PhyloGroup -> PhyloPeriodId
_phylo_groupPeriod   :: (Date,Date)
                 , PhyloGroup -> (Text, Text)
_phylo_groupPeriod'  :: (Text,Text)
                 , PhyloGroup -> Int
_phylo_groupLevel    :: Level
                 , PhyloGroup -> Int
_phylo_groupIndex    :: Int         
                 , PhyloGroup -> Text
_phylo_groupLabel    :: Text
                 , PhyloGroup -> Int
_phylo_groupSupport  :: Support
                 , PhyloGroup -> Maybe Double
_phylo_groupWeight   :: Maybe Double
                 , PhyloGroup -> [Int]
_phylo_groupSources  :: [Int]                 
                 , PhyloGroup -> [Int]
_phylo_groupNgrams   :: [Int]
                 , PhyloGroup -> Cooc
_phylo_groupCooc     :: !(Cooc)
                 , PhyloGroup -> PhyloBranchId
_phylo_groupBranchId :: PhyloBranchId
                 , PhyloGroup -> Map Text [Double]
_phylo_groupMeta     :: Map Text [Double]
                 , PhyloGroup -> [Pointer]
_phylo_groupLevelParents  :: [Pointer]
                 , PhyloGroup -> [Pointer]
_phylo_groupLevelChilds   :: [Pointer]
                 , PhyloGroup -> [Pointer]
_phylo_groupPeriodParents :: [Pointer]
                 , PhyloGroup -> [Pointer]
_phylo_groupPeriodChilds  :: [Pointer]
                 , PhyloGroup -> [Pointer]
_phylo_groupAncestors     :: [Pointer]
                 }
                 deriving ((forall x. PhyloGroup -> Rep PhyloGroup x)
-> (forall x. Rep PhyloGroup x -> PhyloGroup) -> Generic PhyloGroup
forall x. Rep PhyloGroup x -> PhyloGroup
forall x. PhyloGroup -> Rep PhyloGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloGroup x -> PhyloGroup
$cfrom :: forall x. PhyloGroup -> Rep PhyloGroup x
Generic, Int -> PhyloGroup -> ShowS
[PhyloGroup] -> ShowS
PhyloGroup -> String
(Int -> PhyloGroup -> ShowS)
-> (PhyloGroup -> String)
-> ([PhyloGroup] -> ShowS)
-> Show PhyloGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloGroup] -> ShowS
$cshowList :: [PhyloGroup] -> ShowS
show :: PhyloGroup -> String
$cshow :: PhyloGroup -> String
showsPrec :: Int -> PhyloGroup -> ShowS
$cshowsPrec :: Int -> PhyloGroup -> ShowS
Show, PhyloGroup -> PhyloGroup -> Bool
(PhyloGroup -> PhyloGroup -> Bool)
-> (PhyloGroup -> PhyloGroup -> Bool) -> Eq PhyloGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloGroup -> PhyloGroup -> Bool
$c/= :: PhyloGroup -> PhyloGroup -> Bool
== :: PhyloGroup -> PhyloGroup -> Bool
$c== :: PhyloGroup -> PhyloGroup -> Bool
Eq, PhyloGroup -> ()
(PhyloGroup -> ()) -> NFData PhyloGroup
forall a. (a -> ()) -> NFData a
rnf :: PhyloGroup -> ()
$crnf :: PhyloGroup -> ()
NFData)

-- | Weight : A generic mesure that can be associated with an Id
type Weight = Double

-- | Pointer : A weighted pointer to a given PhyloGroup
type Pointer = (PhyloGroupId, Weight)

data Filiation = ToParents | ToChilds deriving ((forall x. Filiation -> Rep Filiation x)
-> (forall x. Rep Filiation x -> Filiation) -> Generic Filiation
forall x. Rep Filiation x -> Filiation
forall x. Filiation -> Rep Filiation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Filiation x -> Filiation
$cfrom :: forall x. Filiation -> Rep Filiation x
Generic, Int -> Filiation -> ShowS
[Filiation] -> ShowS
Filiation -> String
(Int -> Filiation -> ShowS)
-> (Filiation -> String)
-> ([Filiation] -> ShowS)
-> Show Filiation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Filiation] -> ShowS
$cshowList :: [Filiation] -> ShowS
show :: Filiation -> String
$cshow :: Filiation -> String
showsPrec :: Int -> Filiation -> ShowS
$cshowsPrec :: Int -> Filiation -> ShowS
Show)    
data PointerType = TemporalPointer | LevelPointer deriving ((forall x. PointerType -> Rep PointerType x)
-> (forall x. Rep PointerType x -> PointerType)
-> Generic PointerType
forall x. Rep PointerType x -> PointerType
forall x. PointerType -> Rep PointerType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PointerType x -> PointerType
$cfrom :: forall x. PointerType -> Rep PointerType x
Generic, Int -> PointerType -> ShowS
[PointerType] -> ShowS
PointerType -> String
(Int -> PointerType -> ShowS)
-> (PointerType -> String)
-> ([PointerType] -> ShowS)
-> Show PointerType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PointerType] -> ShowS
$cshowList :: [PointerType] -> ShowS
show :: PointerType -> String
$cshow :: PointerType -> String
showsPrec :: Int -> PointerType -> ShowS
$cshowsPrec :: Int -> PointerType -> ShowS
Show)                


----------------------
-- | Phylo Clique | --
----------------------

-- | Support : Number of Documents where a Clique occurs
type Support  = Int

data PhyloClique = PhyloClique
  { PhyloClique -> [Int]
_phyloClique_nodes   :: [Int]
  , PhyloClique -> Int
_phyloClique_support :: Support
  , PhyloClique -> PhyloPeriodId
_phyloClique_period  :: (Date,Date)
  , PhyloClique -> Maybe Double
_phyloClique_weight  :: Maybe Double
  , PhyloClique -> [Int]
_phyloClique_sources :: [Int]
  } deriving ((forall x. PhyloClique -> Rep PhyloClique x)
-> (forall x. Rep PhyloClique x -> PhyloClique)
-> Generic PhyloClique
forall x. Rep PhyloClique x -> PhyloClique
forall x. PhyloClique -> Rep PhyloClique x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloClique x -> PhyloClique
$cfrom :: forall x. PhyloClique -> Rep PhyloClique x
Generic,PhyloClique -> ()
(PhyloClique -> ()) -> NFData PhyloClique
forall a. (a -> ()) -> NFData a
rnf :: PhyloClique -> ()
$crnf :: PhyloClique -> ()
NFData,Int -> PhyloClique -> ShowS
[PhyloClique] -> ShowS
PhyloClique -> String
(Int -> PhyloClique -> ShowS)
-> (PhyloClique -> String)
-> ([PhyloClique] -> ShowS)
-> Show PhyloClique
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloClique] -> ShowS
$cshowList :: [PhyloClique] -> ShowS
show :: PhyloClique -> String
$cshow :: PhyloClique -> String
showsPrec :: Int -> PhyloClique -> ShowS
$cshowsPrec :: Int -> PhyloClique -> ShowS
Show,PhyloClique -> PhyloClique -> Bool
(PhyloClique -> PhyloClique -> Bool)
-> (PhyloClique -> PhyloClique -> Bool) -> Eq PhyloClique
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloClique -> PhyloClique -> Bool
$c/= :: PhyloClique -> PhyloClique -> Bool
== :: PhyloClique -> PhyloClique -> Bool
$c== :: PhyloClique -> PhyloClique -> Bool
Eq)

----------------
-- | Export | --
----------------

type DotId = TextLazy.Text

data EdgeType = GroupToGroup | BranchToGroup | BranchToBranch | GroupToAncestor | PeriodToPeriod deriving (Int -> EdgeType -> ShowS
[EdgeType] -> ShowS
EdgeType -> String
(Int -> EdgeType -> ShowS)
-> (EdgeType -> String) -> ([EdgeType] -> ShowS) -> Show EdgeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EdgeType] -> ShowS
$cshowList :: [EdgeType] -> ShowS
show :: EdgeType -> String
$cshow :: EdgeType -> String
showsPrec :: Int -> EdgeType -> ShowS
$cshowsPrec :: Int -> EdgeType -> ShowS
Show,(forall x. EdgeType -> Rep EdgeType x)
-> (forall x. Rep EdgeType x -> EdgeType) -> Generic EdgeType
forall x. Rep EdgeType x -> EdgeType
forall x. EdgeType -> Rep EdgeType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EdgeType x -> EdgeType
$cfrom :: forall x. EdgeType -> Rep EdgeType x
Generic,EdgeType -> EdgeType -> Bool
(EdgeType -> EdgeType -> Bool)
-> (EdgeType -> EdgeType -> Bool) -> Eq EdgeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EdgeType -> EdgeType -> Bool
$c/= :: EdgeType -> EdgeType -> Bool
== :: EdgeType -> EdgeType -> Bool
$c== :: EdgeType -> EdgeType -> Bool
Eq)

data Filter = ByBranchSize { Filter -> Double
_branch_size :: Double } deriving (Int -> Filter -> ShowS
[Filter] -> ShowS
Filter -> String
(Int -> Filter -> ShowS)
-> (Filter -> String) -> ([Filter] -> ShowS) -> Show Filter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Filter] -> ShowS
$cshowList :: [Filter] -> ShowS
show :: Filter -> String
$cshow :: Filter -> String
showsPrec :: Int -> Filter -> ShowS
$cshowsPrec :: Int -> Filter -> ShowS
Show,(forall x. Filter -> Rep Filter x)
-> (forall x. Rep Filter x -> Filter) -> Generic Filter
forall x. Rep Filter x -> Filter
forall x. Filter -> Rep Filter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Filter x -> Filter
$cfrom :: forall x. Filter -> Rep Filter x
Generic,Filter -> Filter -> Bool
(Filter -> Filter -> Bool)
-> (Filter -> Filter -> Bool) -> Eq Filter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Filter -> Filter -> Bool
$c/= :: Filter -> Filter -> Bool
== :: Filter -> Filter -> Bool
$c== :: Filter -> Filter -> Bool
Eq)

data Order = Asc | Desc deriving (Int -> Order -> ShowS
[Order] -> ShowS
Order -> String
(Int -> Order -> ShowS)
-> (Order -> String) -> ([Order] -> ShowS) -> Show Order
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Order] -> ShowS
$cshowList :: [Order] -> ShowS
show :: Order -> String
$cshow :: Order -> String
showsPrec :: Int -> Order -> ShowS
$cshowsPrec :: Int -> Order -> ShowS
Show,(forall x. Order -> Rep Order x)
-> (forall x. Rep Order x -> Order) -> Generic Order
forall x. Rep Order x -> Order
forall x. Order -> Rep Order x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Order x -> Order
$cfrom :: forall x. Order -> Rep Order x
Generic,Order -> Order -> Bool
(Order -> Order -> Bool) -> (Order -> Order -> Bool) -> Eq Order
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Order -> Order -> Bool
$c/= :: Order -> Order -> Bool
== :: Order -> Order -> Bool
$c== :: Order -> Order -> Bool
Eq)

data Sort = ByBirthDate { Sort -> Order
_sort_order :: Order } | ByHierarchy deriving (Int -> Sort -> ShowS
[Sort] -> ShowS
Sort -> String
(Int -> Sort -> ShowS)
-> (Sort -> String) -> ([Sort] -> ShowS) -> Show Sort
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sort] -> ShowS
$cshowList :: [Sort] -> ShowS
show :: Sort -> String
$cshow :: Sort -> String
showsPrec :: Int -> Sort -> ShowS
$cshowsPrec :: Int -> Sort -> ShowS
Show,(forall x. Sort -> Rep Sort x)
-> (forall x. Rep Sort x -> Sort) -> Generic Sort
forall x. Rep Sort x -> Sort
forall x. Sort -> Rep Sort x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Sort x -> Sort
$cfrom :: forall x. Sort -> Rep Sort x
Generic,Sort -> Sort -> Bool
(Sort -> Sort -> Bool) -> (Sort -> Sort -> Bool) -> Eq Sort
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sort -> Sort -> Bool
$c/= :: Sort -> Sort -> Bool
== :: Sort -> Sort -> Bool
$c== :: Sort -> Sort -> Bool
Eq)

data Tagger = MostInclusive | MostEmergentInclusive | MostEmergentTfIdf deriving (Int -> Tagger -> ShowS
[Tagger] -> ShowS
Tagger -> String
(Int -> Tagger -> ShowS)
-> (Tagger -> String) -> ([Tagger] -> ShowS) -> Show Tagger
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tagger] -> ShowS
$cshowList :: [Tagger] -> ShowS
show :: Tagger -> String
$cshow :: Tagger -> String
showsPrec :: Int -> Tagger -> ShowS
$cshowsPrec :: Int -> Tagger -> ShowS
Show,(forall x. Tagger -> Rep Tagger x)
-> (forall x. Rep Tagger x -> Tagger) -> Generic Tagger
forall x. Rep Tagger x -> Tagger
forall x. Tagger -> Rep Tagger x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Tagger x -> Tagger
$cfrom :: forall x. Tagger -> Rep Tagger x
Generic,Tagger -> Tagger -> Bool
(Tagger -> Tagger -> Bool)
-> (Tagger -> Tagger -> Bool) -> Eq Tagger
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tagger -> Tagger -> Bool
$c/= :: Tagger -> Tagger -> Bool
== :: Tagger -> Tagger -> Bool
$c== :: Tagger -> Tagger -> Bool
Eq)

data PhyloLabel = 
      BranchLabel
      { PhyloLabel -> Tagger
_branch_labelTagger :: Tagger
      , PhyloLabel -> Int
_branch_labelSize   :: Int }
    | GroupLabel
      { PhyloLabel -> Tagger
_group_labelTagger  :: Tagger
      , PhyloLabel -> Int
_group_labelSize    :: Int }
    deriving (Int -> PhyloLabel -> ShowS
[PhyloLabel] -> ShowS
PhyloLabel -> String
(Int -> PhyloLabel -> ShowS)
-> (PhyloLabel -> String)
-> ([PhyloLabel] -> ShowS)
-> Show PhyloLabel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloLabel] -> ShowS
$cshowList :: [PhyloLabel] -> ShowS
show :: PhyloLabel -> String
$cshow :: PhyloLabel -> String
showsPrec :: Int -> PhyloLabel -> ShowS
$cshowsPrec :: Int -> PhyloLabel -> ShowS
Show,(forall x. PhyloLabel -> Rep PhyloLabel x)
-> (forall x. Rep PhyloLabel x -> PhyloLabel) -> Generic PhyloLabel
forall x. Rep PhyloLabel x -> PhyloLabel
forall x. PhyloLabel -> Rep PhyloLabel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloLabel x -> PhyloLabel
$cfrom :: forall x. PhyloLabel -> Rep PhyloLabel x
Generic,PhyloLabel -> PhyloLabel -> Bool
(PhyloLabel -> PhyloLabel -> Bool)
-> (PhyloLabel -> PhyloLabel -> Bool) -> Eq PhyloLabel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloLabel -> PhyloLabel -> Bool
$c/= :: PhyloLabel -> PhyloLabel -> Bool
== :: PhyloLabel -> PhyloLabel -> Bool
$c== :: PhyloLabel -> PhyloLabel -> Bool
Eq)

data PhyloBranch =
      PhyloBranch
      { PhyloBranch -> PhyloBranchId
_branch_id :: PhyloBranchId
      , PhyloBranch -> [Int]
_branch_canonId  :: [Int]
      , PhyloBranch -> [Double]
_branch_seaLevel :: [Double]
      , PhyloBranch -> Double
_branch_x        :: Double
      , PhyloBranch -> Double
_branch_y        :: Double
      , PhyloBranch -> Double
_branch_w        :: Double
      , PhyloBranch -> Double
_branch_t        :: Double
      , PhyloBranch -> Text
_branch_label    :: Text
      , PhyloBranch -> Map Text [Double]
_branch_meta     :: Map Text [Double]
      } deriving ((forall x. PhyloBranch -> Rep PhyloBranch x)
-> (forall x. Rep PhyloBranch x -> PhyloBranch)
-> Generic PhyloBranch
forall x. Rep PhyloBranch x -> PhyloBranch
forall x. PhyloBranch -> Rep PhyloBranch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloBranch x -> PhyloBranch
$cfrom :: forall x. PhyloBranch -> Rep PhyloBranch x
Generic, Int -> PhyloBranch -> ShowS
[PhyloBranch] -> ShowS
PhyloBranch -> String
(Int -> PhyloBranch -> ShowS)
-> (PhyloBranch -> String)
-> ([PhyloBranch] -> ShowS)
-> Show PhyloBranch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloBranch] -> ShowS
$cshowList :: [PhyloBranch] -> ShowS
show :: PhyloBranch -> String
$cshow :: PhyloBranch -> String
showsPrec :: Int -> PhyloBranch -> ShowS
$cshowsPrec :: Int -> PhyloBranch -> ShowS
Show, PhyloBranch -> PhyloBranch -> Bool
(PhyloBranch -> PhyloBranch -> Bool)
-> (PhyloBranch -> PhyloBranch -> Bool) -> Eq PhyloBranch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhyloBranch -> PhyloBranch -> Bool
$c/= :: PhyloBranch -> PhyloBranch -> Bool
== :: PhyloBranch -> PhyloBranch -> Bool
$c== :: PhyloBranch -> PhyloBranch -> Bool
Eq)

data PhyloExport =
      PhyloExport
      { PhyloExport -> [PhyloGroup]
_export_groups    :: [PhyloGroup]
      , PhyloExport -> [PhyloBranch]
_export_branches  :: [PhyloBranch]
      } deriving ((forall x. PhyloExport -> Rep PhyloExport x)
-> (forall x. Rep PhyloExport x -> PhyloExport)
-> Generic PhyloExport
forall x. Rep PhyloExport x -> PhyloExport
forall x. PhyloExport -> Rep PhyloExport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhyloExport x -> PhyloExport
$cfrom :: forall x. PhyloExport -> Rep PhyloExport x
Generic, Int -> PhyloExport -> ShowS
[PhyloExport] -> ShowS
PhyloExport -> String
(Int -> PhyloExport -> ShowS)
-> (PhyloExport -> String)
-> ([PhyloExport] -> ShowS)
-> Show PhyloExport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloExport] -> ShowS
$cshowList :: [PhyloExport] -> ShowS
show :: PhyloExport -> String
$cshow :: PhyloExport -> String
showsPrec :: Int -> PhyloExport -> ShowS
$cshowsPrec :: Int -> PhyloExport -> ShowS
Show)

----------------
-- | Lenses | --
----------------

makeLenses ''Config
makeLenses ''Proximity
makeLenses ''SeaElevation
makeLenses ''Quality
makeLenses ''Clique
makeLenses ''PhyloLabel
makeLenses ''TimeUnit
makeLenses ''PhyloFoundations
makeLenses ''PhyloClique
makeLenses ''Phylo
makeLenses ''PhyloPeriod
makeLenses ''PhyloLevel
makeLenses ''PhyloGroup
makeLenses ''PhyloParam
makeLenses ''PhyloExport
makeLenses ''PhyloBranch

------------------------
-- | JSON instances | --
------------------------

instance FromJSON Phylo
instance ToJSON Phylo
instance FromJSON PhyloSources
instance ToJSON PhyloSources
instance FromJSON PhyloParam
instance ToJSON PhyloParam
instance FromJSON PhyloPeriod
instance ToJSON PhyloPeriod
instance FromJSON PhyloLevel
instance ToJSON PhyloLevel
instance FromJSON Software
instance ToJSON Software
instance FromJSON PhyloGroup
instance ToJSON PhyloGroup

$(deriveJSON (unPrefix "_foundations_"  ) ''PhyloFoundations)