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
159
Issues
159
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
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
093afa75
Commit
093afa75
authored
Nov 02, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] SocialList refactor, Type ListType Ord fixed
parent
c3a9237b
Pipeline
#1184
failed with stage
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
57 deletions
+44
-57
List.hs
src/Gargantext/Core/Text/List.hs
+1
-1
Social.hs
src/Gargantext/Core/Text/List/Social.hs
+17
-7
Find.hs
src/Gargantext/Core/Text/List/Social/Find.hs
+0
-14
Group.hs
src/Gargantext/Core/Text/List/Social/Group.hs
+10
-12
ListType.hs
src/Gargantext/Core/Text/List/Social/ListType.hs
+10
-21
Main.hs
src/Gargantext/Core/Types/Main.hs
+6
-2
No files found.
src/Gargantext/Core/Text/List.hs
View file @
093afa75
...
@@ -129,7 +129,7 @@ buildNgramsTermsList user uCid mCid groupParams = do
...
@@ -129,7 +129,7 @@ buildNgramsTermsList user uCid mCid groupParams = do
printDebug
"
\n
* socialLists *
\n
"
socialLists
printDebug
"
\n
* socialLists *
\n
"
socialLists
let
let
socialStop
=
fromMaybe
Set
.
empty
$
Map
.
lookup
StopTerm
socialLists
_socialStop
=
fromMaybe
Set
.
empty
$
Map
.
lookup
StopTerm
socialLists
_socialMap
=
fromMaybe
Set
.
empty
$
Map
.
lookup
MapTerm
socialLists
_socialMap
=
fromMaybe
Set
.
empty
$
Map
.
lookup
MapTerm
socialLists
_socialCand
=
fromMaybe
Set
.
empty
$
Map
.
lookup
CandidateTerm
socialLists
_socialCand
=
fromMaybe
Set
.
empty
$
Map
.
lookup
CandidateTerm
socialLists
-- stopTerms ignored for now (need to be tagged already)
-- stopTerms ignored for now (need to be tagged already)
...
...
src/Gargantext/Core/Text/List/Social.hs
View file @
093afa75
...
@@ -20,6 +20,7 @@ import Gargantext.API.Ngrams.Tools -- (getListNgrams)
...
@@ -20,6 +20,7 @@ import Gargantext.API.Ngrams.Tools -- (getListNgrams)
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Text.List.Social.Find
import
Gargantext.Core.Text.List.Social.Find
import
Gargantext.Core.Text.List.Social.ListType
import
Gargantext.Core.Text.List.Social.ListType
import
Gargantext.Core.Text.List.Social.Group
import
Gargantext.Core.Types.Individu
import
Gargantext.Core.Types.Individu
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Main
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
...
@@ -54,10 +55,11 @@ flowSocialList user nt ngrams' = do
...
@@ -54,10 +55,11 @@ flowSocialList user nt ngrams' = do
-- publicListIds <- findListsId Public user
-- publicListIds <- findListsId Public user
-- publicLists <- flowSocialListByMode' publicListIds nt (termsByList CandidateTerm privateLists)
-- publicLists <- flowSocialListByMode' publicListIds nt (termsByList CandidateTerm privateLists)
let
result
=
unions
[
Map
.
mapKeys
(
fromMaybe
CandidateTerm
)
privateLists
let
result
=
parentUnionsExcl
,
Map
.
mapKeys
(
fromMaybe
CandidateTerm
)
sharedLists
[
Map
.
mapKeys
(
fromMaybe
CandidateTerm
)
privateLists
-- , Map.mapKeys (fromMaybe CandidateTerm) publicLists
,
Map
.
mapKeys
(
fromMaybe
CandidateTerm
)
sharedLists
]
-- , Map.mapKeys (fromMaybe CandidateTerm) publicLists
]
-- printDebug "* socialLists *: results \n" result
-- printDebug "* socialLists *: results \n" result
pure
result
pure
result
...
@@ -76,6 +78,17 @@ flowSocialListByMode listIds nt ngrams' = do
...
@@ -76,6 +78,17 @@ flowSocialListByMode listIds nt ngrams' = do
pure
r
pure
r
flowSocialListByMode'
::
(
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
ngramsRepos
<-
mapM
(
\
l
->
getListNgrams
[
l
]
nt
)
ns
pure
$
toFlowListScores
st
Map
.
empty
ngramsRepos
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO: maybe use social groups too
-- TODO: maybe use social groups too
-- | TODO what if equality ?
-- | TODO what if equality ?
...
@@ -111,7 +124,6 @@ toSocialList1_testIsTrue = result == (Just MapTerm, Set.singleton token)
...
@@ -111,7 +124,6 @@ toSocialList1_testIsTrue = result == (Just MapTerm, Set.singleton token)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Tools
-- | Tools
------------------------------------------------------------------------
------------------------------------------------------------------------
termsByList
::
ListType
->
(
Map
(
Maybe
ListType
)
(
Set
Text
))
->
Set
Text
termsByList
::
ListType
->
(
Map
(
Maybe
ListType
)
(
Set
Text
))
->
Set
Text
termsByList
CandidateTerm
m
=
Set
.
unions
termsByList
CandidateTerm
m
=
Set
.
unions
...
@@ -121,8 +133,6 @@ termsByList l m =
...
@@ -121,8 +133,6 @@ termsByList l m =
fromMaybe
Set
.
empty
$
Map
.
lookup
(
Just
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/Find.hs
View file @
093afa75
...
@@ -21,20 +21,6 @@ import Gargantext.Database.Query.Tree
...
@@ -21,20 +21,6 @@ import Gargantext.Database.Query.Tree
import
Gargantext.Database.Query.Tree.Root
(
getRootId
)
import
Gargantext.Database.Query.Tree.Root
(
getRootId
)
import
Gargantext.Prelude
import
Gargantext.Prelude
-- filterList imports
import
Data.Maybe
(
fromMaybe
)
import
Data.Map
(
Map
)
import
Data.Set
(
Set
)
import
Data.Semigroup
(
Semigroup
(
..
))
import
Data.Text
(
Text
)
import
Gargantext.API.Ngrams.Tools
-- (getListNgrams)
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Types.Main
import
Gargantext.Database.Schema.Ngrams
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
------------------------------------------------------------------------
------------------------------------------------------------------------
findListsId
::
(
HasNodeError
err
,
HasTreeError
err
)
findListsId
::
(
HasNodeError
err
,
HasTreeError
err
)
=>
NodeMode
->
User
->
Cmd
err
[
NodeId
]
=>
NodeMode
->
User
->
Cmd
err
[
NodeId
]
...
...
src/Gargantext/Core/Text/List/Social/Group.hs
View file @
093afa75
...
@@ -20,18 +20,12 @@ module Gargantext.Core.Text.List.Social.Group
...
@@ -20,18 +20,12 @@ module Gargantext.Core.Text.List.Social.Group
import
Control.Lens
import
Control.Lens
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Semigroup
(
Semigroup
(
..
))
import
Data.Semigroup
(
Semigroup
(
..
))
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Types.Individu
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Main
import
Gargantext.Database.Admin.Config
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
...
@@ -58,7 +52,6 @@ parentUnionsExcl :: Ord a
...
@@ -58,7 +52,6 @@ parentUnionsExcl :: Ord a
parentUnionsExcl
=
Map
.
unions
parentUnionsExcl
=
Map
.
unions
------------------------------------------------------------------------
------------------------------------------------------------------------
type
Parent
=
Text
type
Parent
=
Text
hasParent
::
Text
hasParent
::
Text
...
@@ -68,8 +61,8 @@ hasParent t m = case Map.lookup t m of
...
@@ -68,8 +61,8 @@ hasParent t m = case Map.lookup t m of
Nothing
->
Nothing
Nothing
->
Nothing
Just
m'
->
(
fst
.
fst
)
<$>
Map
.
maxViewWithKey
m'
Just
m'
->
(
fst
.
fst
)
<$>
Map
.
maxViewWithKey
m'
------------------------------------------------------------------------
------------------------------------------------------------------------
data
FlowListScores
=
data
FlowListScores
=
FlowListScores
{
_flc_parents
::
Map
Parent
Int
FlowListScores
{
_flc_parents
::
Map
Parent
Int
,
_flc_lists
::
Map
ListType
Int
,
_flc_lists
::
Map
ListType
Int
...
@@ -80,13 +73,18 @@ data FlowListScores =
...
@@ -80,13 +73,18 @@ data FlowListScores =
makeLenses
''
F
lowListScores
makeLenses
''
F
lowListScores
instance
Semigroup
FlowListScores
where
(
<>
)
(
FlowListScores
p1
l1
)
(
FlowListScores
p2
l2
)
=
FlowListScores
(
p1
<>
p2
)
(
l1
<>
l2
)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | toFlowListScores which generate Score from list of Map Text NgramsRepoElement
-- | toFlowListScores which generate Score from list of Map Text
-- NgramsRepoElement
toFlowListScores
::
Set
Text
toFlowListScores
::
Set
Text
->
Map
Text
FlowListScores
->
Map
Text
FlowListScores
->
[
Map
Text
NgramsRepoElement
]
->
[
Map
Text
NgramsRepoElement
]
->
Map
Text
FlowListScores
->
Map
Text
FlowListScores
toFlowListScores
ts
=
foldl'
(
toFlowListScores'
ts
)
toFlowListScores
ts
=
foldl'
(
toFlowListScores'
ts
)
where
where
toFlowListScores'
::
Set
Text
toFlowListScores'
::
Set
Text
...
@@ -111,7 +109,7 @@ toFlowListScores ts = foldl' (toFlowListScores' ts)
...
@@ -111,7 +109,7 @@ toFlowListScores ts = foldl' (toFlowListScores' ts)
-- | Main addFunctions to FlowListScores
-- | Main addFunctions to FlowListScores
------------------------------------------------------------------------
------------------------------------------------------------------------
-- |
Very u
nseful but nice comment:
-- |
U
nseful but nice comment:
-- "this function looks like an ASCII bird"
-- "this function looks like an ASCII bird"
addList
::
ListType
addList
::
ListType
->
Maybe
FlowListScores
->
Maybe
FlowListScores
...
...
src/Gargantext/Core/Text/List/Social/ListType.hs
View file @
093afa75
...
@@ -11,22 +11,11 @@ Portability : POSIX
...
@@ -11,22 +11,11 @@ Portability : POSIX
module
Gargantext.Core.Text.List.Social.ListType
module
Gargantext.Core.Text.List.Social.ListType
where
where
-- findList imports
import
Gargantext.Core.Types.Individu
import
Gargantext.Database.Admin.Config
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Query.Tree
import
Gargantext.Database.Query.Tree.Root
(
getRootId
)
import
Gargantext.Prelude
-- filterList imports
import
Data.Maybe
(
fromMaybe
)
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
Data.Semigroup
(
Semigroup
(
..
))
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Gargantext.Prelude
import
Gargantext.API.Ngrams.Tools
-- (getListNgrams)
import
Gargantext.API.Ngrams.Tools
-- (getListNgrams)
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Main
...
@@ -49,9 +38,9 @@ countFilterList st nt ls input =
...
@@ -49,9 +38,9 @@ countFilterList st nt ls input =
=>
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
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
...
@@ -62,20 +51,20 @@ toMapTextListType m = Map.fromListWith (<>)
...
@@ -62,20 +51,20 @@ toMapTextListType m = Map.fromListWith (<>)
$
Map
.
toList
m
$
Map
.
toList
m
where
where
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
)))
=
List
.
zip
terms
(
List
.
cycle
[
lt'
])
List
.
zip
terms
(
List
.
cycle
[
lt'
])
where
where
terms
=
[
t
]
terms
=
[
t
]
-- <> maybe [] (\n -> [unNgramsTerm n]) root
-- <> maybe [] (\n -> [unNgramsTerm n]) root
-- <> maybe [] (\n -> [unNgramsTerm n]) parent
-- <> maybe [] (\n -> [unNgramsTerm n]) parent
<>
(
map
unNgramsTerm
$
Map
.
keys
children
)
<>
(
map
unNgramsTerm
$
Map
.
keys
children
)
lt'
=
listOf
m
nre
lt'
=
listOf
m
'
nre
listOf
::
Map
Text
NgramsRepoElement
->
NgramsRepoElement
->
ListType
listOf
::
Map
Text
NgramsRepoElement
->
NgramsRepoElement
->
ListType
listOf
m
ng
=
case
_nre_parent
ng
of
listOf
m
''
ng
=
case
_nre_parent
ng
of
Nothing
->
_nre_list
ng
Nothing
->
_nre_list
ng
Just
p
->
case
Map
.
lookup
(
unNgramsTerm
p
)
m
of
Just
p
->
case
Map
.
lookup
(
unNgramsTerm
p
)
m
''
of
Just
ng'
->
listOf
m
ng'
Just
ng'
->
listOf
m
''
ng'
Nothing
->
CandidateTerm
Nothing
->
CandidateTerm
-- panic "[G.C.T.L.Social.listOf] Nothing: Should Not happen"
-- panic "[G.C.T.L.Social.listOf] Nothing: Should Not happen"
...
@@ -93,7 +82,7 @@ countList t m input = case Map.lookup t m of
...
@@ -93,7 +82,7 @@ countList t m input = case Map.lookup t m of
addList
(
Just
lm
)
=
Just
$
addCountList
l
lm
addList
(
Just
lm
)
=
Just
$
addCountList
l
lm
addCountList
::
ListType
->
Map
ListType
Int
->
Map
ListType
Int
addCountList
::
ListType
->
Map
ListType
Int
->
Map
ListType
Int
addCountList
l
m
=
Map
.
alter
(
plus
l
)
l
m
addCountList
l
'
m'
=
Map
.
alter
(
plus
l'
)
l'
m'
where
where
plus
CandidateTerm
Nothing
=
Just
1
plus
CandidateTerm
Nothing
=
Just
1
plus
CandidateTerm
(
Just
x
)
=
Just
$
x
+
1
plus
CandidateTerm
(
Just
x
)
=
Just
$
x
+
1
...
...
src/Gargantext/Core/Types/Main.hs
View file @
093afa75
...
@@ -50,7 +50,7 @@ instance ToSchema NodeTree where
...
@@ -50,7 +50,7 @@ instance ToSchema NodeTree where
type
TypeId
=
Int
type
TypeId
=
Int
-- TODO multiple ListType declaration, remove it
-- TODO multiple ListType declaration, remove it
-- data ListType = CandidateTerm | StopTerm | MapTerm
-- data ListType = CandidateTerm | StopTerm | MapTerm
data
ListType
=
StopTerm
|
Candidate
Term
|
MapTerm
data
ListType
=
CandidateTerm
|
Stop
Term
|
MapTerm
deriving
(
Generic
,
Eq
,
Ord
,
Show
,
Read
,
Enum
,
Bounded
)
deriving
(
Generic
,
Eq
,
Ord
,
Show
,
Read
,
Enum
,
Bounded
)
instance
ToJSON
ListType
instance
ToJSON
ListType
...
@@ -81,7 +81,11 @@ listTypeId CandidateTerm = 1
...
@@ -81,7 +81,11 @@ listTypeId CandidateTerm = 1
listTypeId
MapTerm
=
2
listTypeId
MapTerm
=
2
fromListTypeId
::
ListTypeId
->
Maybe
ListType
fromListTypeId
::
ListTypeId
->
Maybe
ListType
fromListTypeId
i
=
lookup
i
$
fromList
[
(
listTypeId
l
,
l
)
|
l
<-
[
minBound
..
maxBound
]]
fromListTypeId
i
=
lookup
i
$
fromList
[
(
listTypeId
l
,
l
)
|
l
<-
[
StopTerm
,
CandidateTerm
,
MapTerm
]
]
-- data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
-- data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
-- | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
-- | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
...
...
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