]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Viz/AdaptativePhylo.hs
working on the adaptative matching
[gargantext.git] / src / Gargantext / Viz / AdaptativePhylo.hs
1 {-|
2 Module : Gargantext.Viz.AdaptativePhylo
3 Description : Phylomemy definitions and types.
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Specifications of Phylomemy export format.
11
12 Phylomemy can be described as a Temporal Graph with different scale of
13 granularity of group of ngrams (terms and multi-terms).
14
15 The main type is Phylo which is synonym of Phylomemy (only difference is
16 the number of chars).
17
18 References:
19 Chavalarias, D., Cointet, J.-P., 2013. Phylomemetic patterns
20 in science evolution — the rise and fall of scientific fields. PloS
21 one 8, e54847.
22 -}
23
24 {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
25 {-# LANGUAGE NoImplicitPrelude #-}
26 {-# LANGUAGE TemplateHaskell #-}
27 {-# LANGUAGE MultiParamTypeClasses #-}
28
29 module Gargantext.Viz.AdaptativePhylo where
30
31 import Data.Aeson
32 import Data.Aeson.TH (deriveJSON)
33 import Data.Text (Text)
34 import Data.Vector (Vector)
35
36 import Gargantext.Core.Utils.Prefix (unPrefix)
37 import Gargantext.Prelude
38 import Gargantext.Text.Context (TermList)
39
40 import GHC.Generics
41 import GHC.IO (FilePath)
42 import Control.DeepSeq (NFData)
43 import Control.Lens (makeLenses)
44
45
46 ----------------
47 -- | Config | --
48 ----------------
49
50
51 data CorpusParser = Wos | Csv deriving (Show,Generic)
52
53 data Config =
54 Config { corpusPath :: FilePath
55 , listPath :: FilePath
56 , outputPath :: FilePath
57 , corpusParser :: CorpusParser
58 , corpusLimit :: Int
59 , phyloName :: Text
60 , phyloLevel :: Int
61 , timePeriod :: Int
62 , timeStep :: Int
63 , fisSupport :: Int
64 , fisSize :: Int
65 , branchSize :: Int
66 , safeParall :: Bool
67 } deriving (Show,Generic)
68
69 instance FromJSON Config
70 instance ToJSON Config
71 instance FromJSON CorpusParser
72 instance ToJSON CorpusParser
73
74
75 ------------------
76 -- | Document | --
77 ------------------
78
79
80 -- | Date : a simple Integer
81 type Date = Int
82
83 -- | Ngrams : a contiguous sequence of n terms
84 type Ngrams = Text
85
86 -- | Document : a piece of Text linked to a Date
87 data Document = Document
88 { date :: Date
89 , text :: [Ngrams]
90 } deriving (Show,Generic,NFData)
91
92
93 --------------------
94 -- | Foundation | --
95 --------------------
96
97
98 -- | The Foundations of a Phylo created from a given TermList
99 data PhyloFoundations = PhyloFoundations
100 { _foundations_roots :: !(Vector Ngrams)
101 , _foundations_mapList :: TermList
102 } deriving (Generic, Show, Eq)
103
104
105 ----------------
106 -- | Lenses | --
107 ----------------
108
109 makeLenses ''PhyloFoundations
110
111 ------------------------
112 -- | JSON instances | --
113 ------------------------
114
115
116 $(deriveJSON (unPrefix "_foundations_" ) ''PhyloFoundations)