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
adab5615
Commit
adab5615
authored
Nov 23, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] SocialList working for others than Ngrams with Hierarchical groups
parent
acbb8703
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
14 deletions
+70
-14
List.hs
src/Gargantext/Core/Text/List.hs
+7
-5
Group.hs
src/Gargantext/Core/Text/List/Group.hs
+25
-2
Prelude.hs
src/Gargantext/Core/Text/List/Group/Prelude.hs
+38
-7
No files found.
src/Gargantext/Core/Text/List.hs
View file @
adab5615
...
...
@@ -16,12 +16,13 @@ module Gargantext.Core.Text.List
where
import
Control.Lens
((
^.
),
set
,
view
,
over
)
import
Control.Lens
((
^.
),
set
,
over
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Data.Ord
(
Down
(
..
))
import
Data.Set
(
Set
)
import
Data.Text
(
Text
)
import
Data.Tuple.Extra
(
both
)
import
Gargantext.API.Ngrams.Types
(
NgramsElement
)
import
Gargantext.API.Ngrams.Types
(
RepoCmdM
)
import
Gargantext.Core.Text.List.Group
...
...
@@ -97,7 +98,7 @@ buildNgramsOthersList user uCid groupIt (nt, MapListSize mapListSize) = do
let
groupParams
=
GroupedTextParams
groupIt
(
Set
.
size
.
snd
)
fst
snd
{-(size . fst)-}
groupedWithList
=
toGroupedT
ext
groupParams
(
view
flc_scores
socialLists'
)
ngs'
groupedWithList
=
toGroupedT
reeText
groupParams
socialLists'
ngs'
{-
printDebug "groupedWithList"
...
...
@@ -111,9 +112,10 @@ buildNgramsOthersList user uCid groupIt (nt, MapListSize mapListSize) = do
(
mapTerms
,
tailTerms'
)
=
Map
.
partition
((
==
Just
MapTerm
)
.
viewListType
)
tailTerms
listSize
=
mapListSize
-
(
List
.
length
mapTerms
)
(
mapTerms'
,
candiTerms
)
=
List
.
splitAt
listSize
$
List
.
sortOn
(
Down
.
viewScore
)
$
Map
.
elems
tailTerms'
(
mapTerms'
,
candiTerms
)
=
both
Map
.
fromList
$
List
.
splitAt
listSize
$
List
.
sortOn
(
Down
.
viewScore
.
snd
)
$
Map
.
toList
tailTerms'
pure
$
Map
.
fromList
[(
nt
,
(
toNgramsElement
stopTerms
)
<>
(
toNgramsElement
mapTerms
)
...
...
src/Gargantext/Core/Text/List/Group.hs
View file @
adab5615
...
...
@@ -18,13 +18,14 @@ Portability : POSIX
module
Gargantext.Core.Text.List.Group
where
import
Control.Lens
(
set
)
import
Control.Lens
(
set
,
view
)
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Text
(
Text
)
import
Gargantext.Core.Types
(
ListType
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Core.Text.List.Social.Prelude
(
FlowListScores
(
..
))
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Core.Text.List.Group.Prelude
import
Gargantext.Core.Text.List.Group.WithStem
import
Gargantext.Core.Text.List.Group.WithScores
...
...
@@ -41,6 +42,28 @@ toGroupedText :: GroupedTextParams a b
toGroupedText
groupParams
scores
=
(
groupWithStem
groupParams
)
.
(
groupWithScores
scores
)
-- | TODO add group with stemming
toGroupedTreeText
::
GroupedTextParams
a
b
->
FlowCont
Text
FlowListScores
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTreeScores
(
Set
NodeId
))
toGroupedTreeText
_groupParams
flc
scores
=
view
flc_scores
flow1
where
flow1
=
groupWithScores'
flc
scoring
scoring
t
=
fromMaybe
Set
.
empty
$
Map
.
lookup
t
scores
{-
flow2 = case flc_cont flow1 == Set.empty of
True -> view flc_scores flow1
False -> groupWithStem' groupParams flow1
groupWithStem' :: GroupedTextParams a b
-> FlowCont Text (GroupedTreeScores (Set NodeId))
-> FlowCont Text (GroupedTreeScores (Set NodeId))
groupWithStem' _groupParams = identity
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | TODO To be removed
...
...
src/Gargantext/Core/Text/List/Group/Prelude.hs
View file @
adab5615
...
...
@@ -31,11 +31,11 @@ import Gargantext.Prelude
import
qualified
Data.Set
as
Set
import
qualified
Data.Map
as
Map
import
qualified
Data.List
as
List
------------------------------------------------------------------------
-- | Group With Scores Main Types
-- Tree of GroupedTextScores
-- Target : type FlowCont Text GroupedTextScores'
data
GroupedTreeScores
score
=
GroupedTreeScores
{
_gts'_listType
::
!
(
Maybe
ListType
)
,
_gts'_children
::
!
(
Map
Text
(
GroupedTreeScores
score
))
...
...
@@ -55,7 +55,7 @@ instance (Ord score, Monoid score)
makeLenses
'G
r
oupedTreeScores
---------------------------------------------
---------------------------------------------
---------------------------
class
ViewListType
a
where
viewListType
::
a
->
Maybe
ListType
...
...
@@ -68,21 +68,52 @@ class Ord b => ViewScore a b | a -> b where
class
ToNgramsElement
a
where
toNgramsElement
::
a
->
[
NgramsElement
]
---------------------------------------------
---------------------------------------------
---------------------------
instance
ViewListType
(
GroupedTreeScores
a
)
where
viewListType
=
view
gts'_listType
instance
SetListType
(
GroupedTreeScores
a
)
where
setListType
=
set
gts'_listType
instance
SetListType
(
Map
Text
(
GroupedTreeScores
a
))
where
setListType
lt
=
Map
.
map
(
set
gts'_listType
lt
)
instance
ViewScore
(
GroupedTreeScores
(
Set
NodeId
))
Int
where
viewScore
=
Set
.
size
.
(
view
gts'_score
)
instance
ToNgramsElement
(
Map
Text
(
GroupedTreeScores
(
Set
NodeId
)))
where
toNgramsElement
=
undefined
instance
ToNgramsElement
(
Map
Text
(
GroupedTreeScores
a
))
where
toNgramsElement
=
List
.
concat
.
(
map
toNgramsElement
)
.
Map
.
toList
instance
ToNgramsElement
(
Text
,
GroupedTreeScores
a
)
where
toNgramsElement
(
t
,
gts
)
=
parent
:
children
where
parent
=
mkNgramsElement
(
NgramsTerm
t
)
(
fromMaybe
CandidateTerm
$
viewListType
gts
)
Nothing
(
mSetFromList
$
map
NgramsTerm
$
Map
.
keys
$
view
gts'_children
gts
)
children
=
List
.
concat
$
map
(
childrenWith
(
NgramsTerm
t
)
(
NgramsTerm
t
)
)
$
Map
.
toList
$
view
gts'_children
gts
childrenWith
root
parent'
(
t'
,
gts'
)
=
parent''
:
children'
where
parent''
=
mkNgramsElement
(
NgramsTerm
t'
)
(
fromMaybe
CandidateTerm
$
viewListType
gts'
)
(
Just
$
RootParent
root
parent'
)
(
mSetFromList
$
map
NgramsTerm
$
Map
.
keys
$
view
gts'_children
gts'
)
children'
=
List
.
concat
$
map
(
childrenWith
root
(
NgramsTerm
t'
)
)
$
Map
.
toList
$
view
gts'_children
gts'
...
...
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