Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Przemyslaw Kaminski
haskell-gargantext
Commits
62bd8d8c
Commit
62bd8d8c
authored
Nov 17, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT:SocialLists] Hierarchical inheritence working
parent
cb1a1ebc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+14
-13
No files found.
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
62bd8d8c
...
...
@@ -14,8 +14,7 @@ Portability : POSIX
module
Gargantext.Core.Text.List.Group.WithScores
where
import
Data.Maybe
(
fromMaybe
)
import
Control.Lens
(
makeLenses
,
set
,
over
,
view
)
import
Control.Lens
(
makeLenses
,
over
,
view
)
import
Data.Semigroup
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
...
...
@@ -28,7 +27,6 @@ import Gargantext.Prelude
import
qualified
Data.Set
as
Set
import
qualified
Data.Map
as
Map
------------------------------------------------------------------------
-- | Main Types
data
GroupedWithListScores
=
...
...
@@ -58,28 +56,31 @@ instance Semigroup a => Semigroup (GroupedTextScores a) where
groupWithScores
::
Map
Text
FlowListScores
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
groupWithScores
scores
=
undefined
groupWithScores
scores
ms
=
foldl'
(
addScore
scores
)
start
(
Map
.
toList
ms
)
where
start
=
fromGroupedScores
$
fromListScores
scores
-- | Add scores depending on being either parent or child or orphan
addScore
::
Map
Text
FlowListScores
->
(
Text
,
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
->
(
Text
,
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
addScore
scores
(
t
,
ns
)
ms
=
Map
.
alter
(
isParent
ns
)
t
ms
addScore
scores
ms
(
t
,
ns
)
=
Map
.
alter
(
isParent
ns
)
t
ms
where
-- is parent case
isParent
ns'
(
Just
(
GroupedTextScores
l
s
c
))
=
let
ns''
=
ns'
<>
s
in
Just
(
GroupedTextScores
l
ns''
c
)
-- is either child or orphan case
isParent
ns'
Nothing
=
case
Map
.
lookup
t
scores
of
--
check isChild
--
is child case
Just
fls
->
case
keyWithMaxValue
$
view
fls_parents
fls
of
Just
parent
->
undefined
-- over gts_score (Set.insert
ns') <$> Map.lookup parent ms
Just
parent
->
over
gts_score
(
<>
ns'
)
<$>
Map
.
lookup
parent
ms
Nothing
->
panic
"Should not happen"
-- is Orphan
Nothing
->
undefined
-- GroupedTextScores Nothing ns' Set.empty
isParent
ns'
(
Just
(
GroupedTextScores
l
s
c
))
=
let
ns''
=
ns'
<>
s
in
Just
(
GroupedTextScores
l
ns''
c
)
-- is Orphan case
Nothing
->
Just
$
GroupedTextScores
Nothing
ns'
Set
.
empty
------------------------------------------------------------------------
fromGroupedScores
::
Map
Parent
GroupedWithListScores
->
Map
Parent
(
GroupedTextScores
(
Set
NodeId
))
...
...
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