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
6eb6b6cd
Commit
6eb6b6cd
authored
Nov 16, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] SocialList Map Text ScoresParent to Map Text Children
parent
51991eea
Pipeline
#1211
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
10 deletions
+72
-10
Group.hs
src/Gargantext/Core/Text/List/Group.hs
+31
-10
Scores.hs
src/Gargantext/Core/Text/List/Social/Scores.hs
+41
-0
No files found.
src/Gargantext/Core/Text/List/Group.hs
View file @
6eb6b6cd
...
...
@@ -110,6 +110,7 @@ groupedTextWithStem gparams from =
)
------------------------------------------------------------------------
------------------------------------------------------------------------
type
Stem
=
Text
data
GroupedText
score
=
...
...
@@ -158,15 +159,23 @@ createGroupWithScores' fs (t, ns) = GroupedText (keyWithMaxValue $ fs ^. flc_l
Nothing
->
(
t
,
Set
.
empty
)
Just
t'
->
(
t'
,
Set
.
singleton
t
)
updateGroupWithScores'
fs
(
t
,
ns
)
g
=
set
gt_listType
(
keyWithMaxValue
$
fs
^.
flc_lists
)
$
set
gt_nodes
(
Set
.
union
ns
$
g
^.
gt_nodes
)
g
------------------------------------------------------------------------
updateGroupWithScores'
::
FlowListScores
->
(
a
,
Set
NodeId
)
->
GroupedText
score
->
GroupedText
score
updateGroupWithScores'
fs
(
t
,
ns
)
g
=
set
gt_listType
(
keyWithMaxValue
$
fs
^.
flc_lists
)
$
set
gt_nodes
(
Set
.
union
ns
$
g
^.
gt_nodes
)
g
withParent'
::
FlowListScores
->
Map
Text
(
Set
NodeId
)
->
Text
->
(
Text
,
Set
NodeId
)
->
(
Text
,
Set
NodeId
)
withParent'
fs
m
t
a
=
undefined
------------------------------------------------------------------------
toGroupedText
::
{-( FlowList c a b
Ord b
)
...
...
@@ -188,9 +197,6 @@ groupWithStem :: {- ( HasNgrams a
->
Map
Stem
(
GroupedText
Int
)
groupWithStem
_
=
snd
-- TODO (just for tests on Others Ngrams which do not need stem)
withParent'
::
Map
Text
c
->
Text
->
a
->
a
withParent'
=
undefined
groupWithScores
::
{- Ord b -- (FlowList c a b, Ord b)
=> -}
Map
Text
FlowListScores
->
Map
Text
(
Set
NodeId
)
...
...
@@ -198,21 +204,36 @@ groupWithScores :: {- Ord b -- (FlowList c a b, Ord b)
groupWithScores
scores
ms'
=
foldl'
fun_group
start
ms
where
start
=
(
[]
,
Map
.
empty
)
ms
=
map
(
\
(
t
,
ns
)
->
(
t
,
ns
))
(
Map
.
toList
ms'
)
ms
=
map
identity
(
Map
.
toList
ms'
)
fun_group
::
([(
Text
,
Set
NodeId
)],
Map
Text
(
GroupedText
Int
))
->
(
Text
,
Set
NodeId
)
->
([(
Text
,
Set
NodeId
)],
Map
Text
(
GroupedText
Int
))
->
([(
Text
,
Set
NodeId
)],
Map
Text
(
GroupedText
Int
))
fun_group
(
left
,
grouped
)
current
=
case
Map
.
lookup
(
fst
current
)
scores
of
Just
scores'
->
case
keyWithMaxValue
$
scores'
^.
flc_parents
of
Nothing
->
(
left
,
Map
.
alter
(
updateWith
scores'
current
)
(
fst
current
)
grouped
)
Just
parent
->
fun_group
(
left
,
grouped
)
(
withParent'
ms'
parent
current
)
Just
parent
->
fun_group
(
left
,
grouped
)
(
withParent'
scores'
ms'
parent
current
)
Nothing
->
(
current
:
left
,
grouped
)
updateWith
scores
current
Nothing
=
Just
$
createGroupWithScores'
scores
current
updateWith
scores
current
(
Just
x
)
=
Just
$
updateGroupWithScores'
scores
current
x
-------
groupWithScores'
::
Map
Text
GroupedWithListScores
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedText
Int
)
groupWithScores'
scores
ms
=
foldl'
(
fun_group
scores
)
start
(
Map
.
toList
ms
)
where
start
=
(
[]
,
Map
.
empty
)
fun_group
::
Map
Text
FlowListScores
->
([(
Text
,
GroupedText
Int
)],
Map
Text
(
GroupedText
Int
))
->
(
Text
,
GroupedText
Int
)
->
([(
Text
,
GroupedText
Int
)],
Map
Text
(
GroupedText
Int
))
fun_group
=
undefined
------------------------------------------------------------------------
type
FlowList
c
a
b
=
(
HasNgrams
a
,
HasGroupWithScores
a
b
,
WithParent
c
a
,
Semigroup
a
)
...
...
src/Gargantext/Core/Text/List/Social/Scores.hs
View file @
6eb6b6cd
...
...
@@ -80,6 +80,47 @@ instance Semigroup FlowListScores where
(
<>
)
(
FlowListScores
p1
l1
)
(
FlowListScores
p2
l2
)
=
FlowListScores
(
p1
<>
p2
)
(
l1
<>
l2
)
------------------------------------------------------------------------
data
GroupedWithListScores
=
GroupedWithListScores
{
_gwls_children
::
!
(
Set
Text
)
,
_gwls_listType
::
!
(
Maybe
ListType
)
}
makeLenses
''
G
roupedWithListScores
toGroupedWithListScores
::
Map
Text
FlowListScores
->
Map
Text
GroupedWithListScores
toGroupedWithListScores
ms
=
foldl'
(
toGroup
ms
)
Map
.
empty
(
Map
.
toList
ms
)
where
toGroup
::
Map
Text
FlowListScores
->
Map
Text
GroupedWithListScores
->
(
Text
,
FlowListScores
)
->
Map
Text
GroupedWithListScores
toGroup
ms'
result
(
t
,
fs
)
=
case
(
keyWithMaxValue
$
fs
^.
flc_parents
)
of
Nothing
->
Map
.
alter
(
addGroupedParent
(
t
,
fs
))
t
result
Just
parent
->
Map
.
alter
(
addGroupedChild
(
t
,
fs
))
parent
result
addGroupedParent
::
(
Text
,
FlowListScores
)
->
Maybe
GroupedWithListScores
->
Maybe
GroupedWithListScores
addGroupedParent
(
_
,
fs
)
Nothing
=
Just
$
GroupedWithListScores
Set
.
empty
list
where
list
=
keyWithMaxValue
$
fs
^.
flc_lists
addGroupedParent
(
t
,
fs
)
(
Just
g
)
=
Just
$
set
gwls_listType
list
$
(
%~
)
gwls_children
(
Set
.
insert
t
)
g
where
list
=
keyWithMaxValue
$
fs
^.
flc_lists
addGroupedChild
::
(
Text
,
FlowListScores
)
->
Maybe
GroupedWithListScores
->
Maybe
GroupedWithListScores
addGroupedChild
(
t
,
fs
)
Nothing
=
Just
$
GroupedWithListScores
(
Set
.
singleton
t
)
list
where
list
=
keyWithMaxValue
$
fs
^.
flc_lists
addGroupedChild
(
t
,
fs
)
(
Just
g
)
=
Just
$
(
%~
)
gwls_listType
(
<>
list
)
$
(
%~
)
gwls_children
(
Set
.
insert
t
)
g
where
list
=
keyWithMaxValue
$
fs
^.
flc_lists
------------------------------------------------------------------------
-- | toFlowListScores which generate Score from list of Map Text
-- NgramsRepoElement
...
...
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