Commit 62fcd6ea authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] SocialList. Realizing we need PatchMap here.

parent 093afa75
...@@ -79,10 +79,8 @@ buildNgramsOthersList ::( HasNodeError err ...@@ -79,10 +79,8 @@ buildNgramsOthersList ::( HasNodeError err
-> (NgramsType, MapListSize) -> (NgramsType, MapListSize)
-> m (Map NgramsType [NgramsElement]) -> m (Map NgramsType [NgramsElement])
buildNgramsOthersList user uCid groupIt (nt, MapListSize mapListSize) = do buildNgramsOthersList user uCid groupIt (nt, MapListSize mapListSize) = do
ngs <- groupNodesByNgramsWith groupIt <$> getNodesByNgramsUser uCid nt ngs <- groupNodesByNgramsWith groupIt <$> getNodesByNgramsUser uCid nt
let let
grouped = toGroupedText groupIt (Set.size . snd) fst snd grouped = toGroupedText groupIt (Set.size . snd) fst snd
(Map.toList $ Map.mapWithKey (\k (a,b) -> (Set.delete k a, b)) $ ngs) (Map.toList $ Map.mapWithKey (\k (a,b) -> (Set.delete k a, b)) $ ngs)
...@@ -265,7 +263,6 @@ buildNgramsTermsList user uCid mCid groupParams = do ...@@ -265,7 +263,6 @@ buildNgramsTermsList user uCid mCid groupParams = do
-- printDebug "monoScoredInclHead" monoScoredInclHead -- printDebug "monoScoredInclHead" monoScoredInclHead
-- printDebug "monoScoredExclHead" monoScoredExclTail -- printDebug "monoScoredExclHead" monoScoredExclTail
--
-- printDebug "multScoredInclHead" multScoredInclHead -- printDebug "multScoredInclHead" multScoredInclHead
-- printDebug "multScoredExclTail" multScoredExclTail -- printDebug "multScoredExclTail" multScoredExclTail
......
...@@ -79,12 +79,12 @@ flowSocialListByMode listIds nt ngrams' = do ...@@ -79,12 +79,12 @@ flowSocialListByMode listIds nt ngrams' = do
flowSocialListByMode' :: ( RepoCmdM env err m flowSocialListByMode' :: ( RepoCmdM env err m
, CmdM env err m , CmdM env err m
, HasNodeError err , HasNodeError err
, HasTreeError err , HasTreeError err
) )
=> [NodeId]-> NgramsType -> Set Text => [NodeId]-> NgramsType -> Set Text
-> m (Map Text FlowListScores) -> m (Map Text FlowListScores)
flowSocialListByMode' ns nt st = do flowSocialListByMode' ns nt st = do
ngramsRepos <- mapM (\l -> getListNgrams [l] nt) ns ngramsRepos <- mapM (\l -> getListNgrams [l] nt) ns
pure $ toFlowListScores st Map.empty ngramsRepos pure $ toFlowListScores st Map.empty ngramsRepos
......
...@@ -106,11 +106,9 @@ toFlowListScores ts = foldl' (toFlowListScores' ts) ...@@ -106,11 +106,9 @@ toFlowListScores ts = foldl' (toFlowListScores' ts)
$ Map.alter (addList $ _nre_list nre) t to'' $ Map.alter (addList $ _nre_list nre) t to''
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Main addFunctions to FlowListScores -- | Main addFunctions to groupResolution the FlowListScores
------------------------------------------------------------------------ -- Use patch-map library here
-- diff, transformWith patches simplifies functions below
-- | Unseful but nice comment:
-- "this function looks like an ASCII bird"
addList :: ListType addList :: ListType
-> Maybe FlowListScores -> Maybe FlowListScores
-> Maybe FlowListScores -> Maybe FlowListScores
...@@ -121,16 +119,30 @@ addList l (Just (FlowListScores mapParent mapList)) = ...@@ -121,16 +119,30 @@ addList l (Just (FlowListScores mapParent mapList)) =
Just $ FlowListScores mapParent mapList' Just $ FlowListScores mapParent mapList'
where where
mapList' = addList' l mapList mapList' = addList' l mapList
-- * Unseful but nice comment:
-- "the addList function looks like an ASCII bird in a blue sky"
-- _
-- ___| | ___ _
-- / __| |/ / | | |
-- \__ \ <| |_| |
-- |___/_|\_\\__, |
-- |___/
--
--
--
-- | Concrete function to pass to PatchMap
addList' :: ListType -> Map ListType Int -> Map ListType Int addList' :: ListType -> Map ListType Int -> Map ListType Int
addList' l m = Map.alter (plus l) l m addList' l m = Map.alter (plus l) l m
where where
plus CandidateTerm Nothing = Just 1 plus CandidateTerm Nothing = Just 1
plus CandidateTerm (Just x) = Just $ x + 1 plus CandidateTerm (Just x) = Just $ x + 1
plus _ Nothing = Just 3 plus MapTerm Nothing = Just 2
plus _ (Just x) = Just $ x + 3 plus MapTerm (Just x) = Just $ x + 2
plus StopTerm Nothing = Just 3
plus StopTerm (Just x) = Just $ x + 3
------------------------------------------------------------------------ ------------------------------------------------------------------------
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
...@@ -87,6 +87,9 @@ countList t m input = case Map.lookup t m of ...@@ -87,6 +87,9 @@ countList t m input = case Map.lookup t m of
plus CandidateTerm Nothing = Just 1 plus CandidateTerm Nothing = Just 1
plus CandidateTerm (Just x) = Just $ x + 1 plus CandidateTerm (Just x) = Just $ x + 1
plus _ Nothing = Just 3 plus MapTerm Nothing = Just 2
plus _ (Just x) = Just $ x + 3 plus MapTerm (Just x) = Just $ x + 2
plus StopTerm Nothing = Just 3
plus StopTerm (Just x) = Just $ x + 3
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