module Gargantext.Text.Metrics.FrequentItemSet
( Fis, Size(..)
, occ_hlcm, cooc_hlcm
- , all, between
+ , allFis, between
, fisWithSize
, fisWith
, fisWithSizePoly
, fisWithSizePoly2
+ , fisWithSizePolyMap
, module HLCM
)
where
import qualified Data.Set as Set
import Data.Set (Set)
import qualified Data.Vector as V
-import Data.Vector (Vector)
-import Data.List (filter, concat)
+import Data.List (filter, concat, null)
import Data.Maybe (catMaybes)
import HLCM
cooc_hlcm :: Frequency -> [[Item]] -> [Fis]
cooc_hlcm = fisWithSize (Point 2)
-all :: Frequency -> [[Item]] -> [Fis]
-all = fisWith Nothing
+allFis :: Frequency -> [[Item]] -> [Fis]
+allFis = fisWith Nothing
------------------------------------------------------------------------
between :: (Int, Int) -> Frequency -> [[Item]] -> [Fis]
cond a' x b' = a' <= x && x <= b'
+ --- Filter on Fis and not on [Item]
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
where
filter' = case s of
Nothing -> identity
where
ks = Set.fromList $ concat is
+fisWithSizePolyMap :: Ord a => Size -> Frequency -> [[a]] -> Map (Set a) Int
+fisWithSizePolyMap n f is =
+ Map.fromList $ (\i -> (Set.fromList (_fisItemSet i), _fisCount i)) <$> fisWithSizePoly2 n f is
+
------------------------------------------------------------------------
------------------------------------------------------------------------