Commit 7d6fcbbc authored by Quentin Lobbé's avatar Quentin Lobbé

harmonized functions and types

parent 7da5cfa2
Pipeline #196 failed with stage
...@@ -32,6 +32,9 @@ import Control.Lens (makeLenses) ...@@ -32,6 +32,9 @@ import Control.Lens (makeLenses)
import Data.Aeson.TH (deriveJSON) import Data.Aeson.TH (deriveJSON)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Data.Text (Text) import Data.Text (Text)
import Data.Set (Set)
import Data.Map (Map)
import Data.Vector (Vector)
import Data.Time.Clock.POSIX (POSIXTime) import Data.Time.Clock.POSIX (POSIXTime)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Gargantext.Database.Schema.Ngrams (NgramsId) import Gargantext.Database.Schema.Ngrams (NgramsId)
...@@ -67,17 +70,17 @@ data Software = ...@@ -67,17 +70,17 @@ data Software =
-- Steps : list of all steps to build the phylomemy -- Steps : list of all steps to build the phylomemy
data Phylo = data Phylo =
Phylo { _phylo_duration :: (Start, End) Phylo { _phylo_duration :: (Start, End)
, _phylo_ngrams :: [Ngram] , _phylo_ngrams :: PhyloNgrams
, _phylo_periods :: [PhyloPeriod] , _phylo_periods :: [PhyloPeriod]
} }
deriving (Generic) deriving (Generic, Show)
-- | UTCTime in seconds since UNIX epoch -- | UTCTime in seconds since UNIX epoch
type Start = POSIXTime -- type Start = POSIXTime
type End = POSIXTime -- type End = POSIXTime
type Start = Int
type End = Int
-- | Indexed Ngram
type Ngram = (NgramsId, Text)
-- | PhyloStep : steps of phylomemy on temporal axis -- | PhyloStep : steps of phylomemy on temporal axis
-- Period: tuple (start date, end date) of the step of the phylomemy -- Period: tuple (start date, end date) of the step of the phylomemy
...@@ -86,7 +89,7 @@ data PhyloPeriod = ...@@ -86,7 +89,7 @@ data PhyloPeriod =
PhyloPeriod { _phylo_periodId :: PhyloPeriodId PhyloPeriod { _phylo_periodId :: PhyloPeriodId
, _phylo_periodLevels :: [PhyloLevel] , _phylo_periodLevels :: [PhyloLevel]
} }
deriving (Generic) deriving (Generic, Show)
type PhyloPeriodId = (Start, End) type PhyloPeriodId = (Start, End)
...@@ -100,7 +103,7 @@ data PhyloLevel = ...@@ -100,7 +103,7 @@ data PhyloLevel =
PhyloLevel { _phylo_levelId :: PhyloLevelId PhyloLevel { _phylo_levelId :: PhyloLevelId
, _phylo_levelGroups :: [PhyloGroup] , _phylo_levelGroups :: [PhyloGroup]
} }
deriving (Generic) deriving (Generic, Show)
type PhyloLevelId = (PhyloPeriodId, Int) type PhyloLevelId = (PhyloPeriodId, Int)
...@@ -121,18 +124,35 @@ data PhyloGroup = ...@@ -121,18 +124,35 @@ data PhyloGroup =
, _phylo_groupLevelParents :: [Pointer] , _phylo_groupLevelParents :: [Pointer]
, _phylo_groupLevelChilds :: [Pointer] , _phylo_groupLevelChilds :: [Pointer]
} }
deriving (Generic) deriving (Generic, Show)
type PhyloGroupId = (PhyloLevelId, Int) type PhyloGroupId = (PhyloLevelId, Int)
type Pointer = (PhyloGroupId, Weight) type Pointer = (PhyloGroupId, Weight)
type Weight = Double type Weight = Double
-- | Ngrams : a contiguous sequence of n terms
type Ngrams = Text
-- | PhyloNgrams : Vector of all the Ngrams (PhyloGroup of level -1) used within a Phylo
type PhyloNgrams = Vector Ngrams
-- | Clique : Set of ngrams cooccurring in the same Document
type Clique = Set Ngrams
-- | Support : Number of Documents where a Clique occurs
type Support = Int
-- | Fis : Frequent Items Set (ie: the association between a Clique and a Support)
type Fis = Map Clique Support
-- | Lenses -- | Lenses
makeLenses ''Phylo makeLenses ''Phylo
makeLenses ''PhyloParam makeLenses ''PhyloParam
makeLenses ''PhyloExport makeLenses ''PhyloExport
makeLenses ''Software makeLenses ''Software
-- | JSON instances -- | JSON instances
$(deriveJSON (unPrefix "_phylo_" ) ''Phylo ) $(deriveJSON (unPrefix "_phylo_" ) ''Phylo )
$(deriveJSON (unPrefix "_phylo_period" ) ''PhyloPeriod ) $(deriveJSON (unPrefix "_phylo_period" ) ''PhyloPeriod )
......
This diff is collapsed.
...@@ -32,25 +32,22 @@ module Gargantext.Viz.Phylo.Tools where ...@@ -32,25 +32,22 @@ module Gargantext.Viz.Phylo.Tools where
import Data.Set (Set) import Data.Set (Set)
import Data.Map (Map) import Data.Map (Map)
import Data.Map as Map hiding (Map) import qualified Data.Map as Map
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Viz.Phylo import Gargantext.Viz.Phylo
import Gargantext.Viz.Phylo.Example import Gargantext.Viz.Phylo.Example
-- | Some types to help reading
type Clique = Set Ngrams
type Support = Int
type MinSize = Int type MinSize = Int
-- | Building a phylo -- | Building a phylo
-- (Indicative and schematic function) -- (Indicative and schematic function)
buildPhylo :: Support -> MinSize -- buildPhylo :: Support -> MinSize
-> Map Clique Support -> Phylo -- -> Map Clique Support -> Phylo
buildPhylo s m mcs = level2Phylo -- buildPhylo s m mcs = level2Phylo
. groups2level -- . groups2level
. clusters2group -- . clusters2group
. map clique2cluster -- . Map.map clique2cluster
. filterCliques s m -- . filterCliques s m
level2Phylo :: PhyloLevel -> Phylo -> Phylo level2Phylo :: PhyloLevel -> Phylo -> Phylo
level2Phylo = undefined level2Phylo = undefined
...@@ -58,11 +55,11 @@ level2Phylo = undefined ...@@ -58,11 +55,11 @@ level2Phylo = undefined
groups2level :: [PhyloGroup] -> PhyloLevel groups2level :: [PhyloGroup] -> PhyloLevel
groups2level = undefined groups2level = undefined
clusters2group :: [Cluster Ngrams] -> PhyloGroup -- clusters2group :: [Cluster Ngrams] -> PhyloGroup
clusters2group = undefined -- clusters2group = undefined
clique2cluster :: Clique -> Cluster Ngrams -- clique2cluster :: Clique -> Cluster Ngrams
clique2cluster = undefined -- clique2cluster = undefined
-- | Filtering the cliques before bulding the Phylo -- | Filtering the cliques before bulding the Phylo
-- (Support and MinSize as parameter of the finale function to build a phylo) -- (Support and MinSize as parameter of the finale function to build a phylo)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment