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
141
Issues
141
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
0ce0a194
Commit
0ce0a194
authored
Nov 23, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Type] GroupedTreeScores
parent
8156a769
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
65 deletions
+37
-65
Prelude.hs
src/Gargantext/Core/Text/List/Group/Prelude.hs
+21
-16
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+16
-49
No files found.
src/Gargantext/Core/Text/List/Group/Prelude.hs
View file @
0ce0a194
...
...
@@ -31,26 +31,28 @@ import qualified Data.Map as Map
-- Tree of GroupedTextScores
-- Target : type FlowCont Text GroupedTextScores'
data
GroupedT
extScores'
score
=
GroupedT
extScores'
{
_gts'_listType
::
!
(
Maybe
ListType
)
,
_gts'_children
::
!
(
Map
Text
(
GroupedTextScores'
score
))
,
_gts'_score
::
score
}
deriving
(
Show
,
Ord
,
Eq
)
instance
(
Semigroup
a
,
Ord
a
)
=>
Semigroup
(
GroupedT
extScores'
a
)
where
(
<>
)
(
GroupedT
extScores'
l1
s1
c1
)
(
GroupedT
extScores'
l2
s2
c2
)
=
GroupedT
extScores'
(
l1
<>
l2
)
(
s1
<>
s2
)
(
c1
<>
c2
)
data
GroupedT
reeScores
score
=
GroupedT
reeScores
{
_gts'_listType
::
!
(
Maybe
ListType
)
,
_gts'_children
::
!
(
Map
Text
(
GroupedTreeScores
score
))
,
_gts'_score
::
score
}
deriving
(
Show
,
Ord
,
Eq
)
instance
(
Semigroup
a
,
Ord
a
)
=>
Semigroup
(
GroupedT
reeScores
a
)
where
(
<>
)
(
GroupedT
reeScores
l1
s1
c1
)
(
GroupedT
reeScores
l2
s2
c2
)
=
GroupedT
reeScores
(
l1
<>
l2
)
(
s1
<>
s2
)
(
c1
<>
c2
)
instance
(
Ord
score
,
Monoid
score
)
=>
Monoid
(
GroupedT
extScores'
score
)
where
mempty
=
GroupedT
extScores'
Nothing
Map
.
empty
mempty
=>
Monoid
(
GroupedT
reeScores
score
)
where
mempty
=
GroupedT
reeScores
Nothing
Map
.
empty
mempty
makeLenses
'G
r
oupedT
extScores'
makeLenses
'G
r
oupedT
reeScores
-- | Intermediary Type
-- 8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--
-- TODO to remove below
data
GroupedWithListScores
=
GroupedWithListScores
{
_gwls_listType
::
!
(
Maybe
ListType
)
,
_gwls_children
::
!
(
Set
Text
)
...
...
@@ -66,6 +68,9 @@ instance Monoid GroupedWithListScores where
mempty
=
GroupedWithListScores
Nothing
Set
.
empty
makeLenses
''
G
roupedWithListScores
-- 8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
0ce0a194
...
...
@@ -35,25 +35,26 @@ import qualified Data.Map as Map
-- | Main function
groupWithScores'
::
FlowCont
Text
FlowListScores
->
(
Text
->
Set
NodeId
)
-- Map Text (Set NodeId)
->
FlowCont
Text
(
GroupedT
extScores'
(
Set
NodeId
))
groupWithScores'
flc
_
scores
=
FlowCont
groups
orphans
->
FlowCont
Text
(
GroupedT
reeScores
(
Set
NodeId
))
groupWithScores'
flc
scores
=
FlowCont
groups
orphans
where
groups
=
toGroupedTextScores'
$
view
flc_scores
flc
-- parent/child relation is inherited from social lists
groups
=
toGroupedTree
$
toMapMaybeParent
scores
$
view
flc_scores
flc
orphans
=
(
view
flc_cont
flc
)
-- orphans have been filtered already
orphans
=
(
view
flc_cont
flc
)
------------------------------------------------------------------------
mapMaybeParent
::
(
Text
->
Set
NodeId
)
toMapMaybeParent
::
(
Text
->
Set
NodeId
)
->
Map
Text
FlowListScores
->
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTextScores'
(
Set
NodeId
)))
mapMaybeParent
f
=
Map
.
fromListWith
(
<>
)
.
(
map
(
fromScores''
f
))
.
Map
.
toList
->
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTreeScores
(
Set
NodeId
)))
toMapMaybeParent
f
=
Map
.
fromListWith
(
<>
)
.
(
map
(
fromScores''
f
))
.
Map
.
toList
fromScores''
::
(
Text
->
Set
NodeId
)
->
(
Text
,
FlowListScores
)
->
(
Maybe
Parent
,
Map
Text
(
GroupedT
extScores'
(
Set
NodeId
)))
->
(
Maybe
Parent
,
Map
Text
(
GroupedT
reeScores
(
Set
NodeId
)))
fromScores''
f'
(
t
,
fs
)
=
(
maybeParent
,
Map
.
fromList
[(
t
,
set
gts'_score
(
f'
t
)
$
set
gts'_listType
maybeList
mempty
...
...
@@ -63,15 +64,15 @@ fromScores'' f' (t, fs) = ( maybeParent
maybeParent
=
keyWithMaxValue
$
view
fls_parents
fs
maybeList
=
keyWithMaxValue
$
view
fls_listType
fs
toGroupedTree
::
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedT
extScores'
(
Set
NodeId
)))
->
Map
Parent
(
GroupedT
extScores'
(
Set
NodeId
))
toGroupedTree
::
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedT
reeScores
(
Set
NodeId
)))
->
Map
Parent
(
GroupedT
reeScores
(
Set
NodeId
))
toGroupedTree
m
=
case
Map
.
lookup
Nothing
m
of
Nothing
->
Map
.
empty
Just
m'
->
toGroupedTree'
m
m'
toGroupedTree'
::
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedT
extScores'
(
Set
NodeId
)))
->
(
Map
Text
(
GroupedT
extScores'
(
Set
NodeId
)))
->
Map
Parent
(
GroupedT
extScores'
(
Set
NodeId
))
toGroupedTree'
::
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedT
reeScores
(
Set
NodeId
)))
->
(
Map
Text
(
GroupedT
reeScores
(
Set
NodeId
)))
->
Map
Parent
(
GroupedT
reeScores
(
Set
NodeId
))
toGroupedTree'
m
notEmpty
|
notEmpty
==
Map
.
empty
=
Map
.
empty
|
otherwise
=
Map
.
mapWithKey
(
addGroup
m
)
notEmpty
...
...
@@ -88,40 +89,6 @@ toGroupedTree' m notEmpty
--8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<--
-- TODO TO BE REMOVED
------------------------------------------------------------------------
toGroupedTextScores'
::
Map
Text
FlowListScores
->
Map
Parent
(
GroupedTextScores'
(
Set
NodeId
))
toGroupedTextScores'
=
toGroupedScores'
.
fromListScores'
------------------------------------------------------------------------
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
,
set
gwls_listType
(
keyWithMaxValue
$
view
fls_listType
fs
)
mempty
)
-- Parent case: taking its listType, for now children Set is empty
Just
parent
->
(
parent
,
set
gwls_children
(
Set
.
singleton
t
)
mempty
)
-- 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)
-- toGroupedTree :: GroupedW
-- TODO To be removed
data
GroupedTextScores
score
=
GroupedTextScores
{
_gts_listType
::
!
(
Maybe
ListType
)
,
_gts_score
::
score
...
...
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