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
9ff74a4b
Commit
9ff74a4b
authored
Nov 18, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Social List starting from scratch (zero corpus)
parent
436eec32
Pipeline
#1224
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
5 deletions
+34
-5
Group.hs
src/Gargantext/Core/Text/List/Group.hs
+1
-2
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+33
-3
No files found.
src/Gargantext/Core/Text/List/Group.hs
View file @
9ff74a4b
...
...
@@ -22,7 +22,7 @@ import Control.Lens (set)
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
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.Core.Text.List.Social.Scores
(
FlowListScores
(
..
))
import
Gargantext.Core.Text.List.Group.WithStem
...
...
@@ -93,7 +93,6 @@ toGroupedText_test =
)
]
------------------------------------------------------------------------
-- | To be removed
addListType
::
Map
Text
ListType
->
GroupedText
a
->
GroupedText
a
...
...
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
9ff74a4b
...
...
@@ -52,14 +52,30 @@ instance Semigroup a => Semigroup (GroupedTextScores a) where
(
GroupedTextScores
l2
s2
c2
)
=
GroupedTextScores
(
l1
<>
l2
)
(
s1
<>
s2
)
(
c1
<>
c2
)
------
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
groupWithScores
::
Map
Text
FlowListScores
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
groupWithScores
scores
ms
=
addScore
ms
$
fromGroupedScores
$
fromListScores
scores
groupWithScores
scores
ms
=
orphans
<>
groups
where
groups
=
addScore
ms
$
fromGroupedScores
$
fromListScores
scores
orphans
=
addIfNotExist
scores
ms
addScore
::
Map
Text
(
Set
NodeId
)
...
...
@@ -67,12 +83,26 @@ addScore :: Map Text (Set NodeId)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
addScore
mapNs
=
Map
.
mapWithKey
scoring
where
scoring
k
g
=
set
gts_score
(
Set
.
unions
$
catMaybes
$
map
(
\
n
->
Map
.
lookup
n
mapNs
)
$
[
k
]
<>
(
Set
.
toList
$
view
gts_children
g
)
)
g
addIfNotExist
::
Map
Text
FlowListScores
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
addIfNotExist
mapSocialScores
mapScores
=
foldl'
(
addIfNotExist'
mapSocialScores
mapScores
)
Map
.
empty
$
Map
.
toList
mapScores
where
addIfNotExist'
mss
ms
m
(
t
,
ns
)
=
case
Map
.
lookup
t
mss
of
Nothing
->
Map
.
alter
(
add
(
t
,
ns
))
t
m
_
->
m
add
(
t
,
ns
)
Nothing
=
Just
$
GroupedTextScores
Nothing
ns
Set
.
empty
add
_
_
=
Nothing
-- should not be present
------------------------------------------------------------------------
...
...
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