Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
701ef9ac
Commit
701ef9ac
authored
Nov 10, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] SocialList with TypeFamilies
parent
1461659b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
16 deletions
+56
-16
Group.hs
src/Gargantext/Core/Text/Group.hs
+56
-16
No files found.
src/Gargantext/Core/Text/Group.hs
View file @
701ef9ac
...
...
@@ -10,11 +10,13 @@ Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-}
module
Gargantext.Core.Text.Group
where
import
Control.Lens
(
makeLenses
,
set
)
import
Control.Lens
(
makeLenses
,
set
,
(
^.
)
)
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
import
Data.Text
(
Text
)
...
...
@@ -23,7 +25,7 @@ import Gargantext.Core.Text (size)
import
Gargantext.Core.Types
(
ListType
(
..
))
-- (MasterCorpusId, UserCorpusId)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
-- import Gargantext.Core.Text.List.Learn (Model(..))
import
Gargantext.Core.Text.List.Social.Group
(
FlowListScores
)
import
Gargantext.Core.Text.List.Social.Group
(
FlowListScores
(
..
),
flc_lists
)
import
Gargantext.Core.Text.Terms.Mono.Stem
(
stem
)
import
Gargantext.Prelude
import
qualified
Data.Set
as
Set
...
...
@@ -115,24 +117,62 @@ grouping (GroupedText lt1 label1 score1 group1 s1 stem1 nodes1)
nodes
=
Set
.
union
nodes1
nodes2
------------------------------------------------------------------------
toGroupedText_FlowListScores
::
Ord
a
=>
Map
Text
(
Set
NodeId
)
toGroupedText_FlowListScores
::
(
FlowList
a
,
Ord
a
)
=>
[
a
]
->
Map
Text
FlowListScores
->
Map
Text
(
GroupedText
a
)
->
Map
Text
(
GroupedText
b
)
toGroupedText_FlowListScores
=
undefined
toGroupedText_FlowListScores'
::
Ord
a
=>
Map
Text
(
Set
NodeId
)
toGroupedText_FlowListScores'
::
(
FlowList
a
,
b
~
GroupFamily
a
)
=>
[
a
]
->
Map
Text
FlowListScores
->
(
[(
Text
,
Set
NodeId
)
]
,
Map
Text
(
GroupedText
a
)
->
(
[
a
]
,
Map
Text
(
GroupedText
b
)
)
toGroupedText_FlowListScores'
=
undefined
toGroupedText_FlowListScores'
ms
mf
=
foldl'
fun_group
start
ms
where
start
=
(
[]
,
Map
.
empty
)
fun_group
(
left
,
grouped
)
current
=
case
Map
.
lookup
(
hasNgrams
current
)
mf
of
Just
scores
->
(
left
,
Map
.
alter
(
updateWith
scores
current
)
(
hasNgrams
current
)
grouped
)
Nothing
->
(
current
:
left
,
grouped
)
updateWith
scores
current
Nothing
=
Just
$
createGroupWith
scores
current
updateWith
scores
current
(
Just
x
)
=
Just
$
updateGroupWith
scores
current
x
type
FlowList
a
=
(
HasNgrams
a
,
HasGroup
a
)
class
HasNgrams
a
where
hasNgrams
::
a
->
Text
class
HasGroup
a
where
createGroupWith
::
(
b
~
GroupFamily
a
)
=>
FlowListScores
->
a
->
GroupedText
b
updateGroupWith
::
(
b
~
GroupFamily
a
)
=>
FlowListScores
->
a
->
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
createGroupWith
fs
(
t
,
ns
)
=
GroupedText
(
mapMax
$
fs
^.
flc_lists
)
t
(
Set
.
size
ns
)
Set
.
empty
(
size
t
)
t
ns
updateGroupWith
fs
(
t
,
ns
)
g
=
undefined
mapMax
::
Map
a
b
->
Maybe
a
mapMax
m
=
(
fst
.
fst
)
<$>
Map
.
maxViewWithKey
m
------------------------------------------------------------------------
type
Stem
=
Text
type
Label
=
Text
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment