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
b9de7802
Commit
b9de7802
authored
Nov 20, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT] FlowCont for Group with Scores (WIP).
parent
962046fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
54 deletions
+120
-54
Prelude.hs
src/Gargantext/Core/Text/List/Group/Prelude.hs
+59
-0
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+59
-52
Prelude.hs
src/Gargantext/Core/Text/List/Social/Prelude.hs
+2
-2
No files found.
src/Gargantext/Core/Text/List/Group/Prelude.hs
0 → 100644
View file @
b9de7802
{-|
Module : Gargantext.Core.Text.List.Group.Prelude
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Core.Text.List.Group.Prelude
where
import
Control.Lens
(
makeLenses
,
view
,
set
)
import
Data.Semigroup
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Data.Text
(
Text
)
import
Gargantext.Core.Types
(
ListType
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Prelude
import
qualified
Data.Set
as
Set
import
qualified
Data.Map
as
Map
------------------------------------------------------------------------
-- | Group With Scores Main Types
-- Tree of GroupedTextScores
-- Target : type FlowCont Text GroupedTextScores'
data
GroupedTextScores'
score
=
GroupedTextScores'
{
_gts'_listType
::
!
(
Maybe
ListType
)
,
_gts'_score
::
score
,
_gts'_children
::
!
(
Set
(
GroupedTextScores'
score
))
}
deriving
(
Show
,
Ord
,
Eq
)
makeLenses
'G
r
oupedTextScores'
instance
(
Semigroup
a
,
Ord
a
)
=>
Semigroup
(
GroupedTextScores'
a
)
where
(
<>
)
(
GroupedTextScores'
l1
s1
c1
)
(
GroupedTextScores'
l2
s2
c2
)
=
GroupedTextScores'
(
l1
<>
l2
)
(
s1
<>
s2
)
(
c1
<>
c2
)
-- | Intermediary Type
data
GroupedWithListScores
=
GroupedWithListScores
{
_gwls_children
::
!
(
Set
Text
)
,
_gwls_listType
::
!
(
Maybe
ListType
)
}
deriving
(
Show
)
makeLenses
''
G
roupedWithListScores
instance
Semigroup
GroupedWithListScores
where
(
<>
)
(
GroupedWithListScores
c1
l1
)
(
GroupedWithListScores
c2
l2
)
=
GroupedWithListScores
(
c1
<>
c2
)
(
l1
<>
l2
)
------------------------------------------------------------------------
-- | Group With Stem Main Types
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
b9de7802
...
@@ -20,28 +20,64 @@ import Data.Set (Set)
...
@@ -20,28 +20,64 @@ import Data.Set (Set)
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Data.Maybe
(
catMaybes
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Gargantext.Core.Types
(
ListType
(
..
))
-- (MasterCorpusId, UserCorpusId)
import
Gargantext.Core.Types
(
ListType
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Core.Text.List.Group.Prelude
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Main Types
-- | Main function
data
GroupedWithListScores
=
groupWithScores'
::
FlowCont
Text
FlowListScores
GroupedWithListScores
{
_gwls_children
::
!
(
Set
Text
)
->
(
Text
->
Set
NodeId
)
-- Map Text (Set NodeId)
,
_gwls_listType
::
!
(
Maybe
ListType
)
->
FlowCont
Text
(
GroupedTextScores'
(
Set
NodeId
))
}
deriving
(
Show
)
groupWithScores'
flc
scores
=
FlowCont
groups
orphans
makeLenses
''
G
roupedWithListScores
where
instance
Semigroup
GroupedWithListScores
where
groups
=
toGroupedTextScores'
$
view
flc_scores
flc
(
<>
)
(
GroupedWithListScores
c1
l1
)
orphans
=
(
view
flc_cont
flc
)
(
GroupedWithListScores
c2
l2
)
=
GroupedWithListScores
(
c1
<>
c2
)
(
l1
<>
l2
)
toGroupedTextScores'
::
Map
Text
FlowListScores
->
Map
Parent
(
GroupedTextScores'
(
Set
NodeId
))
------
toGroupedTextScores'
=
toGroupedScores'
.
fromListScores'
-- To be removed
------------------------------------------------------------------------
fromListScores'
::
Map
Text
FlowListScores
->
Map
Parent
GroupedWithListScores
fromListScores'
=
Map
.
fromListWith
(
<>
)
.
(
map
fromScores'
)
.
Map
.
toList
where
fromScores'
::
(
Text
,
FlowListScores
)
->
(
Text
,
GroupedWithListScores
)
fromScores'
(
t
,
fs
)
=
case
(
keyWithMaxValue
$
view
fls_parents
fs
)
of
Nothing
->
(
t
,
GroupedWithListScores
Set
.
empty
(
keyWithMaxValue
$
view
fls_listType
fs
))
-- Parent case: taking its listType, for now children Set is empty
Just
parent
->
(
parent
,
GroupedWithListScores
(
Set
.
singleton
t
)
Nothing
)
-- We ignore the ListType of children for the parents' one
-- added after and winner of semigroup actions
toGroupedScores'
::
Map
Parent
GroupedWithListScores
->
Map
Parent
(
GroupedTextScores'
(
Set
NodeId
))
toGroupedScores'
=
undefined
-- Map.map (\(GroupedWithListScores c l) -> GroupedTextScores l Set.empty c)
--8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<--
-- TODO To be removed
data
GroupedTextScores
score
=
data
GroupedTextScores
score
=
GroupedTextScores
{
_gts_listType
::
!
(
Maybe
ListType
)
GroupedTextScores
{
_gts_listType
::
!
(
Maybe
ListType
)
,
_gts_score
::
score
,
_gts_score
::
score
...
@@ -49,25 +85,12 @@ data GroupedTextScores score =
...
@@ -49,25 +85,12 @@ data GroupedTextScores score =
}
deriving
(
Show
)
}
deriving
(
Show
)
makeLenses
'G
r
oupedTextScores
makeLenses
'G
r
oupedTextScores
instance
Semigroup
a
=>
Semigroup
(
GroupedTextScores
a
)
where
instance
Semigroup
a
=>
Semigroup
(
GroupedTextScores
a
)
where
(
<>
)
(
GroupedTextScores
l1
s1
c1
)
(
<>
)
(
GroupedTextScores
l1
s1
c1
)
(
GroupedTextScores
l2
s2
c2
)
(
GroupedTextScores
l2
s2
c2
)
=
GroupedTextScores
(
l1
<>
l2
)
(
s1
<>
s2
)
(
c1
<>
c2
)
=
GroupedTextScores
(
l1
<>
l2
)
(
s1
<>
s2
)
------
(
c1
<>
c2
)
-- | Tree of GroupedTextScores
data
GroupedTextScores'
score
=
GroupedTextScores'
{
_gts'_listType
::
!
(
Maybe
ListType
)
,
_gts'_score
::
score
,
_gts'_children
::
!
(
Set
(
GroupedTextScores'
score
))
}
deriving
(
Show
,
Ord
,
Eq
)
makeLenses
'G
r
oupedTextScores'
instance
(
Semigroup
a
,
Ord
a
)
=>
Semigroup
(
GroupedTextScores'
a
)
where
(
<>
)
(
GroupedTextScores'
l1
s1
c1
)
(
GroupedTextScores'
l2
s2
c2
)
=
GroupedTextScores'
(
l1
<>
l2
)
(
s1
<>
s2
)
(
c1
<>
c2
)
------------------------------------------------------------------------
-- | Main function
-- | Main function
groupWithScores
::
Map
Text
FlowListScores
groupWithScores
::
Map
Text
FlowListScores
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
Set
NodeId
)
...
@@ -79,20 +102,6 @@ groupWithScores scores ms = orphans <> groups
...
@@ -79,20 +102,6 @@ groupWithScores scores ms = orphans <> groups
$
fromListScores
scores
$
fromListScores
scores
orphans
=
addIfNotExist
scores
ms
orphans
=
addIfNotExist
scores
ms
{-
groupWithScores :: Map Text FlowListScores
-> Map Text (Set NodeId)
-> Map Text (GroupedTextScores (Set NodeId))
groupWithScores scores ms = orphans <> groups
where
groups = addScore ms
$ fromGroupedScores
$ fromListScores scores
orphans = addIfNotExist scores ms
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
addScore
::
Map
Text
(
Set
NodeId
)
addScore
::
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
...
@@ -121,11 +130,6 @@ addIfNotExist mapSocialScores mapScores =
...
@@ -121,11 +130,6 @@ addIfNotExist mapSocialScores mapScores =
add
_
_
=
Nothing
-- should not be present
add
_
_
=
Nothing
-- should not be present
------------------------------------------------------------------------
------------------------------------------------------------------------
toGroupedTextScores'
::
Map
Parent
GroupedWithListScores
-- -> Map Text (Set NodeId)
->
Map
Parent
(
GroupedTextScores'
(
Set
NodeId
))
toGroupedTextScores'
par
=
undefined
------------------------------------------------------------------------
------------------------------------------------------------------------
fromGroupedScores
::
Map
Parent
GroupedWithListScores
fromGroupedScores
::
Map
Parent
GroupedWithListScores
->
Map
Parent
(
GroupedTextScores
(
Set
NodeId
))
->
Map
Parent
(
GroupedTextScores
(
Set
NodeId
))
...
@@ -144,3 +148,6 @@ fromListScores = Map.fromListWith (<>) . (map fromScores') . Map.toList
...
@@ -144,3 +148,6 @@ fromListScores = Map.fromListWith (<>) . (map fromScores') . Map.toList
-- We ignore the ListType of children for the parents' one
-- We ignore the ListType of children for the parents' one
-- added after and winner of semigroup actions
-- added after and winner of semigroup actions
--8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<--
src/Gargantext/Core/Text/List/Social/Prelude.hs
View file @
b9de7802
...
@@ -8,13 +8,13 @@ Stability : experimental
...
@@ -8,13 +8,13 @@ Stability : experimental
Portability : POSIX
Portability : POSIX
-}
-}
------------------------------------------------------------------------
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilies #-}
------------------------------------------------------------------------
module
Gargantext.Core.Text.List.Social.Prelude
module
Gargantext.Core.Text.List.Social.Prelude
where
where
...
...
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