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
962046fb
Commit
962046fb
authored
Nov 20, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TYPE] FlowCont (Flow Continuation) basic type
parent
b32b1ee0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
74 deletions
+82
-74
List.hs
src/Gargantext/Core/Text/List.hs
+11
-13
Group.hs
src/Gargantext/Core/Text/List/Group.hs
+2
-2
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+15
-4
Social.hs
src/Gargantext/Core/Text/List/Social.hs
+35
-36
Prelude.hs
src/Gargantext/Core/Text/List/Social/Prelude.hs
+11
-11
Scores.hs
src/Gargantext/Core/Text/List/Social/Scores.hs
+8
-8
No files found.
src/Gargantext/Core/Text/List.hs
View file @
962046fb
...
@@ -17,36 +17,34 @@ module Gargantext.Core.Text.List
...
@@ -17,36 +17,34 @@ module Gargantext.Core.Text.List
import
Control.Lens
((
^.
),
set
,
view
,
over
)
import
Control.Lens
((
^.
),
set
,
view
,
over
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
fromMaybe
,
catMaybes
)
import
Data.Maybe
(
fromMaybe
,
catMaybes
)
import
Data.Ord
(
Down
(
..
))
import
Data.Ord
(
Down
(
..
))
import
Data.Map
(
Map
)
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
qualified
Data.Char
as
Char
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
Text
-- import Gargantext.API.Ngrams.Tools (getCoocByNgrams', Diagonal(..))
import
Gargantext.API.Ngrams.Types
(
NgramsElement
,
mkNgramsElement
,
NgramsTerm
(
..
),
RootParent
(
..
),
mSetFromList
)
import
Gargantext.API.Ngrams.Types
(
NgramsElement
,
mkNgramsElement
,
NgramsTerm
(
..
),
RootParent
(
..
),
mSetFromList
)
import
Gargantext.API.Ngrams.Types
(
RepoCmdM
)
import
Gargantext.API.Ngrams.Types
(
RepoCmdM
)
import
Gargantext.Core.Text.List.Social
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Core.Text.List.Group
import
Gargantext.Core.Text.List.Group
import
Gargantext.Core.Text.List.Group.WithStem
import
Gargantext.Core.Text.List.Group.WithStem
import
Gargantext.Core.Text.List.Social
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Core.Text.Metrics
(
scored'
,
Scored
(
..
),
normalizeGlobal
,
normalizeLocal
)
import
Gargantext.Core.Text.Metrics
(
scored'
,
Scored
(
..
),
normalizeGlobal
,
normalizeLocal
)
import
Gargantext.Core.Types
(
ListType
(
..
),
MasterCorpusId
,
UserCorpusId
)
import
Gargantext.Core.Types
(
ListType
(
..
),
MasterCorpusId
,
UserCorpusId
)
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Database.Action.Metrics.NgramsByNode
(
getNodesByNgramsUser
,
getNodesByNgramsOnlyUser
)
import
Gargantext.Database.Action.Metrics.NgramsByNode
(
getNodesByNgramsUser
,
getNodesByNgramsOnlyUser
)
import
Gargantext.Database.Action.Metrics.TFICF
(
getTficf
)
import
Gargantext.Database.Action.Metrics.TFICF
(
getTficf
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Database.Prelude
(
CmdM
)
import
Gargantext.Database.Prelude
(
CmdM
)
import
Gargantext.Database.Query.Table.Node
(
defaultList
)
import
Gargantext.Database.Query.Table.Node
(
defaultList
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
())
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
())
import
Gargantext.Database.Query.Tree.Error
(
HasTreeError
)
import
Gargantext.Database.Query.Tree.Error
(
HasTreeError
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Data.Char
as
Char
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
Text
-- | TODO improve grouping functions of Authors, Sources, Institutes..
-- | TODO improve grouping functions of Authors, Sources, Institutes..
...
@@ -86,8 +84,8 @@ buildNgramsOthersList ::( HasNodeError err
...
@@ -86,8 +84,8 @@ buildNgramsOthersList ::( HasNodeError err
buildNgramsOthersList
user
uCid
groupIt
(
nt
,
MapListSize
mapListSize
)
=
do
buildNgramsOthersList
user
uCid
groupIt
(
nt
,
MapListSize
mapListSize
)
=
do
ngs'
::
Map
Text
(
Set
NodeId
)
<-
getNodesByNgramsUser
uCid
nt
ngs'
::
Map
Text
(
Set
NodeId
)
<-
getNodesByNgramsUser
uCid
nt
socialLists'
::
Flow
ListCont
Text
socialLists'
::
Flow
Cont
Text
FlowListScores
<-
flowSocialList'
MySelfFirst
user
nt
(
Flow
List
Cont
Map
.
empty
$
Set
.
fromList
$
Map
.
keys
ngs'
)
<-
flowSocialList'
MySelfFirst
user
nt
(
FlowCont
Map
.
empty
$
Set
.
fromList
$
Map
.
keys
ngs'
)
-- PrivateFirst for first developments since Public NodeMode is not implemented yet
-- PrivateFirst for first developments since Public NodeMode is not implemented yet
printDebug
"flowSocialList'"
printDebug
"flowSocialList'"
...
...
src/Gargantext/Core/Text/List/Group.hs
View file @
962046fb
...
@@ -41,7 +41,7 @@ toGroupedText groupParams scores =
...
@@ -41,7 +41,7 @@ toGroupedText groupParams scores =
(
groupWithStem
groupParams
)
.
(
groupWithScores
scores
)
(
groupWithStem
groupParams
)
.
(
groupWithScores
scores
)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- |
WIP, put this
in test folder
-- |
TODO put
in test folder
toGroupedText_test
::
Bool
-- Map Stem (GroupedText Int)
toGroupedText_test
::
Bool
-- Map Stem (GroupedText Int)
toGroupedText_test
=
toGroupedText_test
=
-- fromGroupedScores $ fromListScores from
-- fromGroupedScores $ fromListScores from
...
@@ -93,7 +93,7 @@ toGroupedText_test =
...
@@ -93,7 +93,7 @@ toGroupedText_test =
]
]
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | To be removed
-- | T
ODO T
o be removed
addListType
::
Map
Text
ListType
->
GroupedText
a
->
GroupedText
a
addListType
::
Map
Text
ListType
->
GroupedText
a
->
GroupedText
a
addListType
m
g
=
set
gt_listType
(
hasListType
m
g
)
g
addListType
m
g
=
set
gt_listType
(
hasListType
m
g
)
g
where
where
...
...
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
962046fb
...
@@ -80,6 +80,19 @@ groupWithScores scores ms = orphans <> groups
...
@@ -80,6 +80,19 @@ groupWithScores scores ms = orphans <> groups
orphans
=
addIfNotExist
scores
ms
orphans
=
addIfNotExist
scores
ms
{-
groupWithScores :: Map Text FlowListScores
-> Map Text (Set NodeId)
-> Map Text (GroupedTextScores (Set NodeId))
groupWithScores scores ms = orphans <> groups
where
groups = addScore ms
$ fromGroupedScores
$ fromListScores scores
orphans = addIfNotExist scores ms
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
addScore
::
Map
Text
(
Set
NodeId
)
addScore
::
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
...
@@ -108,12 +121,10 @@ addIfNotExist mapSocialScores mapScores =
...
@@ -108,12 +121,10 @@ addIfNotExist mapSocialScores mapScores =
add
_
_
=
Nothing
-- should not be present
add
_
_
=
Nothing
-- should not be present
------------------------------------------------------------------------
------------------------------------------------------------------------
{-
toGroupedTextScores'
::
Map
Parent
GroupedWithListScores
toGroupedTextScores'
::
Map
Parent
GroupedWithListScores
-> Map Text (Set NodeId)
-
- -
> Map Text (Set NodeId)
->
Map
Parent
(
GroupedTextScores'
(
Set
NodeId
))
->
Map
Parent
(
GroupedTextScores'
(
Set
NodeId
))
toGroupedTextScores' par datas = undefined
toGroupedTextScores'
par
=
undefined
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
fromGroupedScores
::
Map
Parent
GroupedWithListScores
fromGroupedScores
::
Map
Parent
GroupedWithListScores
...
...
src/Gargantext/Core/Text/List/Social.hs
View file @
962046fb
...
@@ -62,45 +62,44 @@ flowSocialList' :: ( RepoCmdM env err m
...
@@ -62,45 +62,44 @@ flowSocialList' :: ( RepoCmdM env err m
)
)
=>
FlowSocialListPriority
=>
FlowSocialListPriority
->
User
->
NgramsType
->
User
->
NgramsType
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
->
m
(
Flow
ListCont
Text
)
->
m
(
Flow
Cont
Text
FlowListScores
)
flowSocialList'
flowPriority
user
nt
flc
=
flowSocialList'
flowPriority
user
nt
flc
=
mconcat
<$>
mapM
(
flowSocialListByMode'
user
nt
flc
)
mconcat
<$>
mapM
(
flowSocialListByMode'
user
nt
flc
)
(
flowSocialListPriority
flowPriority
)
(
flowSocialListPriority
flowPriority
)
where
------------------------------------------------------------------------
flowSocialListByMode'
::
(
RepoCmdM
env
err
m
flowSocialListByMode'
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
,
CmdM
env
err
m
,
HasNodeError
err
,
HasNodeError
err
,
HasTreeError
err
,
HasTreeError
err
)
)
=>
User
->
NgramsType
=>
User
->
NgramsType
->
FlowCont
Text
FlowListScores
->
FlowListCont
Text
->
NodeMode
->
NodeMode
->
m
(
FlowCont
Text
FlowListScores
)
->
m
(
FlowListCont
Text
)
flowSocialListByMode'
user'
nt'
flc'
mode
=
flowSocialListByMode'
user
nt
flc
mode
=
findListsId
user'
mode
findListsId
user
mode
>>=
flowSocialListByModeWith
nt'
flc'
>>=
flowSocialListByModeWith
nt
flc
flowSocialListByModeWith
::
(
RepoCmdM
env
err
m
flowSocialListByModeWith
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
,
CmdM
env
err
m
,
HasNodeError
err
,
HasNodeError
err
,
HasTreeError
err
,
HasTreeError
err
)
)
=>
NgramsType
=>
NgramsType
->
FlowCont
Text
FlowListScores
->
FlowListCont
Text
->
[
NodeId
]
->
[
NodeId
]
->
m
(
FlowCont
Text
FlowListScores
)
->
m
(
FlowListCont
Text
)
flowSocialListByModeWith
nt''
flc''
ns
=
flowSocialListByModeWith
nt
flc
ns
=
mapM
(
\
l
->
getListNgrams
[
l
]
nt''
)
ns
mapM
(
\
l
->
getListNgrams
[
l
]
nt
)
ns
>>=
pure
>>=
pure
.
toFlowListScores
(
keepAllParents
nt''
)
flc''
.
toFlowListScores
(
keepAllParents
nt
)
flc
---8<-TODO-REMOVE ALL BELOW--8<--8<-- 8<-- 8<--8<--8<--
---8<-TODO-ALL BELOW--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<-
-- | Choice depends on Ord instance of ListType
-- | Choice depends on Ord instance of ListType
-- for now : data ListType = StopTerm | CandidateTerm | MapTerm
-- for now : data ListType = StopTerm | CandidateTerm | MapTerm
...
...
src/Gargantext/Core/Text/List/Social/Prelude.hs
View file @
962046fb
...
@@ -35,20 +35,20 @@ import qualified Data.Set as Set
...
@@ -35,20 +35,20 @@ import qualified Data.Set as Set
type
Parent
=
Text
type
Parent
=
Text
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | DataType inspired by continuation Monad (but simpler)
-- | DataType inspired by continuation Monad (but simpler)
data
Flow
ListCont
a
=
data
Flow
Cont
a
b
=
Flow
ListCont
{
_flc_scores
::
Map
a
FlowListScores
Flow
Cont
{
_flc_scores
::
Map
a
b
,
_flc_cont
::
Set
a
,
_flc_cont
::
Set
a
}
}
instance
Ord
a
=>
Monoid
(
Flow
ListCont
a
)
where
instance
Ord
a
=>
Monoid
(
Flow
Cont
a
b
)
where
mempty
=
Flow
List
Cont
Map
.
empty
Set
.
empty
mempty
=
FlowCont
Map
.
empty
Set
.
empty
instance
(
Eq
a
,
Ord
a
)
=>
Semigroup
(
Flow
ListCont
a
)
where
instance
(
Eq
a
,
Ord
a
)
=>
Semigroup
(
Flow
Cont
a
b
)
where
(
<>
)
(
Flow
List
Cont
m1
s1
)
(
<>
)
(
FlowCont
m1
s1
)
(
Flow
List
Cont
m2
s2
)
(
FlowCont
m2
s2
)
|
s1
==
Set
.
empty
=
Flow
List
Cont
m
s2
|
s1
==
Set
.
empty
=
FlowCont
m
s2
|
s2
==
Set
.
empty
=
Flow
List
Cont
m
s1
|
s2
==
Set
.
empty
=
FlowCont
m
s1
|
otherwise
=
Flow
List
Cont
m
(
Set
.
intersection
s1
s2
)
|
otherwise
=
FlowCont
m
(
Set
.
intersection
s1
s2
)
where
where
m
=
Map
.
union
m1
m2
m
=
Map
.
union
m1
m2
...
@@ -64,7 +64,7 @@ data FlowListScores =
...
@@ -64,7 +64,7 @@ data FlowListScores =
------------------------------------------------------------------------
------------------------------------------------------------------------
makeLenses
''
F
low
List
Cont
makeLenses
''
F
lowCont
makeLenses
''
F
lowListScores
makeLenses
''
F
lowListScores
-- | Rules to compose 2 datatype FlowListScores
-- | Rules to compose 2 datatype FlowListScores
...
...
src/Gargantext/Core/Text/List/Social/Scores.hs
View file @
962046fb
...
@@ -32,18 +32,18 @@ import qualified Data.Set as Set
...
@@ -32,18 +32,18 @@ import qualified Data.Set as Set
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Generates Score from list of Map Text NgramsRepoElement
-- | Generates Score from list of Map Text NgramsRepoElement
toFlowListScores
::
KeepAllParents
toFlowListScores
::
KeepAllParents
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
->
[
Map
Text
NgramsRepoElement
]
->
[
Map
Text
NgramsRepoElement
]
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
toFlowListScores
k
flc_origin
=
foldl'
(
toFlowListScores_Level1
k
flc_origin
)
mempty
toFlowListScores
k
flc_origin
=
foldl'
(
toFlowListScores_Level1
k
flc_origin
)
mempty
where
where
toFlowListScores_Level1
::
KeepAllParents
toFlowListScores_Level1
::
KeepAllParents
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
->
Map
Text
NgramsRepoElement
->
Map
Text
NgramsRepoElement
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
toFlowListScores_Level1
k'
flc_origin'
flc_dest
ngramsRepo
=
toFlowListScores_Level1
k'
flc_origin'
flc_dest
ngramsRepo
=
Set
.
foldl'
(
toFlowListScores_Level2
k'
ngramsRepo
flc_origin'
)
Set
.
foldl'
(
toFlowListScores_Level2
k'
ngramsRepo
flc_origin'
)
flc_dest
flc_dest
...
@@ -52,10 +52,10 @@ toFlowListScores k flc_origin = foldl' (toFlowListScores_Level1 k flc_origin) me
...
@@ -52,10 +52,10 @@ toFlowListScores k flc_origin = foldl' (toFlowListScores_Level1 k flc_origin) me
toFlowListScores_Level2
::
KeepAllParents
toFlowListScores_Level2
::
KeepAllParents
->
Map
Text
NgramsRepoElement
->
Map
Text
NgramsRepoElement
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
->
Text
->
Text
->
Flow
ListCont
Text
->
Flow
Cont
Text
FlowListScores
toFlowListScores_Level2
k''
ngramsRepo
flc_origin''
flc_dest'
t
=
toFlowListScores_Level2
k''
ngramsRepo
flc_origin''
flc_dest'
t
=
case
Map
.
lookup
t
ngramsRepo
of
case
Map
.
lookup
t
ngramsRepo
of
Nothing
->
over
flc_cont
(
Set
.
insert
t
)
flc_dest'
Nothing
->
over
flc_cont
(
Set
.
insert
t
)
flc_dest'
...
...
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