Commit 7a6ec685 authored by qlobbe's avatar qlobbe Committed by Alexandre Delanoë

add default weight

parent 74d2038a
...@@ -28,7 +28,7 @@ module Gargantext.Core.Text.Metrics.FrequentItemSet ...@@ -28,7 +28,7 @@ module Gargantext.Core.Text.Metrics.FrequentItemSet
import Data.List (concat, null) import Data.List (concat, null)
import Data.Map.Strict (Map) import Data.Map.Strict (Map)
import Data.Maybe (catMaybes) import Data.Maybe (catMaybes, isNothing)
import Data.Set (Set) import Data.Set (Set)
import Gargantext.Prelude import Gargantext.Prelude
import HLCM import HLCM
...@@ -131,14 +131,19 @@ isSublistOf sub lst = all (\i -> elem i lst) sub ...@@ -131,14 +131,19 @@ isSublistOf sub lst = all (\i -> elem i lst) sub
reIndexFis :: Ord a => [([a],(b,c))] -> [Fis' a] -> [(Fis' a,([b],[c]))] reIndexFis :: Ord a => [([a],(b,c))] -> [Fis' a] -> [(Fis' a,([b],[c]))]
reIndexFis items fis = map (\f -> reIndexFis items fis = map (\f ->
let docs = filter (\(lst,_) -> isSublistOf (_fisItemSet f) lst) items let docs = filter (\(lst,_) -> isSublistOf (_fisItemSet f) lst) items
in (f, (map (fst . snd) docs,map (snd . snd) docs))) fis in (f, (map (fst . snd) docs, map (snd . snd) docs))) fis
wsum :: [Maybe Double] -> Maybe Double wsum :: [Maybe Double] -> Int -> Maybe Double
wsum lst = fmap sum $ sequence lst wsum lst sup =
let w = fmap sum $ sequence lst
in
if (isNothing w)
then Just $ fromIntegral sup
else w
fisWithSizePolyMap' :: Ord a => Size -> Frequency -> [([a], (Maybe Double,[Int]))] -> Map (Set a) (Int, (Maybe Double,[Int])) fisWithSizePolyMap' :: Ord a => Size -> Frequency -> [([a], (Maybe Double,[Int]))] -> Map (Set a) (Int, (Maybe Double,[Int]))
fisWithSizePolyMap' n f is = Map.fromList fisWithSizePolyMap' n f is = Map.fromList
$ map (\(fis,(ws,sources)) -> (Set.fromList (_fisItemSet fis),(_fisCount fis,(wsum ws,concat sources)))) $ map (\(fis,(ws,sources)) -> (Set.fromList (_fisItemSet fis),(_fisCount fis,(wsum ws (_fisCount fis),concat sources))))
$ reIndexFis is $ reIndexFis is
$ fisWithSizePoly2 n f (map fst is) $ fisWithSizePoly2 n f (map fst is)
......
...@@ -241,7 +241,7 @@ toPhyloClique phylo phyloDocs = case (clique $ getConfig phylo) of ...@@ -241,7 +241,7 @@ toPhyloClique phylo phyloDocs = case (clique $ getConfig phylo) of
in (prd, map (\f -> PhyloClique (Set.toList $ fst f) ((fst . snd) f) prd ((fst . snd . snd) f) (((snd . snd . snd) f))) lst) in (prd, map (\f -> PhyloClique (Set.toList $ fst f) ((fst . snd) f) prd ((fst . snd . snd) f) (((snd . snd . snd) f))) lst)
_ -> let lst = toList _ -> let lst = toList
$ fisWithSizePolyMap (Segment 1 20) 1 (map (\d -> ngramsToIdx (text d) (getRoots phylo)) docs) $ fisWithSizePolyMap (Segment 1 20) 1 (map (\d -> ngramsToIdx (text d) (getRoots phylo)) docs)
in (prd, map (\f -> PhyloClique (Set.toList $ fst f) (snd f) prd Nothing []) lst) in (prd, map (\f -> PhyloClique (Set.toList $ fst f) (snd f) prd (Just $ fromIntegral $ snd f) []) lst)
) )
$ toList phyloDocs $ toList phyloDocs
fis' = fis `using` parList rdeepseq fis' = fis `using` parList rdeepseq
......
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