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
141
Issues
141
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
a8d05287
Commit
a8d05287
authored
Nov 24, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] connecting Ngrams Terms flow with social list
parent
501553c6
Pipeline
#1241
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
12 deletions
+34
-12
List.hs
src/Gargantext/Core/Text/List.hs
+12
-10
Prelude.hs
src/Gargantext/Core/Text/List/Group/Prelude.hs
+22
-2
No files found.
src/Gargantext/Core/Text/List.hs
View file @
a8d05287
...
...
@@ -153,8 +153,9 @@ buildNgramsTermsList user uCid mCid groupParams = do
groupedWithList
=
map
(
addListType
(
invertForw
socialLists
))
grouped
(
stopTerms
,
candidateTerms
)
=
Map
.
partition
(
\
t
->
t
^.
gt_listType
==
Just
StopTerm
)
groupedWithList
(
stopTerms
,
candidateTerms
)
=
Map
.
partition
(
(
==
Just
StopTerm
)
.
viewListType
)
groupedWithList
(
groupedMono
,
groupedMult
)
=
Map
.
partition
(
\
t
->
t
^.
gt_size
<
2
)
candidateTerms
-- (groupedMono, groupedMult) = Map.partitionWithKey (\t -> t ^. gt_size < 2) candidateTerms
-- printDebug "\n * stopTerms * \n" stopTerms
-- splitting monterms and multiterms to take proportional candidates
...
...
@@ -180,8 +181,9 @@ buildNgramsTermsList user uCid mCid groupParams = do
(
\
set'
(
GroupedText
_
l'
_
g
_
_
_
)
->
Set
.
union
set'
$
Set
.
insert
l'
g
)
Set
.
empty
Set
.
empty
(
groupedMonoHead
<>
groupedMultHead
)
-- selectedTerms = hasTerms (groupedMonoHead <> groupedMultHead)
-- TO remove (and remove HasNodeError instance)
userListId
<-
defaultList
uCid
...
...
@@ -243,7 +245,7 @@ buildNgramsTermsList user uCid mCid groupParams = do
-- filter mono/multi again
(
monoScored
,
multScored
)
=
List
.
partition
(
\
g
->
_gt_size
g
<
2
)
groupsWithScores
-- filter with max score
partitionWithMaxScore
=
List
.
partition
(
\
g
->
let
(
s1
,
s2
)
=
_gt_s
core
g
in
s1
>
s2
)
partitionWithMaxScore
=
List
.
partition
(
\
g
->
let
(
s1
,
s2
)
=
viewS
core
g
in
s1
>
s2
)
(
monoScoredIncl
,
monoScoredExcl
)
=
partitionWithMaxScore
monoScored
(
multScoredIncl
,
multScoredExcl
)
=
partitionWithMaxScore
multScored
...
...
@@ -255,29 +257,29 @@ buildNgramsTermsList user uCid mCid groupParams = do
exclSize
=
1
-
inclSize
splitAt'
n'
=
List
.
splitAt
(
round
$
n'
*
listSizeLocal
)
(
monoScoredInclHead
,
monoScoredInclTail
)
=
splitAt'
(
monoSize
*
inclSize
/
2
)
$
List
.
sortOn
(
Down
.
_gt_s
core
)
monoScoredIncl
(
monoScoredExclHead
,
monoScoredExclTail
)
=
splitAt'
(
monoSize
*
inclSize
/
2
)
$
List
.
sortOn
(
Down
.
_gt_s
core
)
monoScoredExcl
(
monoScoredInclHead
,
monoScoredInclTail
)
=
splitAt'
(
monoSize
*
inclSize
/
2
)
$
List
.
sortOn
(
Down
.
viewS
core
)
monoScoredIncl
(
monoScoredExclHead
,
monoScoredExclTail
)
=
splitAt'
(
monoSize
*
inclSize
/
2
)
$
List
.
sortOn
(
Down
.
viewS
core
)
monoScoredExcl
(
multScoredInclHead
,
multScoredInclTail
)
=
splitAt'
(
multSize
*
exclSize
/
2
)
$
List
.
sortOn
(
Down
.
_gt_s
core
)
multScoredIncl
(
multScoredExclHead
,
multScoredExclTail
)
=
splitAt'
(
multSize
*
exclSize
/
2
)
$
List
.
sortOn
(
Down
.
_gt_s
core
)
multScoredExcl
(
multScoredInclHead
,
multScoredInclTail
)
=
splitAt'
(
multSize
*
exclSize
/
2
)
$
List
.
sortOn
(
Down
.
viewS
core
)
multScoredIncl
(
multScoredExclHead
,
multScoredExclTail
)
=
splitAt'
(
multSize
*
exclSize
/
2
)
$
List
.
sortOn
(
Down
.
viewS
core
)
multScoredExcl
-- Final Step building the Typed list
termListHead
=
maps
<>
cands
where
maps
=
set
gt_l
istType
(
Just
MapTerm
)
maps
=
set
L
istType
(
Just
MapTerm
)
<$>
monoScoredInclHead
<>
monoScoredExclHead
<>
multScoredInclHead
<>
multScoredExclHead
cands
=
set
gt_l
istType
(
Just
CandidateTerm
)
cands
=
set
L
istType
(
Just
CandidateTerm
)
<$>
monoScoredInclTail
<>
monoScoredExclTail
<>
multScoredInclTail
<>
multScoredExclTail
termListTail
=
map
(
set
gt_l
istType
(
Just
CandidateTerm
))
(
groupedMonoTail
<>
groupedMultTail
)
termListTail
=
map
(
set
L
istType
(
Just
CandidateTerm
))
(
groupedMonoTail
<>
groupedMultTail
)
-- printDebug "monoScoredInclHead" monoScoredInclHead
-- printDebug "monoScoredExclHead" monoScoredExclTail
...
...
src/Gargantext/Core/Text/List/Group/Prelude.hs
View file @
a8d05287
...
...
@@ -65,6 +65,9 @@ class SetListType a where
class
Ord
b
=>
ViewScore
a
b
|
a
->
b
where
viewScore
::
a
->
b
class
ViewScores
a
b
|
a
->
b
where
viewScores
::
a
->
b
class
ToNgramsElement
a
where
toNgramsElement
::
a
->
[
NgramsElement
]
...
...
@@ -82,12 +85,29 @@ instance SetListType (GroupedTreeScores a) where
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
)
viewScore
=
Set
.
size
.
viewScores
instance
ViewScores
(
GroupedTreeScores
(
Set
NodeId
))
(
Set
NodeId
)
where
viewScores
g
=
Set
.
unions
$
parent
:
children
where
parent
=
view
gts'_score
g
children
=
map
viewScores
$
Map
.
elems
$
view
gts'_children
g
------
instance
HasTerms
(
Map
Text
(
GroupedTreeScores
a
))
where
hasTerms
=
undefined
hasTerms
=
Set
.
unions
.
(
map
hasTerms
)
.
Map
.
toList
instance
HasTerms
(
Text
,
GroupedTreeScores
a
)
where
hasTerms
(
t
,
g
)
=
Set
.
singleton
t
<>
children
where
children
=
Set
.
unions
$
map
hasTerms
$
Map
.
toList
$
view
gts'_children
g
------
instance
ToNgramsElement
(
Map
Text
(
GroupedTreeScores
a
))
where
toNgramsElement
=
List
.
concat
.
(
map
toNgramsElement
)
.
Map
.
toList
...
...
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