Commit 137eca93 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] SocialList with Functional Dependency

parent 701ef9ac
Pipeline #1203 canceled with stage
...@@ -12,6 +12,8 @@ Portability : POSIX ...@@ -12,6 +12,8 @@ Portability : POSIX
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FunctionalDependencies #-}
module Gargantext.Core.Text.Group module Gargantext.Core.Text.Group
where where
...@@ -117,7 +119,7 @@ grouping (GroupedText lt1 label1 score1 group1 s1 stem1 nodes1) ...@@ -117,7 +119,7 @@ grouping (GroupedText lt1 label1 score1 group1 s1 stem1 nodes1)
nodes = Set.union nodes1 nodes2 nodes = Set.union nodes1 nodes2
------------------------------------------------------------------------ ------------------------------------------------------------------------
toGroupedText_FlowListScores :: ( FlowList a toGroupedText_FlowListScores :: ( FlowList a b
, Ord a , Ord a
) )
=> [a] => [a]
...@@ -126,8 +128,7 @@ toGroupedText_FlowListScores :: ( FlowList a ...@@ -126,8 +128,7 @@ toGroupedText_FlowListScores :: ( FlowList a
toGroupedText_FlowListScores = undefined toGroupedText_FlowListScores = undefined
toGroupedText_FlowListScores' :: ( FlowList a toGroupedText_FlowListScores' :: ( FlowList a b
, b ~ GroupFamily a
) )
=> [a] => [a]
-> Map Text FlowListScores -> Map Text FlowListScores
...@@ -144,24 +145,19 @@ toGroupedText_FlowListScores' ms mf = foldl' fun_group start ms ...@@ -144,24 +145,19 @@ toGroupedText_FlowListScores' ms mf = foldl' fun_group start ms
updateWith scores current Nothing = Just $ createGroupWith scores current updateWith scores current Nothing = Just $ createGroupWith scores current
updateWith scores current (Just x) = Just $ updateGroupWith scores current x updateWith scores current (Just x) = Just $ updateGroupWith scores current x
type FlowList a = (HasNgrams a, HasGroup a) type FlowList a b = (HasNgrams a, HasGroup a b)
class HasNgrams a where class HasNgrams a where
hasNgrams :: a -> Text hasNgrams :: a -> Text
class HasGroup a where class HasGroup a b | a -> b where
createGroupWith :: (b ~ GroupFamily a) => FlowListScores -> a -> GroupedText b createGroupWith :: FlowListScores -> a -> GroupedText b
updateGroupWith :: (b ~ GroupFamily a) updateGroupWith :: FlowListScores -> a
=> FlowListScores -> a
-> GroupedText b -> GroupedText b
-> GroupedText b -> GroupedText b
-- | Check if functional dependency is better
type family GroupFamily a
type instance GroupFamily (Text, Set NodeId) = Int
------------------------------------------ ------------------------------------------
instance HasGroup (Text, Set NodeId) where instance HasGroup (Text, Set NodeId) Int where
createGroupWith fs (t, ns) = GroupedText (mapMax $ fs ^. flc_lists) createGroupWith fs (t, ns) = GroupedText (mapMax $ fs ^. flc_lists)
t t
(Set.size ns) (Set.size ns)
......
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