Commit ce0f0e64 authored by Quentin Lobbé's avatar Quentin Lobbé

add types Fis, Clique and Support

parent 101568d4
...@@ -32,9 +32,11 @@ import Data.Text (Text, unwords, toLower, words) ...@@ -32,9 +32,11 @@ import Data.Text (Text, unwords, toLower, words)
import Data.Tuple.Extra (both) import Data.Tuple.Extra (both)
import Data.Map (Map) import Data.Map (Map)
import qualified Data.Map as DM import qualified Data.Map as Map
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Set as DS
import qualified Data.Matrix as DM'
import Gargantext.Text.Metrics.FrequentItemSet (fisWithSizePolyMap, Size(..)) import Gargantext.Text.Metrics.FrequentItemSet (fisWithSizePolyMap, Size(..))
import Gargantext.Text.Terms.Mono (monoTexts) import Gargantext.Text.Terms.Mono (monoTexts)
...@@ -59,53 +61,19 @@ type PeriodeSize = Int ...@@ -59,53 +61,19 @@ type PeriodeSize = Int
type Occurrences = Int type Occurrences = Int
------------------------------------------------------------------------ -- | number of Documents in a given Corpus where a set of Ngrams co-occurs
-- | Phylo'' ? type Support = Int
-- | phylo_id = date && source data && query && [operations] -- | frequent items set
-- | node_type = 0 | 1 | 2 | 3 <=> root | emergence | recombination | steady type Fis = Map (Set Ngrams) Support
data Phylo'' a = Phylo'' { phylo_id :: a
, branch_list :: [Branch a]
}
data Branch a = Branch { branch_id :: Int
, cluster_list :: [Cluster' a]
, cluster_edge :: [Edge a]
}
data Cluster' a = Cluster' { cluster_node :: Node a
, cluster_date :: Date
, term_list :: [Node a]
, term_edge :: [Edge a]
}
data Edge a = Edge { edge_id :: Int --------------------------------------------------------------------
, edge_source :: Node a
, edge_target :: Node a
}
data Node a = Node { node_id :: Int
, node_label :: Ngrams
, node_type :: a
, node_score :: a
}
------------------------------------------------------------------------
-- | Phylo == Phylo' ?
type Phylo' a = [Strate a]
data Strate a = Strate { strate_date :: (Date,Date)
, strate_clusters :: [Cluster a]
}
data Cluster a = Cluster { cluster_id :: Int data PhyloField = PhyloField {
, cluster_ngrams :: Set Ngrams phyloField_id :: Int
, cluster_score :: a }
, cluster_parent :: [(Cluster a, Double)]
}
------------------------------------------------------------------------ --------------------------------------------------------------------
phyloExampleFinal :: Phylo phyloExampleFinal :: Phylo
phyloExampleFinal = undefined phyloExampleFinal = undefined
...@@ -115,12 +83,21 @@ appariement = undefined ...@@ -115,12 +83,21 @@ appariement = undefined
-------------------------------------------------------------------- --------------------------------------------------------------------
phyloExample :: Map (Date, Date) (Map (Set Ngrams) Int) fisToFields :: Fis
phyloExample = fis phyloTerms -> [PhyloField]
fisToFields = undefined
phyloClusters :: Map (Date,Date) [PhyloField]
phyloClusters = undefined
--------------------------------------------------------------------
phyloFis :: Map (Date, Date) Fis
phyloFis = termsToFis phyloTerms
fis :: Map (Date, Date) [Document] termsToFis :: Map (Date, Date) [Document]
-> Map (Date, Date) (Map (Set Ngrams) Int) -> Map (Date, Date) Fis
fis = phylo (words . text) termsToFis = phylo (words . text)
phyloTerms :: Map (Date, Date) [Document] phyloTerms :: Map (Date, Date) [Document]
phyloTerms = toPeriodes date 5 3 $ cleanCorpus mapList phyloCorpus phyloTerms = toPeriodes date 5 3 $ cleanCorpus mapList phyloCorpus
...@@ -132,14 +109,14 @@ phyloTerms = toPeriodes date 5 3 $ cleanCorpus mapList phyloCorpus ...@@ -132,14 +109,14 @@ phyloTerms = toPeriodes date 5 3 $ cleanCorpus mapList phyloCorpus
phylo :: (Document -> [Ngrams]) phylo :: (Document -> [Ngrams])
-> Map (Date, Date) [Document] -> Map (Date, Date) [Document]
-> Map (Date, Date) (Map (Set Ngrams) Int) -> Map (Date, Date) (Map (Set Ngrams) Int)
phylo f = DM.map (\d -> fisWithSizePolyMap (Segment 1 20) 1 (map f d)) phylo f = Map.map (\d -> fisWithSizePolyMap (Segment 1 20) 1 (map f d))
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Create a Map of (time steps) and [documents] -- | Create a Map of (time steps) and [documents]
toPeriodes :: (Ord date, Enum date) => (doc -> date) toPeriodes :: (Ord date, Enum date) => (doc -> date)
-> Grain -> Step -> [doc] -> Map (date, date) [doc] -> Grain -> Step -> [doc] -> Map (date, date) [doc]
toPeriodes _ _ _ [] = panic "Empty corpus can not have any periods" toPeriodes _ _ _ [] = panic "Empty corpus can not have any periods"
toPeriodes f g s es = DM.fromList $ zip hs $ map (inPeriode f es) hs toPeriodes f g s es = Map.fromList $ zip hs $ map (inPeriode f es) hs
where where
hs = steps g s $ both f (DL.head es, DL.last es) hs = steps g s $ both f (DL.head es, DL.last es)
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
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