Commit 02da3a03 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Notes MEETING] Phylomemy work with Quentin and David.

parent d5b62df5
...@@ -7,7 +7,7 @@ Maintainer : team@gargantext.org ...@@ -7,7 +7,7 @@ Maintainer : team@gargantext.org
Stability : experimental Stability : experimental
Portability : POSIX Portability : POSIX
Specifications of Phylomemy format. Specifications of Phylomemy export format.
Phylomemy can be described as a Temporal Graph with different scale of Phylomemy can be described as a Temporal Graph with different scale of
granularity of group of ngrams (terms and multi-terms). granularity of group of ngrams (terms and multi-terms).
...@@ -39,9 +39,9 @@ import Gargantext.Core.Utils.Prefix (unPrefix) ...@@ -39,9 +39,9 @@ import Gargantext.Core.Utils.Prefix (unPrefix)
import Gargantext.Prelude import Gargantext.Prelude
------------------------------------------------------------------------ ------------------------------------------------------------------------
data PhyloFormat = data PhyloExport =
PhyloFormat { _phyloFormat_param :: PhyloParam PhyloExport { _phyloExport_param :: PhyloParam
, _phyloFormat_data :: Phylo , _phyloExport_data :: Phylo
} deriving (Generic) } deriving (Generic)
-- | .phylo parameters -- | .phylo parameters
...@@ -66,7 +66,7 @@ data Software = ...@@ -66,7 +66,7 @@ data Software =
-- Ngrams : list of all (possible) terms contained in the phylomemy (with their id) -- Ngrams : list of all (possible) terms contained in the phylomemy (with their id)
-- Steps : list of all steps to build the phylomemy -- Steps : list of all steps to build the phylomemy
data Phylo = data Phylo =
Phylo { _phylo_puration :: (Start, End) Phylo { _phylo_duration :: (Start, End)
, _phylo_ngrams :: [Ngram] , _phylo_ngrams :: [Ngram]
, _phylo_periods :: [PhyloPeriod] , _phylo_periods :: [PhyloPeriod]
} }
...@@ -109,27 +109,28 @@ type PhyloLevelId = (PhyloPeriodId, Int) ...@@ -109,27 +109,28 @@ type PhyloLevelId = (PhyloPeriodId, Int)
-- Ngrams: set of terms that build the group -- Ngrams: set of terms that build the group
-- Period Parents|Childs: weighted link to Parents|Childs (Temporal Period axis) -- Period Parents|Childs: weighted link to Parents|Childs (Temporal Period axis)
-- Level Parents|Childs: weighted link to Parents|Childs (Level Granularity axis) -- Level Parents|Childs: weighted link to Parents|Childs (Level Granularity axis)
-- Pointers are directed link from Self to any PhyloGroup (/= Self ?)
data PhyloGroup = data PhyloGroup =
PhyloGroup { _phylo_groupId :: PhyloGroupId PhyloGroup { _phylo_groupId :: PhyloGroupId
, _phylo_groupLabel :: Maybe Text , _phylo_groupLabel :: Maybe Text
, _phylo_groupNgrams :: [NgramsId] , _phylo_groupNgrams :: [NgramsId]
, _phylo_groupPeriodParents :: [Edge] , _phylo_groupPeriodParents :: [Pointer]
, _phylo_groupPeriodChilds :: [Edge] , _phylo_groupPeriodChilds :: [Pointer]
, _phylo_groupLevelParents :: [Edge] , _phylo_groupLevelParents :: [Pointer]
, _phylo_groupLevelChilds :: [Edge] , _phylo_groupLevelChilds :: [Pointer]
} }
deriving (Generic) deriving (Generic)
type PhyloGroupId = (PhyloLevelId, Int) type PhyloGroupId = (PhyloLevelId, Int)
type Edge = (PhyloGroupId, Weight) type Pointer = (PhyloGroupId, Weight)
type Weight = Double type Weight = Double
-- | Lenses -- | Lenses
makeLenses ''Phylo makeLenses ''Phylo
makeLenses ''PhyloParam makeLenses ''PhyloParam
makeLenses ''PhyloFormat makeLenses ''PhyloExport
makeLenses ''Software makeLenses ''Software
-- | JSON instances -- | JSON instances
...@@ -140,7 +141,7 @@ $(deriveJSON (unPrefix "_phylo_group" ) ''PhyloGroup ) ...@@ -140,7 +141,7 @@ $(deriveJSON (unPrefix "_phylo_group" ) ''PhyloGroup )
-- --
$(deriveJSON (unPrefix "_software_" ) ''Software ) $(deriveJSON (unPrefix "_software_" ) ''Software )
$(deriveJSON (unPrefix "_phyloParam_" ) ''PhyloParam ) $(deriveJSON (unPrefix "_phyloParam_" ) ''PhyloParam )
$(deriveJSON (unPrefix "_phyloFormat_" ) ''PhyloFormat ) $(deriveJSON (unPrefix "_phyloExport_" ) ''PhyloExport )
-- | TODO XML instances -- | TODO XML instances
{-|
Module : Gargantext.Viz.Phylo.Tools
Description : Phylomemy tools
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Phylo Toolbox:
- functions to build a Phylo
- functions to filter the cliques
- functions to manage a Phylo
Group Functions (TODO list)
- cohesion sur un groupe
- distance au dernier branchement
- âge du groupe
Futre Idea: temporal zoom on Phylo
phyloZoomOut :: (PeriodGrain, Phylo) -> [(PeriodGrain, Phylo)]
(from smallest granularity, it increases (zoom out) the periods of the Phylo)
Moral idea: viz from out to in
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
module Gargantext.Viz.Phylo.Tools where
import Data.Set (Set)
import Data.Map (Map)
import Data.Map as Map hiding (Map)
import Gargantext.Prelude
import Gargantext.Viz.Phylo
import Gargantext.Viz.Phylo.Example
-- | Building a phylo
-- (Indicative and schematic function)
buildPhylo :: Support -> MinSize
-> Map Clique Support -> Phylo
buildPhylo s m mcs = level2Phylo
. groups2level
. clusters2group
. map clique2cluster
. filterCliques s m
level2Phylo :: PhyloLevel -> Phylo -> Phylo
level2Phylo = undefined
groups2level :: [PhyloGroup] -> PhyloLevel
groups2level = undefined
clusters2group :: [Cluster Ngrams] -> PhyloGroup
clusters2group = undefined
clique2cluster :: Clique -> Cluster Ngrams
clique2cluster = undefined
-- | Filtering the cliques before bulding the Phylo
-- (Support and MinSize as parameter of the finale function to build a phylo)
-- idea: log of Corpus size (of docs)
filterCliques :: Support -> MinSize
-> Map Clique Support -> [Clique]
filterCliques s ms = maximalCliques
. filterWithSizeSet ms
. Map.keys
. filterWithSupport s
type Clique = Set Ngrams
type Support = Int
type MinSize = Int
-- | Hapaxify / Threshold
-- hapax s = 1
-- ?
filterWithSupport :: Support -> Map Clique Support -> Map Clique Support
filterWithSupport s = Map.filter (>s)
filterWithSizeSet :: MinSize -> [Clique] -> [Clique]
filterWithSizeSet = undefined
-- | filtre les cliques de ngrams compris dans une clique plus grande
-- /!\ optim inside
maximalCliques :: [Clique] -> [Clique]
maximalCliques = undefined
-- | Phylo management
-- | PhyloLevel Management
viewGroups :: (Start,End) -> PhyloLevel -> Phylo -> [PhyloGroup]
viewGroups = undefined
viewLevels :: (Start,End) -> Phylo -> [PhyloLevel]
viewLevels = undefined
-- | tous les terme des champs, tous les parents et les enfants
setGroup :: PhyloGroup -> PhyloGroup -> PhyloGroup
setGroup = undefined
--removeTerms :: recalculer les cliques pour ces termes
--addTerms
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