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
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
Christian Merten
haskell-gargantext
Commits
7fef5813
Commit
7fef5813
authored
Oct 29, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT] SocialList clean funs
parent
eef6a43a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
90 deletions
+20
-90
Social.hs
src/Gargantext/Core/Text/List/Social.hs
+12
-3
ListType.hs
src/Gargantext/Core/Text/List/Social/ListType.hs
+8
-87
No files found.
src/Gargantext/Core/Text/List/Social.hs
View file @
7fef5813
...
@@ -83,9 +83,6 @@ flowSocialListByMode listIds nt ngrams' = do
...
@@ -83,9 +83,6 @@ flowSocialListByMode listIds nt ngrams' = do
pure
r
pure
r
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO: maybe use social groups too
-- TODO: maybe use social groups too
-- | TODO what if equality ?
-- | TODO what if equality ?
...
@@ -121,6 +118,18 @@ toSocialList1_testIsTrue = result == (Just MapTerm, Set.singleton token)
...
@@ -121,6 +118,18 @@ toSocialList1_testIsTrue = result == (Just MapTerm, Set.singleton token)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Tools
-- | Tools
------------------------------------------------------------------------
termsByList
::
ListType
->
(
Map
(
Maybe
ListType
)
(
Set
Text
))
->
Set
Text
termsByList
CandidateTerm
m
=
Set
.
unions
$
map
(
\
lt
->
fromMaybe
Set
.
empty
$
Map
.
lookup
lt
m
)
[
Nothing
,
Just
CandidateTerm
]
termsByList
l
m
=
fromMaybe
Set
.
empty
$
Map
.
lookup
(
Just
l
)
m
------------------------------------------------------------------------
unions
::
(
Ord
a
,
Semigroup
a
,
Semigroup
b
,
Ord
b
)
unions
::
(
Ord
a
,
Semigroup
a
,
Semigroup
b
,
Ord
b
)
=>
[
Map
a
(
Set
b
)]
->
Map
a
(
Set
b
)
=>
[
Map
a
(
Set
b
)]
->
Map
a
(
Set
b
)
unions
=
invertBack
.
Map
.
unionsWith
(
<>
)
.
map
invertForw
unions
=
invertBack
.
Map
.
unionsWith
(
<>
)
.
map
invertForw
...
...
src/Gargantext/Core/Text/List/Social/ListType.hs
View file @
7fef5813
...
@@ -35,15 +35,6 @@ import qualified Data.List as List
...
@@ -35,15 +35,6 @@ import qualified Data.List as List
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
------------------------------------------------------------------------
termsByList
::
ListType
->
(
Map
(
Maybe
ListType
)
(
Set
Text
))
->
Set
Text
termsByList
CandidateTerm
m
=
Set
.
unions
$
map
(
\
lt
->
fromMaybe
Set
.
empty
$
Map
.
lookup
lt
m
)
[
Nothing
,
Just
CandidateTerm
]
termsByList
l
m
=
fromMaybe
Set
.
empty
$
Map
.
lookup
(
Just
l
)
m
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | [ListId] does not merge the lists (it is for Master and User lists
-- | [ListId] does not merge the lists (it is for Master and User lists
-- here we need UserList only
-- here we need UserList only
...
@@ -53,16 +44,14 @@ countFilterList :: RepoCmdM env err m
...
@@ -53,16 +44,14 @@ countFilterList :: RepoCmdM env err m
->
m
(
Map
Text
(
Map
ListType
Int
))
->
m
(
Map
Text
(
Map
ListType
Int
))
countFilterList
st
nt
ls
input
=
countFilterList
st
nt
ls
input
=
foldM'
(
\
m
l
->
countFilterList'
st
nt
[
l
]
m
)
input
ls
foldM'
(
\
m
l
->
countFilterList'
st
nt
[
l
]
m
)
input
ls
where
countFilterList'
::
RepoCmdM
env
err
m
countFilterList'
::
RepoCmdM
env
err
m
=>
Set
Text
->
NgramsType
->
[
ListId
]
=>
Set
Text
->
NgramsType
->
[
ListId
]
->
Map
Text
(
Map
ListType
Int
)
->
Map
Text
(
Map
ListType
Int
)
->
m
(
Map
Text
(
Map
ListType
Int
))
->
m
(
Map
Text
(
Map
ListType
Int
))
countFilterList'
st
nt
ls
input
=
do
countFilterList'
st
nt
ls
input
=
do
ml
<-
toMapTextListType
<$>
getListNgrams
ls
nt
ml
<-
toMapTextListType
<$>
getListNgrams
ls
nt
pure
$
Set
.
foldl'
(
\
m
t
->
countList
t
ml
m
)
input
st
-- printDebug "countFilterList'" ml
pure
$
Set
.
foldl'
(
\
m
t
->
countList
t
ml
m
)
input
st
------------------------------------------------------------------------
------------------------------------------------------------------------
-- FIXME children have to herit the ListType of the parent
-- FIXME children have to herit the ListType of the parent
...
@@ -72,74 +61,6 @@ toMapTextListType m = Map.fromListWith (<>)
...
@@ -72,74 +61,6 @@ toMapTextListType m = Map.fromListWith (<>)
$
map
(
toList
m
)
$
map
(
toList
m
)
$
Map
.
toList
m
$
Map
.
toList
m
----------------------
-- | Tools to inherit groupings
----------------------
type
Parent
=
Text
parentUnionsMerge
::
(
Ord
a
,
Ord
b
,
Num
c
)
=>
[
Map
a
(
Map
b
c
)]
->
Map
a
(
Map
b
c
)
parentUnionsMerge
=
Map
.
unionsWith
(
Map
.
unionWith
(
+
))
-- This Parent union is specific
-- [Private, Shared, Public]
-- means the following preferences:
-- Private > Shared > Public
-- if data have not been tagged privately, then use others tags
-- This unions behavior takes first key only and ignore others
parentUnionsExcl
::
Ord
a
=>
[
Map
a
b
]
->
Map
a
b
parentUnionsExcl
=
Map
.
unions
hasParent
::
Text
->
Map
Text
(
Map
Parent
Int
)
->
Maybe
Parent
hasParent
t
m
=
case
Map
.
lookup
t
m
of
Nothing
->
Nothing
Just
m'
->
(
fst
.
fst
)
<$>
Map
.
maxViewWithKey
m'
toMapTextParent
::
Set
Text
->
Map
Text
(
Map
Parent
Int
)
->
[
Map
Text
NgramsRepoElement
]
->
Map
Text
(
Map
Parent
Int
)
toMapTextParent
ts
=
foldl'
(
toMapTextParent'
ts
)
where
toMapTextParent'
::
Set
Text
->
Map
Text
(
Map
Parent
Int
)
->
Map
Text
NgramsRepoElement
->
Map
Text
(
Map
Parent
Int
)
toMapTextParent'
ts'
to
from
=
Set
.
foldl'
(
toMapTextParent''
ts'
from
)
to
ts'
toMapTextParent''
::
Set
Text
->
Map
Text
NgramsRepoElement
->
Map
Text
(
Map
Parent
Int
)
->
Text
->
Map
Text
(
Map
Parent
Int
)
toMapTextParent''
ss
from
to
t
=
case
Map
.
lookup
t
from
of
Nothing
->
to
Just
nre
->
case
_nre_parent
nre
of
Just
(
NgramsTerm
p'
)
->
if
Set
.
member
p'
ss
then
Map
.
alter
(
addParent
p'
)
t
to
else
to
where
addParent
p''
Nothing
=
Just
$
addCountParent
p''
Map
.
empty
addParent
p''
(
Just
ps
)
=
Just
$
addCountParent
p''
ps
addCountParent
::
Parent
->
Map
Parent
Int
->
Map
Parent
Int
addCountParent
p
m
=
Map
.
alter
addCount
p
m
where
addCount
Nothing
=
Just
1
addCount
(
Just
n
)
=
Just
$
n
+
1
_
->
to
------------------------------------------------------------------------
------------------------------------------------------------------------
toList
::
Map
Text
NgramsRepoElement
->
(
Text
,
NgramsRepoElement
)
->
[(
Text
,
ListType
)]
toList
::
Map
Text
NgramsRepoElement
->
(
Text
,
NgramsRepoElement
)
->
[(
Text
,
ListType
)]
toList
m
(
t
,
nre
@
(
NgramsRepoElement
_
_
_
_
(
MSet
children
)))
=
toList
m
(
t
,
nre
@
(
NgramsRepoElement
_
_
_
_
(
MSet
children
)))
=
...
...
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