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
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
83403098
Commit
83403098
authored
Nov 28, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CLEAN] renaming unexplicit fun
parent
bfdd7490
Pipeline
#1255
failed with stage
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
147 deletions
+51
-147
Metrics.hs
src/Gargantext/API/Metrics.hs
+4
-4
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+2
-1
NgramsTree.hs
src/Gargantext/API/Ngrams/NgramsTree.hs
+15
-14
Social.hs
src/Gargantext/Core/Text/List/Social.hs
+1
-5
ListType.hs
src/Gargantext/Core/Text/List/Social/ListType.hs
+0
-95
Scores.hs
src/Gargantext/Core/Text/List/Social/Scores.hs
+24
-23
Chart.hs
src/Gargantext/Core/Viz/Chart.hs
+2
-2
List.hs
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
+3
-3
No files found.
src/Gargantext/API/Metrics.hs
View file @
83403098
...
...
@@ -25,7 +25,7 @@ import Data.Time (UTCTime)
import
Servant
import
Gargantext.API.HashedResponse
import
Gargantext.API.Ngrams.NTree
import
Gargantext.API.Ngrams.N
grams
Tree
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Prelude
(
GargServer
)
import
Gargantext.Core.Types
(
CorpusId
,
Limit
,
ListId
,
ListType
(
..
))
...
...
@@ -317,7 +317,7 @@ type TreeApi = Summary " Tree API"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"listType"
ListType
:>
Get
'[
J
SON
]
(
HashedResponse
(
ChartMetrics
[
My
Tree
]))
:>
Get
'[
J
SON
]
(
HashedResponse
(
ChartMetrics
[
Ngrams
Tree
]))
:<|>
Summary
"Tree Chart update"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
...
...
@@ -347,7 +347,7 @@ getTree :: FlowCmdM env err m
->
Maybe
ListId
->
TabType
->
ListType
->
m
(
HashedResponse
(
ChartMetrics
[
My
Tree
]))
->
m
(
HashedResponse
(
ChartMetrics
[
Ngrams
Tree
]))
getTree
cId
_start
_end
maybeListId
tabType
listType
=
do
listId
<-
case
maybeListId
of
Just
lid
->
pure
lid
...
...
@@ -383,7 +383,7 @@ updateTree' :: FlowCmdM env err m =>
->
Maybe
ListId
->
TabType
->
ListType
->
m
(
ChartMetrics
[
My
Tree
])
->
m
(
ChartMetrics
[
Ngrams
Tree
])
updateTree'
cId
maybeListId
tabType
listType
=
do
listId
<-
case
maybeListId
of
Just
lid
->
pure
lid
...
...
src/Gargantext/API/Ngrams.hs
View file @
83403098
{-# OPTIONS_GHC -fno-warn-unused-top-binds #-}
{-|
Module : Gargantext.API.Ngrams
Description : Server API
...
...
@@ -16,6 +15,8 @@ add get
-}
{-# OPTIONS_GHC -fno-warn-unused-top-binds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
...
...
src/Gargantext/API/Ngrams/NTree.hs
→
src/Gargantext/API/Ngrams/N
grams
Tree.hs
View file @
83403098
{-|
Module : Gargantext.API.Ngrams.NTree
Module : Gargantext.API.Ngrams.N
grams
Tree
Description : Tree of Ngrams
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
...
...
@@ -11,7 +11,7 @@ Portability : POSIX
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.API.Ngrams.NTree
module
Gargantext.API.Ngrams.N
grams
Tree
where
import
Data.Aeson.TH
(
deriveJSON
)
...
...
@@ -36,24 +36,25 @@ import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger)
type
Children
=
Text
type
Root
=
Text
data
MyTree
=
MyTree
{
mt_label
::
Text
,
mt_value
::
Double
,
mt_children
::
[
MyTree
]
}
deriving
(
Generic
,
Show
)
data
NgramsTree
=
NgramsTree
{
mt_label
::
Text
,
mt_value
::
Double
,
mt_children
::
[
NgramsTree
]
}
deriving
(
Generic
,
Show
)
to
MyTree
::
Tree
(
Text
,
Double
)
->
My
Tree
to
MyTree
(
Node
(
l
,
v
)
xs
)
=
MyTree
l
v
(
map
toMy
Tree
xs
)
to
NgramsTree
::
Tree
(
Text
,
Double
)
->
Ngrams
Tree
to
NgramsTree
(
Node
(
l
,
v
)
xs
)
=
NgramsTree
l
v
(
map
toNgrams
Tree
xs
)
deriveJSON
(
unPrefix
"mt_"
)
''
M
y
Tree
deriveJSON
(
unPrefix
"mt_"
)
''
N
grams
Tree
instance
ToSchema
My
Tree
where
instance
ToSchema
Ngrams
Tree
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"mt_"
)
instance
Arbitrary
My
Tree
instance
Arbitrary
Ngrams
Tree
where
arbitrary
=
My
Tree
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
arbitrary
=
Ngrams
Tree
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
toTree
::
ListType
->
Map
Text
(
Set
NodeId
)
->
Map
Text
NgramsRepoElement
->
[
My
Tree
]
toTree
lt
vs
m
=
map
to
My
Tree
$
unfoldForest
buildNode
roots
toTree
::
ListType
->
Map
Text
(
Set
NodeId
)
->
Map
Text
NgramsRepoElement
->
[
Ngrams
Tree
]
toTree
lt
vs
m
=
map
to
Ngrams
Tree
$
unfoldForest
buildNode
roots
where
buildNode
r
=
maybe
((
r
,
value
r
),
[]
)
(
\
x
->
((
r
,
value
r
),
unNgramsTerm
<$>
(
mSetToList
$
_nre_children
x
)))
...
...
src/Gargantext/Core/Text/List/Social.hs
View file @
83403098
...
...
@@ -13,7 +13,7 @@ module Gargantext.Core.Text.List.Social
import
Data.Monoid
(
mconcat
)
import
Data.Text
(
Text
)
import
Gargantext.API.Ngrams.Tools
-- (getListNgrams)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Text.List.Social.Find
import
Gargantext.Core.Text.List.Social.Prelude
...
...
@@ -26,7 +26,6 @@ import Gargantext.Database.Query.Tree
import
Gargantext.Database.Schema.Ngrams
import
Gargantext.Prelude
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Main parameters
...
...
@@ -46,7 +45,6 @@ keepAllParents :: NgramsType -> KeepAllParents
keepAllParents
NgramsTerms
=
KeepAllParents
False
keepAllParents
_
=
KeepAllParents
True
------------------------------------------------------------------------
flowSocialList'
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
...
...
@@ -89,5 +87,3 @@ flowSocialList' flowPriority user nt flc =
mapM
(
\
l
->
getListNgrams
[
l
]
nt''
)
ns
>>=
pure
.
toFlowListScores
(
keepAllParents
nt''
)
flc''
src/Gargantext/Core/Text/List/Social/ListType.hs
deleted
100644 → 0
View file @
bfdd7490
{-|
Module : Gargantext.Core.Text.List.Social.ListType
Description :
Copyright : (c) CNRS, 2018-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
module
Gargantext.Core.Text.List.Social.ListType
where
import
Gargantext.Database.Admin.Types.Node
import
Data.Map
(
Map
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
)
import
Gargantext.Prelude
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
------------------------------------------------------------------------
-- | [ListId] does not merge the lists (it is for Master and User lists
-- here we need UserList only
countFilterList
::
RepoCmdM
env
err
m
=>
Set
Text
->
NgramsType
->
[
ListId
]
->
Map
Text
(
Map
ListType
Int
)
->
m
(
Map
Text
(
Map
ListType
Int
))
countFilterList
st
nt
ls
input
=
foldM'
(
\
m
l
->
countFilterList'
st
nt
[
l
]
m
)
input
ls
where
countFilterList'
::
RepoCmdM
env
err
m
=>
Set
Text
->
NgramsType
->
[
ListId
]
->
Map
Text
(
Map
ListType
Int
)
->
m
(
Map
Text
(
Map
ListType
Int
))
countFilterList'
st'
nt'
ls'
input'
=
do
ml
<-
toMapTextListType
<$>
getListNgrams
ls'
nt'
pure
$
Set
.
foldl'
(
\
m
t
->
countList
t
ml
m
)
input'
st'
------------------------------------------------------------------------
-- FIXME children have to herit the ListType of the parent
toMapTextListType
::
Map
Text
NgramsRepoElement
->
Map
Text
ListType
toMapTextListType
m
=
Map
.
fromListWith
(
<>
)
$
List
.
concat
$
map
(
toList
m
)
$
Map
.
toList
m
where
toList
::
Map
Text
NgramsRepoElement
->
(
Text
,
NgramsRepoElement
)
->
[(
Text
,
ListType
)]
toList
m'
(
t
,
nre
@
(
NgramsRepoElement
_
_
_
_
(
MSet
children
)))
=
List
.
zip
terms
(
List
.
cycle
[
lt'
])
where
terms
=
[
t
]
-- <> maybe [] (\n -> [unNgramsTerm n]) root
-- <> maybe [] (\n -> [unNgramsTerm n]) parent
<>
(
map
unNgramsTerm
$
Map
.
keys
children
)
lt'
=
listOf
m'
nre
listOf
::
Map
Text
NgramsRepoElement
->
NgramsRepoElement
->
ListType
listOf
m''
ng
=
case
_nre_parent
ng
of
Nothing
->
_nre_list
ng
Just
p
->
case
Map
.
lookup
(
unNgramsTerm
p
)
m''
of
Just
ng'
->
listOf
m''
ng'
Nothing
->
CandidateTerm
-- panic "[G.C.T.L.Social.listOf] Nothing: Should Not happen"
------------------------------------------------------------------------
countList
::
Text
->
Map
Text
ListType
->
Map
Text
(
Map
ListType
Int
)
->
Map
Text
(
Map
ListType
Int
)
countList
t
m
input
=
case
Map
.
lookup
t
m
of
Nothing
->
input
Just
l
->
Map
.
alter
addList
t
input
where
addList
Nothing
=
Just
$
addCountList
l
Map
.
empty
addList
(
Just
lm
)
=
Just
$
addCountList
l
lm
addCountList
::
ListType
->
Map
ListType
Int
->
Map
ListType
Int
addCountList
l'
m'
=
Map
.
alter
(
plus
l'
)
l'
m'
where
plus
CandidateTerm
Nothing
=
Just
1
plus
CandidateTerm
(
Just
x
)
=
Just
$
x
+
1
plus
MapTerm
Nothing
=
Just
2
plus
MapTerm
(
Just
x
)
=
Just
$
x
+
2
plus
StopTerm
Nothing
=
Just
3
plus
StopTerm
(
Just
x
)
=
Just
$
x
+
3
src/Gargantext/Core/Text/List/Social/Scores.hs
View file @
83403098
...
...
@@ -39,34 +39,35 @@ toFlowListScores k flc_origin = foldl' (toFlowListScores_Level1 k flc_origin) me
where
toFlowListScores_Level1
::
KeepAllParents
->
FlowCont
Text
FlowListScores
->
FlowCont
Text
FlowListScores
->
Map
Text
NgramsRepoElement
->
FlowCont
Text
FlowListScores
->
FlowCont
Text
FlowListScores
->
FlowCont
Text
FlowListScores
->
Map
Text
NgramsRepoElement
->
FlowCont
Text
FlowListScores
toFlowListScores_Level1
k'
flc_origin'
flc_dest
ngramsRepo
=
Set
.
foldl'
(
toFlowListScores_Level2
k'
ngramsRepo
flc_origin'
)
flc_dest
(
Set
.
fromList
$
Map
.
keys
$
view
flc_cont
flc_origin'
)
toFlowListScores_Level2
::
KeepAllParents
->
Map
Text
NgramsRepoElement
->
FlowCont
Text
FlowListScores
->
FlowCont
Text
FlowListScores
->
Text
->
FlowCont
Text
FlowListScores
->
Map
Text
NgramsRepoElement
->
FlowCont
Text
FlowListScores
->
FlowCont
Text
FlowListScores
->
Text
->
FlowCont
Text
FlowListScores
toFlowListScores_Level2
k''
ngramsRepo
flc_origin''
flc_dest'
t
=
case
Map
.
lookup
t
ngramsRepo
of
Nothing
->
over
flc_cont
(
Map
.
union
$
Map
.
singleton
t
mempty
)
flc_dest'
Just
nre
->
over
flc_cont
(
Map
.
delete
t
)
$
over
flc_scores
(
(
Map
.
alter
(
addParent
k''
nre
(
Set
.
fromList
$
Map
.
keys
$
view
flc_cont
flc_origin''
)
)
t
)
.
(
Map
.
alter
(
addList
$
_nre_list
nre
)
t
)
)
flc_dest'
Nothing
->
over
flc_cont
(
Map
.
union
$
Map
.
singleton
t
mempty
)
flc_dest'
Just
nre
->
over
flc_cont
(
Map
.
delete
t
)
$
over
flc_scores
(
(
Map
.
alter
(
addParent
k''
nre
(
Set
.
fromList
$
Map
.
keys
$
view
flc_cont
flc_origin''
)
)
t
)
.
(
Map
.
alter
(
addList
$
_nre_list
nre
)
t
)
)
flc_dest'
------------------------------------------------------------------------
-- | Main addFunctions to groupResolution the FlowListScores
...
...
@@ -118,9 +119,9 @@ addParentScore :: Num a
->
Set
Text
->
Map
Text
a
->
Map
Text
a
addParentScore
_
Nothing
_ss
mapParent
=
mapParent
addParentScore
(
KeepAllParents
k
)
(
Just
(
NgramsTerm
p'
))
ss
mapParent
=
case
k
of
addParentScore
_
Nothing
_ss
mapParent
=
mapParent
addParentScore
(
KeepAllParents
k
eep
)
(
Just
(
NgramsTerm
p'
))
ss
mapParent
=
case
k
eep
of
True
->
Map
.
alter
addCount
p'
mapParent
False
->
case
Set
.
member
p'
ss
of
False
->
mapParent
...
...
src/Gargantext/Core/Viz/Chart.hs
View file @
83403098
...
...
@@ -31,7 +31,7 @@ import Gargantext.Prelude
import
Gargantext.Core.Text.Metrics.Count
(
occurrencesWith
)
-- Pie Chart
import
Gargantext.API.Ngrams.NTree
import
Gargantext.API.Ngrams.N
grams
Tree
import
Gargantext.API.Ngrams.Tools
import
Gargantext.Core.Types
import
Gargantext.Database.Action.Flow
...
...
@@ -71,7 +71,7 @@ chartData cId nt lt = do
treeData
::
FlowCmdM
env
err
m
=>
CorpusId
->
NgramsType
->
ListType
->
m
[
My
Tree
]
->
m
[
Ngrams
Tree
]
treeData
cId
nt
lt
=
do
ls'
<-
selectNodesWithUsername
NodeList
userMaster
ls
<-
map
(
_node_id
)
<$>
getListsWithParentId
cId
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
View file @
83403098
...
...
@@ -27,7 +27,7 @@ import Control.Applicative
import
Gargantext.Prelude
import
Gargantext.Core.Viz.Types
(
Histo
(
..
))
import
Gargantext.API.Ngrams.N
Tree
(
My
Tree
)
import
Gargantext.API.Ngrams.N
gramsTree
(
Ngrams
Tree
)
import
Gargantext.API.Ngrams.Types
(
TabType
)
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
import
Gargantext.Database.Admin.Types.Metrics
(
ChartMetrics
(
..
),
Metrics
)
...
...
@@ -38,13 +38,13 @@ data HyperdataList =
,
_hl_list
::
!
(
Maybe
Text
)
,
_hl_pie
::
!
(
Map
TabType
(
ChartMetrics
Histo
))
,
_hl_scatter
::
!
(
Map
TabType
Metrics
)
,
_hl_tree
::
!
(
Map
TabType
(
ChartMetrics
[
My
Tree
]))
,
_hl_tree
::
!
(
Map
TabType
(
ChartMetrics
[
Ngrams
Tree
]))
}
deriving
(
Show
,
Generic
)
-- HyperdataList { _hl_chart :: !(Maybe (ChartMetrics Histo))
-- , _hl_list :: !(Maybe Text)
-- , _hl_pie :: !(Maybe (ChartMetrics Histo))
-- , _hl_scatter :: !(Maybe Metrics)
-- , _hl_tree :: !(Maybe (ChartMetrics [
My
Tree]))
-- , _hl_tree :: !(Maybe (ChartMetrics [
Ngrams
Tree]))
-- } deriving (Show, Generic)
defaultHyperdataList
::
HyperdataList
...
...
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