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
4a5e83c1
Commit
4a5e83c1
authored
Nov 09, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Social Lists : option for PrivateFirst or OthersFirst
parent
c4e94103
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
34 deletions
+63
-34
Group.hs
src/Gargantext/Core/Text/Group.hs
+0
-3
List.hs
src/Gargantext/Core/Text/List.hs
+18
-10
Social.hs
src/Gargantext/Core/Text/List/Social.hs
+38
-3
Find.hs
src/Gargantext/Core/Text/List/Social/Find.hs
+2
-3
Group.hs
src/Gargantext/Core/Text/List/Social/Group.hs
+5
-15
No files found.
src/Gargantext/Core/Text/Group.hs
View file @
4a5e83c1
...
...
@@ -99,9 +99,6 @@ toGroupedText fun_stem fun_score fun_texts fun_nodeIds from = groupStems' $ map
(
fun_nodeIds
d
)
)
groupStems
::
[(
Stem
,
GroupedText
Double
)]
->
[
GroupedText
Double
]
groupStems
=
Map
.
elems
.
groupStems'
groupStems'
::
Ord
a
=>
[(
Stem
,
GroupedText
a
)]
->
Map
Stem
(
GroupedText
a
)
groupStems'
=
Map
.
fromListWith
grouping
where
...
...
src/Gargantext/Core/Text/List.hs
View file @
4a5e83c1
...
...
@@ -81,24 +81,32 @@ buildNgramsOthersList ::( HasNodeError err
buildNgramsOthersList
user
uCid
groupIt
(
nt
,
MapListSize
mapListSize
)
=
do
ngs
<-
groupNodesByNgramsWith
groupIt
<$>
getNodesByNgramsUser
uCid
nt
let
let
grouped
=
toGroupedText
groupIt
(
Set
.
size
.
snd
)
fst
snd
(
Map
.
toList
$
Map
.
mapWithKey
(
\
k
(
a
,
b
)
->
(
Set
.
delete
k
a
,
b
))
$
ngs
)
$
Map
.
toList
$
Map
.
mapWithKey
(
\
k
(
a
,
b
)
->
(
Set
.
delete
k
a
,
b
))
$
ngs
socialLists
<-
flowSocialList
user
nt
(
Set
.
fromList
$
Map
.
keys
ngs
)
let
groupedWithList
=
map
(
addListType
(
invertForw
socialLists
))
grouped
(
stopTerms
,
tailTerms
)
=
Map
.
partition
(
\
t
->
t
^.
gt_listType
==
Just
StopTerm
)
groupedWithList
(
mapTerms
,
tailTerms'
)
=
Map
.
partition
(
\
t
->
t
^.
gt_listType
==
Just
MapTerm
)
tailTerms
(
stopTerms
,
tailTerms
)
=
Map
.
partition
(
\
t
->
t
^.
gt_listType
==
Just
StopTerm
)
groupedWithList
(
mapTerms
,
tailTerms'
)
=
Map
.
partition
(
\
t
->
t
^.
gt_listType
==
Just
MapTerm
)
tailTerms
listSize
=
mapListSize
-
(
List
.
length
mapTerms
)
(
mapTerms'
,
candiTerms
)
=
List
.
splitAt
listSize
$
List
.
sortOn
(
Down
.
_gt_score
)
$
Map
.
elems
tailTerms'
pure
$
Map
.
fromList
[(
nt
,
(
List
.
concat
$
map
toNgramsElement
stopTerms
)
<>
(
List
.
concat
$
map
toNgramsElement
mapTerms
)
<>
(
List
.
concat
$
map
toNgramsElement
$
map
(
set
gt_listType
(
Just
MapTerm
))
mapTerms'
)
<>
(
List
.
concat
$
map
toNgramsElement
$
map
(
set
gt_listType
(
Just
CandidateTerm
))
candiTerms
)
(
mapTerms'
,
candiTerms
)
=
List
.
splitAt
listSize
$
List
.
sortOn
(
Down
.
_gt_score
)
$
Map
.
elems
tailTerms'
pure
$
Map
.
fromList
[(
nt
,
(
List
.
concat
$
map
toNgramsElement
stopTerms
)
<>
(
List
.
concat
$
map
toNgramsElement
mapTerms
)
<>
(
List
.
concat
$
map
toNgramsElement
$
map
(
set
gt_listType
(
Just
MapTerm
))
mapTerms'
)
<>
(
List
.
concat
$
map
toNgramsElement
$
map
(
set
gt_listType
(
Just
CandidateTerm
))
candiTerms
)
)]
-- TODO use ListIds
...
...
src/Gargantext/Core/Text/List/Social.hs
View file @
4a5e83c1
...
...
@@ -42,11 +42,11 @@ flowSocialList :: ( RepoCmdM env err m
->
m
(
Map
ListType
(
Set
Text
))
flowSocialList
user
nt
ngrams'
=
do
-- Here preference to privateLists (discutable: let user choice)
privateListIds
<-
findListsId
Private
user
privateListIds
<-
findListsId
user
Private
privateLists
<-
flowSocialListByMode
privateListIds
nt
ngrams'
-- printDebug "* privateLists *: \n" privateLists
sharedListIds
<-
findListsId
Shared
user
sharedListIds
<-
findListsId
user
Shared
sharedLists
<-
flowSocialListByMode
sharedListIds
nt
(
termsByList
CandidateTerm
privateLists
)
-- printDebug "* sharedLists *: \n" sharedLists
...
...
@@ -63,6 +63,29 @@ flowSocialList user nt ngrams' = do
-- printDebug "* socialLists *: results \n" result
pure
result
------------------------------------------------------------------------
-- | FlowSocialListPriority
-- Sociological assumption: either private or others (public) first
-- This parameter depends on the user choice
data
FlowSocialListPriority
=
PrivateFirst
|
OthersFirst
flowSocialListPriority
::
FlowSocialListPriority
->
[
NodeMode
]
flowSocialListPriority
PrivateFirst
=
[
Private
,
Shared
{-, Public -}
]
flowSocialListPriority
OthersFirst
=
reverse
$
flowSocialListPriority
PrivateFirst
flowSocialList'
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
,
HasNodeError
err
,
HasTreeError
err
)
=>
FlowSocialListPriority
->
User
->
NgramsType
->
Set
Text
->
m
(
Map
Text
FlowListScores
)
flowSocialList'
flowPriority
user
nt
ngrams'
=
parentUnionsExcl
<$>
mapM
(
\
m
->
flowSocialListByMode'
user
m
nt
ngrams'
)
(
flowSocialListPriority
flowPriority
)
------------------------------------------------------------------------
flowSocialListByMode
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
...
...
@@ -83,9 +106,21 @@ flowSocialListByMode' :: ( RepoCmdM env err m
,
HasNodeError
err
,
HasTreeError
err
)
=>
User
->
NodeMode
->
NgramsType
->
Set
Text
->
m
(
Map
Text
FlowListScores
)
flowSocialListByMode'
user
mode
nt
st
=
do
listIds
<-
findListsId
user
mode
flowSocialListByModeWith
listIds
nt
st
flowSocialListByModeWith
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
,
HasNodeError
err
,
HasTreeError
err
)
=>
[
NodeId
]
->
NgramsType
->
Set
Text
->
m
(
Map
Text
FlowListScores
)
flowSocialListByMode
'
ns
nt
st
=
do
flowSocialListByMode
With
ns
nt
st
=
do
ngramsRepos
<-
mapM
(
\
l
->
getListNgrams
[
l
]
nt
)
ns
pure
$
toFlowListScores
(
keepAllParents
nt
)
st
Map
.
empty
ngramsRepos
...
...
src/Gargantext/Core/Text/List/Social/Find.hs
View file @
4a5e83c1
...
...
@@ -23,12 +23,11 @@ import Gargantext.Prelude
------------------------------------------------------------------------
findListsId
::
(
HasNodeError
err
,
HasTreeError
err
)
=>
NodeMode
->
User
->
Cmd
err
[
NodeId
]
findListsId
mode
u
=
do
=>
User
->
NodeMode
->
Cmd
err
[
NodeId
]
findListsId
u
mode
=
do
r
<-
getRootId
u
ns
<-
map
_dt_nodeId
<$>
filter
(
\
n
->
_dt_typeId
n
==
nodeTypeId
NodeList
)
<$>
findNodes'
mode
r
-- printDebug "findListsIds" ns
pure
ns
...
...
src/Gargantext/Core/Text/List/Social/Group.hs
View file @
4a5e83c1
...
...
@@ -80,12 +80,11 @@ instance Semigroup FlowListScores where
------------------------------------------------------------------------
-- | toFlowListScores which generate Score from list of Map Text
-- NgramsRepoElement
toFlowListScores
::
KeepAllParents
->
Set
Text
->
Map
Text
FlowListScores
->
[
Map
Text
NgramsRepoElement
]
->
Map
Text
FlowListScores
->
Set
Text
->
Map
Text
FlowListScores
->
[
Map
Text
NgramsRepoElement
]
->
Map
Text
FlowListScores
toFlowListScores
k
ts
=
foldl'
(
toFlowListScores'
k
ts
)
where
toFlowListScores'
::
KeepAllParents
...
...
@@ -123,16 +122,7 @@ addList l (Just (FlowListScores mapParent mapList)) =
where
mapList'
=
addList'
l
mapList
-- * Unseful but nice comment:
-- "the addList function looks like an ASCII bird in a blue sky"
-- _
-- ___| | ___ _
-- / __| |/ / | | |
-- \__ \ <| |_| |
-- |___/_|\_\\__, |
-- |___/
--
--
--
-- "the addList function looks like an ASCII bird"
-- | Concrete function to pass to PatchMap
addList'
::
ListType
->
Map
ListType
Int
->
Map
ListType
Int
...
...
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