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
8156a769
Commit
8156a769
authored
Nov 23, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FUN] toGroupedText before toGroupedTextTree.
parent
f25948fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
23 deletions
+46
-23
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+45
-22
Tree.hs
src/Gargantext/Database/Query/Tree.hs
+1
-1
No files found.
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
8156a769
...
...
@@ -14,12 +14,12 @@ Portability : POSIX
module
Gargantext.Core.Text.List.Group.WithScores
where
import
Control.Lens
(
makeLenses
,
view
,
set
)
import
Control.Lens
(
makeLenses
,
view
,
set
,
over
)
import
Data.Semigroup
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
import
Data.Monoid
(
mempty
)
import
Data.Maybe
(
catMaybes
)
import
Data.Maybe
(
catMaybes
,
fromMaybe
)
import
Data.Text
(
Text
)
import
Gargantext.Core.Types
(
ListType
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
...
...
@@ -45,12 +45,54 @@ groupWithScores' flc _scores = FlowCont groups orphans
-- orphans have been filtered already
------------------------------------------------------------------------
mapMaybeParent
::
(
Text
->
Set
NodeId
)
->
Map
Text
FlowListScores
->
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTextScores'
(
Set
NodeId
)))
mapMaybeParent
f
=
Map
.
fromListWith
(
<>
)
.
(
map
(
fromScores''
f
))
.
Map
.
toList
fromScores''
::
(
Text
->
Set
NodeId
)
->
(
Text
,
FlowListScores
)
->
(
Maybe
Parent
,
Map
Text
(
GroupedTextScores'
(
Set
NodeId
)))
fromScores''
f'
(
t
,
fs
)
=
(
maybeParent
,
Map
.
fromList
[(
t
,
set
gts'_score
(
f'
t
)
$
set
gts'_listType
maybeList
mempty
)]
)
where
maybeParent
=
keyWithMaxValue
$
view
fls_parents
fs
maybeList
=
keyWithMaxValue
$
view
fls_listType
fs
toGroupedTree
::
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTextScores'
(
Set
NodeId
)))
->
Map
Parent
(
GroupedTextScores'
(
Set
NodeId
))
toGroupedTree
m
=
case
Map
.
lookup
Nothing
m
of
Nothing
->
Map
.
empty
Just
m'
->
toGroupedTree'
m
m'
toGroupedTree'
::
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTextScores'
(
Set
NodeId
)))
->
(
Map
Text
(
GroupedTextScores'
(
Set
NodeId
)))
->
Map
Parent
(
GroupedTextScores'
(
Set
NodeId
))
toGroupedTree'
m
notEmpty
|
notEmpty
==
Map
.
empty
=
Map
.
empty
|
otherwise
=
Map
.
mapWithKey
(
addGroup
m
)
notEmpty
where
addGroup
m'
k
v
=
over
gts'_children
(
(
toGroupedTree'
m'
)
.
(
Map
.
union
(
fromMaybe
Map
.
empty
$
Map
.
lookup
(
Just
k
)
m'
)
)
)
v
--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
...
...
@@ -67,16 +109,7 @@ fromListScores' = Map.fromListWith (<>) . (map fromScores') . Map.toList
-- We ignore the ListType of children for the parents' one
-- added after and winner of semigroup actions
-- | TODO add score here
fromScores''
::
(
Text
,
FlowListScores
)
->
(
Maybe
Parent
,
[
GroupedTextScores'
(
Set
NodeId
)])
fromScores''
(
t
,
fs
)
=
(
maybeParent
,
[
set
gts'_listType
maybeList
mempty
]
)
where
maybeParent
=
keyWithMaxValue
$
view
fls_parents
fs
maybeList
=
keyWithMaxValue
$
view
fls_listType
fs
-- toTree :: [(Maybe Parent, [GroupedWithListScores])] -> Map Parent (
toGroupedScores'
::
Map
Parent
GroupedWithListScores
...
...
@@ -88,16 +121,6 @@ toGroupedScores' = undefined
--8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<--
-- TODO To be removed
data
GroupedTextScores
score
=
GroupedTextScores
{
_gts_listType
::
!
(
Maybe
ListType
)
...
...
src/Gargantext/Database/Query/Tree.hs
View file @
8156a769
...
...
@@ -174,7 +174,7 @@ toTree m =
->
Tree
NodeTree
toTree'
m'
n
=
TreeN
(
toNodeTree
n
)
$
-- | Lines below are equ
al
computationally but not semantically
-- | Lines below are equ
ivalent
computationally but not semantically
-- m' ^.. at (Just $ _dt_nodeId n) . _Just . each . to (toTree' m')
toListOf
(
at
(
Just
$
_dt_nodeId
n
)
.
_Just
.
each
.
to
(
toTree'
m'
))
m'
...
...
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