Commit b9b19dee authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] SocialLists clean

parent e10c2ed4
Pipeline #1205 failed with stage
...@@ -27,7 +27,7 @@ import Gargantext.Core.Text (size) ...@@ -27,7 +27,7 @@ import Gargantext.Core.Text (size)
import Gargantext.Core.Types (ListType(..)) -- (MasterCorpusId, UserCorpusId) import Gargantext.Core.Types (ListType(..)) -- (MasterCorpusId, UserCorpusId)
import Gargantext.Database.Admin.Types.Node (NodeId) import Gargantext.Database.Admin.Types.Node (NodeId)
-- import Gargantext.Core.Text.List.Learn (Model(..)) -- import Gargantext.Core.Text.List.Learn (Model(..))
import Gargantext.Core.Text.List.Social.Group (FlowListScores(..), flc_lists) import Gargantext.Core.Text.List.Social.Group (FlowListScores(..), flc_lists, mapMax)
import Gargantext.Core.Text.Terms.Mono.Stem (stem) import Gargantext.Core.Text.Terms.Mono.Stem (stem)
import Gargantext.Prelude import Gargantext.Prelude
import qualified Data.Set as Set import qualified Data.Set as Set
...@@ -86,7 +86,6 @@ mergeMapParent = undefined ...@@ -86,7 +86,6 @@ mergeMapParent = undefined
-} -}
------------------------------------------------------------------------ ------------------------------------------------------------------------
data GroupedTextParams a b = data GroupedTextParams a b =
GroupedTextParams { _gt_fun_stem :: Text -> Text GroupedTextParams { _gt_fun_stem :: Text -> Text
, _gt_fun_score :: a -> b , _gt_fun_score :: a -> b
...@@ -136,7 +135,7 @@ toGroupedText_FlowListScores :: ( FlowList a b ...@@ -136,7 +135,7 @@ toGroupedText_FlowListScores :: ( FlowList a b
-> Map Text (GroupedText b) -> Map Text (GroupedText b)
toGroupedText_FlowListScores = undefined toGroupedText_FlowListScores = undefined
toGroupedText_FlowListScores' :: ( FlowList a b ) toGroupedText_FlowListScores' :: ( FlowList a b, Ord b)
=> [a] => [a]
-> Map Text FlowListScores -> Map Text FlowListScores
-> ( [a] -> ( [a]
...@@ -159,13 +158,8 @@ class HasNgrams a where ...@@ -159,13 +158,8 @@ class HasNgrams a where
class HasGroup a b | a -> b where class HasGroup a b | a -> b where
createGroupWith :: FlowListScores -> a -> GroupedText b createGroupWith :: FlowListScores -> a -> GroupedText b
updateGroupWith :: FlowListScores -> a updateGroupWith :: FlowListScores -> a -> GroupedText b -> GroupedText b
-> GroupedText b
-> GroupedText b
------------------------------------------
mapMax :: Map a b -> Maybe a
mapMax m = (fst . fst) <$> Map.maxViewWithKey m
------------------------------------------------------------------------ ------------------------------------------------------------------------
type Stem = Text type Stem = Text
type Label = Text type Label = Text
...@@ -206,8 +200,9 @@ instance HasGroup (Text, Set NodeId) Int where ...@@ -206,8 +200,9 @@ instance HasGroup (Text, Set NodeId) Int where
updateGroupWith fs (t, ns) g = set gt_listType (mapMax $ fs ^. flc_lists) updateGroupWith fs (t, ns) g = set gt_listType (mapMax $ fs ^. flc_lists)
$ set gt_nodes (Set.union ns $ g ^. gt_nodes) g $ set gt_nodes (Set.union ns $ g ^. gt_nodes) g
------------------------------------------------------------------------ ------------------------------------------------------------------------
------------------------------------------------------------------------
-- | To be removed
addListType :: Map Text ListType -> GroupedText a -> GroupedText a addListType :: Map Text ListType -> GroupedText a -> GroupedText a
addListType m g = set gt_listType (hasListType m g) g addListType m g = set gt_listType (hasListType m g) g
where where
......
...@@ -59,9 +59,11 @@ hasParent :: Text ...@@ -59,9 +59,11 @@ hasParent :: Text
-> Maybe Parent -> Maybe Parent
hasParent t m = case Map.lookup t m of hasParent t m = case Map.lookup t m of
Nothing -> Nothing Nothing -> Nothing
Just m' -> (fst . fst) <$> Map.maxViewWithKey m' Just m' -> mapMax m'
------------------------------------------------------------------------
mapMax :: Map a b -> Maybe a
mapMax m = (fst . fst) <$> Map.maxViewWithKey m
------------------------------------------------------------------------ ------------------------------------------------------------------------
data FlowListScores = data FlowListScores =
FlowListScores { _flc_parents :: Map Parent Int FlowListScores { _flc_parents :: Map Parent 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