Commit f225c5cf authored by Karen Konou's avatar Karen Konou

[Phylo] Display phylo generation parameters

parent eb38e748
......@@ -92,13 +92,14 @@ nodeCpt = here.component "node" cpt where
]
]
, defaultSlot:
R2.fromMaybe state' \(PhyloSet { corpusId, listId, phyloData }) ->
R2.fromMaybe state' \(PhyloSet { corpusId, listId, phyloData, phyloConfig}) ->
let
state_ :: Record PhyloStore.State
state_ =
-- Data
{ phyloData
, phyloConfig
, corpusId
, listId
, phyloId: nodeId
......
......@@ -3,6 +3,11 @@ module Gargantext.Components.PhyloExplorer.JSON
, GraphData(..)
, NodeData(..), RawObject(..)
, EdgeData(..), RawEdge(..)
, Cluster(..), PhyloLabel(..)
, Sort(..), Synchrony(..)
, SeaElevation(..), PhyloSimilarity(..)
, TimeUnit(..), ConfigData(..)
, Quality(..)
) where
import Gargantext.Prelude
......@@ -26,6 +31,17 @@ newtype PhyloJSON = PhyloJSON
, strict :: Boolean
| GraphData
}
, pd_config ::
{ clique :: Cluster
, exportLabel :: Array PhyloLabel
, exportSort :: Sort
, phyloSynchrony :: Synchrony
, phyloQuality :: Quality
, seaElevation :: SeaElevation
, similarity :: PhyloSimilarity
, timeUnit :: TimeUnit
| ConfigData
}
}
derive instance Generic PhyloJSON _
......@@ -184,3 +200,157 @@ derive instance Eq RawEdge
instance Show RawEdge where show = genericShow
instance JSON.ReadForeign RawEdge where
readImpl f = GR.to <$> untaggedSumRep f
--------------------------------------------------
type ConfigData =
( corpusPath :: String
, defaultMode :: Boolean
, findAncestors :: Boolean
, listParser :: String
, listPath :: String
, outputPath :: String
, phyloName :: String
, phyloScale :: Int
)
data Cluster
= Fis
{ _fis_support :: Int
, _fis_size :: Int
}
| MaxClique
{ _mcl_size :: Int
, _mcl_threshold :: Number
, _mcl_filter :: String
}
derive instance Generic Cluster _
derive instance Eq Cluster
instance Show Cluster where show = genericShow
instance JSON.ReadForeign Cluster where
readImpl f = GR.to <$> untaggedSumRep f
data PhyloLabel
= BranchLabel
{ _branch_labelTagger :: String
, _branch_labelSize :: Int
}
| GroupLabel
{ _group_labelTagger :: String
, _group_labelSize :: Int
}
derive instance Generic PhyloLabel _
derive instance Eq PhyloLabel
instance Show PhyloLabel where show = genericShow
instance JSON.ReadForeign PhyloLabel where
readImpl f = GR.to <$> untaggedSumRep f
data Sort = ByBirthDate { _sort_order :: String } | ByHierarchy {_sort_order :: String }
derive instance Generic Sort _
derive instance Eq Sort
instance Show Sort where show = genericShow
instance JSON.ReadForeign Sort where
readImpl f = GR.to <$> untaggedSumRep f
data Synchrony
= ByProximityThreshold
{ _bpt_threshold :: Number
, _bpt_sensibility :: Number
, _bpt_scope :: String
, _bpt_strategy :: String
}
| ByProximityDistribution
{ _bpd_sensibility :: Number
, _bpd_strategy :: String
}
derive instance Generic Synchrony _
derive instance Eq Synchrony
instance Show Synchrony where show = genericShow
instance JSON.ReadForeign Synchrony where
readImpl f = GR.to <$> untaggedSumRep f
data SeaElevation
= Constante
{ _cons_start :: Number
, _cons_gap :: Number
}
| Adaptative
{ _adap_steps :: Number }
| Evolving
{ _evol_neighborhood :: Boolean }
derive instance Generic SeaElevation _
derive instance Eq SeaElevation
instance Show SeaElevation where show = genericShow
instance JSON.ReadForeign SeaElevation where
readImpl f = GR.to <$> untaggedSumRep f
data PhyloSimilarity
= WeightedLogJaccard
{ _wlj_sensibility :: Number
, _wlj_minSharedNgrams :: Int
}
| WeightedLogSim
{ _wls_sensibility :: Number
, _wls_minSharedNgrams :: Int
}
| Hamming
{ _hmg_sensibility :: Number
, _hmg_minSharedNgrams :: Int
}
derive instance Generic PhyloSimilarity _
derive instance Eq PhyloSimilarity
instance Show PhyloSimilarity where show = genericShow
instance JSON.ReadForeign PhyloSimilarity where
readImpl f = GR.to <$> untaggedSumRep f
data TimeUnit
= Epoch
{ _epoch_period :: Int
, _epoch_step :: Int
, _epoch_matchingFrame :: Int
}
| Year
{ _year_period :: Int
, _year_step :: Int
, _year_matchingFrame :: Int
}
| Month
{ _month_period :: Int
, _month_step :: Int
, _month_matchingFrame :: Int
}
| Week
{ _week_period :: Int
, _week_step :: Int
, _week_matchingFrame :: Int
}
| Day
{ _day_period :: Int
, _day_step :: Int
, _day_matchingFrame :: Int
}
derive instance Generic TimeUnit _
derive instance Eq TimeUnit
instance Show TimeUnit where show = genericShow
instance JSON.ReadForeign TimeUnit where
readImpl f = GR.to <$> untaggedSumRep f
data Quality
= Quality
{ _qua_granularity :: Number
, _qua_minBranch :: Int
}
derive instance Generic Quality _
derive instance Eq Quality
instance Show Quality where show = genericShow
instance JSON.ReadForeign Quality where
readImpl f = GR.to <$> untaggedSumRep f
......@@ -4,8 +4,9 @@ module Gargantext.Components.PhyloExplorer.DetailsTab
import Gargantext.Prelude
import Gargantext.Components.PhyloExplorer.JSON (Cluster(..), TimeUnit(..))
import Gargantext.Components.PhyloExplorer.Store as PhyloStore
import Gargantext.Components.PhyloExplorer.Types (PhyloData(..))
import Gargantext.Components.PhyloExplorer.Types (PhyloConfig(..), PhyloData(..))
import Gargantext.Utils (nbsp)
import Gargantext.Utils.Reactix as R2
import Reactix as R
......@@ -26,6 +27,7 @@ detailsTabCpt = here.component "" cpt where
store <- PhyloStore.use
(PhyloData o) <- R2.useLive' store.phyloData
(PhyloConfig c) <- R2.useLive' store.phyloConfig
-- | Render
-- |
......@@ -66,6 +68,20 @@ detailsTabCpt = here.component "" cpt where
[
H.text "How the phylomemy was built?"
]
,
H.hr
{ className: "phylo-details-tab__delimiter" }
,
-- Phylo params
H.ul
{ className: "phylo-details-tab__counter" }
[ detailsTimeUnit c.timeUnit
, detailsParams c.levelOfObservation "Level of observation"
, detailsClique c.clique
, detailsParams c.proximity "Proximity"
, detailsParams c.synchrony "Synchrony"
, detailsParams c.minBranch "Minimum Branch Size"
]
]
detailsCount :: Int -> String -> R.Element
......@@ -85,3 +101,30 @@ detailsCount value label =
H.text $ nbsp 1 <> label
]
]
detailsParams :: forall a. (Show a) => a -> String -> R.Element
detailsParams value label =
H.li {} [ H.text $ label <> ": " <> show value ]
detailsClique :: Cluster -> R.Element
detailsClique c =
H.li {} [ H.text $ "Cluster algo: " <> parseClique c]
where
parseClique (Fis { _fis_support, _fis_size }) = "FIS. Support: " <> show _fis_support <> ". Size: " <> show _fis_size
parseClique (MaxClique { _mcl_size, _mcl_threshold, _mcl_filter}) =
"MaxClique. Size: " <> show _mcl_size <> ". Threshhold: " <> show _mcl_threshold <> ". Filter: " <> _mcl_filter
detailsTimeUnit :: TimeUnit -> R.Element
detailsTimeUnit t =
H.li {} [ H.text $ "Time unit: " <> parseTimeUnit t]
where
parseTimeUnit (Epoch {_epoch_period, _epoch_step, _epoch_matchingFrame}) =
"Epoch. Period: " <> show _epoch_period <> ". Step: " <> show _epoch_step <>". Matching frame: " <> show _epoch_matchingFrame
parseTimeUnit (Year {_year_period, _year_step, _year_matchingFrame}) =
"Year. Period: " <> show _year_period <> ". Step: " <> show _year_step <>". Matching frame: " <> show _year_matchingFrame
parseTimeUnit (Month {_month_period, _month_step, _month_matchingFrame}) =
"Month. Period: " <> show _month_period <> ". Step: " <> show _month_step <>". Matching frame: " <> show _month_matchingFrame
parseTimeUnit (Week {_week_period, _week_step, _week_matchingFrame}) =
"Week. Period: " <> show _week_period <> ". Step: " <> show _week_step <>". Matching frame: " <> show _week_matchingFrame
parseTimeUnit (Day {_day_period, _day_step, _day_matchingFrame}) =
"Day. Period: " <> show _day_period <> ". Step: " <> show _day_step <>". Matching frame: " <> show _day_matchingFrame
......@@ -11,7 +11,7 @@ module Gargantext.Components.PhyloExplorer.Store
import Gargantext.Prelude
import Data.Maybe (Maybe(..))
import Gargantext.Components.PhyloExplorer.Types (CorpusId, DisplayView(..), ExtractedCount, ExtractedTerm, FrameDoc, PhyloData, Source, TabView(..), Term, ListId, defaultCacheParams)
import Gargantext.Components.PhyloExplorer.Types (CorpusId, DisplayView(..), ExtractedCount, ExtractedTerm, FrameDoc, ListId, PhyloConfig, PhyloData, Source, TabView(..), Term, defaultCacheParams)
import Gargantext.Types (NodeID, SidePanelState(..))
import Gargantext.Utils (getter)
import Gargantext.Utils.Reactix as R2
......@@ -26,6 +26,7 @@ here = R2.here "Gargantext.Components.GraphExplorer.Store"
type Store =
-- Data
( phyloData :: T.Box PhyloData
, phyloConfig :: T.Box PhyloConfig
, phyloId :: T.Box NodeID
, corpusId :: T.Box CorpusId
, listId :: T.Box ListId
......@@ -55,6 +56,7 @@ type Store =
type State =
-- Data
( phyloData :: PhyloData
, phyloConfig :: PhyloConfig
, phyloId :: NodeID
, corpusId :: CorpusId
, listId :: ListId
......
......@@ -2,6 +2,7 @@ module Gargantext.Components.PhyloExplorer.Types
( PhyloSet(..), parseToPhyloSet
, CorpusId, ListId, DocId
, PhyloData(..)
, PhyloConfig(..)
, Branch(..), Period(..), Group(..)
, Link(..), AncestorLink(..), BranchLink(..)
, Term(..)
......@@ -19,8 +20,8 @@ import Gargantext.Prelude
import Data.Array as Array
import Data.Date as Date
import Data.Generic.Rep (class Generic)
import Data.FunctorWithIndex (mapWithIndex)
import Data.Generic.Rep (class Generic)
import Data.Int as Int
import Data.Maybe (Maybe(..), maybe)
import Data.Newtype (class Newtype)
......@@ -30,7 +31,7 @@ import Data.String as String
import Data.String.Extra (camelCase)
import Data.Tuple as Tuple
import Data.Tuple.Nested ((/\))
import Gargantext.Components.PhyloExplorer.JSON (PhyloJSON(..), RawEdge(..), RawObject(..))
import Gargantext.Components.PhyloExplorer.JSON (Cluster, PhyloJSON(..), PhyloSimilarity(..), Quality(..), RawEdge(..), RawObject(..), Synchrony(..), TimeUnit)
import Simple.JSON as JSON
-- @NOTE #219: PureScript Date or stick to JavaScript foreign?
......@@ -45,9 +46,10 @@ type DocId = Int
------------------------------------------------------------------
data PhyloSet = PhyloSet
{ corpusId :: CorpusId
, listId :: ListId
, phyloData :: PhyloData
{ corpusId :: CorpusId
, listId :: ListId
, phyloData :: PhyloData
, phyloConfig :: PhyloConfig
}
derive instance Generic PhyloSet _
......@@ -78,11 +80,20 @@ parseToPhyloSet (PhyloJSON o) = PhyloSet
, timeScale : p.phyloTimeScale
, weighted : getGlobalWeightedValue groups
}
, phyloConfig : PhyloConfig
{ clique: c.clique
, timeUnit: c.timeUnit
, synchrony: parseSynchrony c.phyloSynchrony
, proximity: parseSimilarity c.similarity
, minBranch: parseQualityToMinBranch c.phyloQuality
, levelOfObservation: parseQualityToLevelOfObservation c.phyloQuality
}
}
where
p = o.pd_data
c = o.pd_config
epochTS = p.phyloTimeScale == "epoch"
ancestorLinks = parseAncestorLinks p.edges
......@@ -120,6 +131,36 @@ instance Show PhyloData where show = genericShow
-----------------------------------------------------------
data PhyloConfig = PhyloConfig
{ clique :: Cluster
, timeUnit :: TimeUnit
, synchrony :: Number
, proximity :: Number
, minBranch :: Int
, levelOfObservation :: Number
}
derive instance Generic PhyloConfig _
derive instance Eq PhyloConfig
instance Show PhyloConfig where show = genericShow
parseSynchrony :: Synchrony -> Number
parseSynchrony (ByProximityThreshold { _bpt_threshold }) = _bpt_threshold
parseSynchrony (ByProximityDistribution { _bpd_sensibility }) = _bpd_sensibility
parseSimilarity :: PhyloSimilarity -> Number
parseSimilarity (WeightedLogJaccard { _wlj_sensibility }) = _wlj_sensibility
parseSimilarity (WeightedLogSim { _wls_sensibility }) = _wls_sensibility
parseSimilarity (Hamming { _hmg_sensibility }) = _hmg_sensibility
parseQualityToMinBranch :: Quality -> Int
parseQualityToMinBranch (Quality { _qua_minBranch }) = _qua_minBranch
parseQualityToLevelOfObservation :: Quality -> Number
parseQualityToLevelOfObservation (Quality { _qua_granularity }) = _qua_granularity
-----------------------------------------------------------
newtype Branch = Branch
{ bId :: Int
, gvid :: Int
......
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