Commit 0c9ed01c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[PHYLO] FIS added.

parent c430654e
...@@ -111,7 +111,8 @@ library: ...@@ -111,7 +111,8 @@ library:
- path - path
- path-io - path-io
- postgresql-simple - postgresql-simple
- pretty - pretty-simple
- probability
- product-profunctors - product-profunctors
- profunctors - profunctors
- protolude - protolude
......
...@@ -33,7 +33,7 @@ import qualified Data.Set as Set ...@@ -33,7 +33,7 @@ import qualified Data.Set as Set
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Vector as V import qualified Data.Vector as V
import Data.List (filter, concat) import Data.List (filter, concat, null)
import Data.Maybe (catMaybes) import Data.Maybe (catMaybes)
import HLCM import HLCM
...@@ -93,7 +93,9 @@ fisWithSize n f is = case n of ...@@ -93,7 +93,9 @@ fisWithSize n f is = case n of
--- Filter on Fis and not on [Item] --- Filter on Fis and not on [Item]
fisWith :: Maybe ([Item] -> Bool) -> Frequency -> [[Item]] -> [Fis] fisWith :: Maybe ([Item] -> Bool) -> Frequency -> [[Item]] -> [Fis]
fisWith s f is = catMaybes $ map items2fis $ filter' $ runLCMmatrix is f fisWith s f is = case filter (not . null) is of
[] -> []
js -> catMaybes $ map items2fis $ filter' $ runLCMmatrix js f
-- drop unMaybe -- drop unMaybe
where where
filter' = case s of filter' = case s of
......
...@@ -10,12 +10,15 @@ module Gargantext.Viz.Phylo.Example where ...@@ -10,12 +10,15 @@ module Gargantext.Viz.Phylo.Example where
import qualified Data.List as DL import qualified Data.List as DL
import Data.String (String) import Data.String (String)
import Data.Text (Text, pack, unwords, toLower) import Data.Text (Text, pack, 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 DM
import Data.Set (Set)
import Gargantext.Text.Metrics.FrequentItemSet (fisWithSizePolyMap, Size(..))
import Gargantext.Text.Terms.Mono (monoTexts) import Gargantext.Text.Terms.Mono (monoTexts)
import Gargantext.Prelude import Gargantext.Prelude
...@@ -24,11 +27,21 @@ type Histoire = [Event] ...@@ -24,11 +27,21 @@ type Histoire = [Event]
data Event = Event {date:: Double, text :: Text} data Event = Event {date:: Double, text :: Text}
deriving (Show) deriving (Show)
type MapList = [Text] type MapList = [Text]
type PeriodeSize = Int type PeriodeSize = Int
-- data Periodes b a = Map (b,b) a -- data Periodes b a = Map (b,b) a
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | TODO FIS on monotexts
phyloFIS :: Map (Double, Double) [Event] -> Map (Double, Double) (Map (Set Text) Int)
phyloFIS = DM.map (\n -> fisWithSizePolyMap (Point 1) 1 (map (words . text) n))
phyloExample :: Map (Double, Double) [Event]
phyloExample = toPeriodes date 1 $ cleanHistoire mapList phyloCorpus
------------------------------------------------------------------------
toPeriodes :: (Enum b, Fractional b, Ord b) => (t -> b) -> b -> [t] -> Map (b, b) [t] toPeriodes :: (Enum b, Fractional b, Ord b) => (t -> b) -> b -> [t] -> Map (b, b) [t]
toPeriodes _ _ [] = panic $ pack "Empty history can not have any periode" toPeriodes _ _ [] = panic $ pack "Empty history can not have any periode"
toPeriodes f s hs = periodes f st hs toPeriodes f s hs = periodes f st hs
......
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