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
ad759fa0
Commit
ad759fa0
authored
Dec 14, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] ListType working now with history patch
parent
69c6ee20
Pipeline
#1301
failed with stage
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
45 deletions
+58
-45
List.hs
src/Gargantext/Core/Text/List.hs
+9
-0
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+10
-14
Social.hs
src/Gargantext/Core/Text/List/Social.hs
+19
-19
Patch.hs
src/Gargantext/Core/Text/List/Social/Patch.hs
+7
-5
Prelude.hs
src/Gargantext/Core/Text/List/Social/Prelude.hs
+13
-7
No files found.
src/Gargantext/Core/Text/List.hs
View file @
ad759fa0
...
@@ -101,9 +101,18 @@ buildNgramsOthersList user uCid groupParams (nt, MapListSize mapListSize) = do
...
@@ -101,9 +101,18 @@ buildNgramsOthersList user uCid groupParams (nt, MapListSize mapListSize) = do
(
List
.
cycle
[
mempty
])
(
List
.
cycle
[
mempty
])
)
)
if
nt
==
Authors
then
printDebug
"flowSocialList"
socialLists
else
printDebug
"flowSocialList"
""
let
let
groupedWithList
=
toGroupedTree
groupParams
socialLists
allTerms
groupedWithList
=
toGroupedTree
groupParams
socialLists
allTerms
if
nt
==
Authors
then
printDebug
"groupedWithList"
groupedWithList
else
printDebug
"groupedWithList"
""
let
let
(
stopTerms
,
tailTerms
)
=
Map
.
partition
((
==
Just
StopTerm
)
.
viewListType
)
(
stopTerms
,
tailTerms
)
=
Map
.
partition
((
==
Just
StopTerm
)
.
viewListType
)
$
view
flc_scores
groupedWithList
$
view
flc_scores
groupedWithList
...
...
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
ad759fa0
...
@@ -32,7 +32,7 @@ import qualified Data.Map as Map
...
@@ -32,7 +32,7 @@ import qualified Data.Map as Map
groupWithScores'
::
(
Eq
a
,
Ord
a
,
Monoid
a
)
groupWithScores'
::
(
Eq
a
,
Ord
a
,
Monoid
a
)
=>
FlowCont
Text
FlowListScores
=>
FlowCont
Text
FlowListScores
->
(
Text
->
a
)
-- Map Text (a)
->
(
Text
->
a
)
-- Map Text (a)
->
FlowCont
Text
(
GroupedTreeScores
(
a
)
)
->
FlowCont
Text
(
GroupedTreeScores
a
)
groupWithScores'
flc
scores
=
FlowCont
groups
orphans
groupWithScores'
flc
scores
=
FlowCont
groups
orphans
where
where
-- parent/child relation is inherited from social lists
-- parent/child relation is inherited from social lists
...
@@ -44,11 +44,12 @@ groupWithScores' flc scores = FlowCont groups orphans
...
@@ -44,11 +44,12 @@ groupWithScores' flc scores = FlowCont groups orphans
orphans
=
toGroupedTree
orphans
=
toGroupedTree
$
toMapMaybeParent
scores
$
toMapMaybeParent
scores
$
view
flc_cont
flc
$
view
flc_cont
flc
------------------------------------------------------------------------
------------------------------------------------------------------------
toMapMaybeParent
::
(
Eq
a
,
Ord
a
,
Monoid
a
)
toMapMaybeParent
::
(
Eq
a
,
Ord
a
,
Monoid
a
)
=>
(
Text
->
a
)
=>
(
Text
->
a
)
->
Map
Text
FlowListScores
->
Map
Text
FlowListScores
->
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTreeScores
(
a
)
))
->
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTreeScores
a
))
toMapMaybeParent
f
=
Map
.
fromListWith
(
<>
)
toMapMaybeParent
f
=
Map
.
fromListWith
(
<>
)
.
(
map
(
fromScores''
f
))
.
(
map
(
fromScores''
f
))
.
Map
.
toList
.
Map
.
toList
...
@@ -56,7 +57,7 @@ toMapMaybeParent f = Map.fromListWith (<>)
...
@@ -56,7 +57,7 @@ toMapMaybeParent f = Map.fromListWith (<>)
fromScores''
::
(
Eq
a
,
Ord
a
,
Monoid
a
)
fromScores''
::
(
Eq
a
,
Ord
a
,
Monoid
a
)
=>
(
Text
->
a
)
=>
(
Text
->
a
)
->
(
Text
,
FlowListScores
)
->
(
Text
,
FlowListScores
)
->
(
Maybe
Parent
,
Map
Text
(
GroupedTreeScores
(
a
)
))
->
(
Maybe
Parent
,
Map
Text
(
GroupedTreeScores
a
))
fromScores''
f'
(
t
,
fs
)
=
(
maybeParent
fromScores''
f'
(
t
,
fs
)
=
(
maybeParent
,
Map
.
fromList
[(
t
,
set
gts'_score
(
f'
t
)
,
Map
.
fromList
[(
t
,
set
gts'_score
(
f'
t
)
$
set
gts'_listType
maybeList
mempty
$
set
gts'_listType
maybeList
mempty
...
@@ -66,17 +67,18 @@ fromScores'' f' (t, fs) = ( maybeParent
...
@@ -66,17 +67,18 @@ fromScores'' f' (t, fs) = ( maybeParent
maybeParent
=
keyWithMaxValue
$
view
fls_parents
fs
maybeParent
=
keyWithMaxValue
$
view
fls_parents
fs
maybeList
=
keyWithMaxValue
$
view
fls_listType
fs
maybeList
=
keyWithMaxValue
$
view
fls_listType
fs
------------------------------------------------------------------------
toGroupedTree
::
Eq
a
toGroupedTree
::
Eq
a
=>
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTreeScores
(
a
)
))
=>
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTreeScores
a
))
->
Map
Parent
(
GroupedTreeScores
(
a
)
)
->
Map
Parent
(
GroupedTreeScores
a
)
toGroupedTree
m
=
case
Map
.
lookup
Nothing
m
of
toGroupedTree
m
=
case
Map
.
lookup
Nothing
m
of
Nothing
->
mempty
Nothing
->
mempty
Just
m'
->
toGroupedTree'
m
m'
Just
m'
->
toGroupedTree'
m
m'
toGroupedTree'
::
Eq
a
=>
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTreeScores
(
a
)
))
toGroupedTree'
::
Eq
a
=>
Map
(
Maybe
Parent
)
(
Map
Text
(
GroupedTreeScores
a
))
->
(
Map
Text
(
GroupedTreeScores
(
a
)
))
->
(
Map
Text
(
GroupedTreeScores
a
))
->
Map
Parent
(
GroupedTreeScores
(
a
)
)
->
Map
Parent
(
GroupedTreeScores
a
)
toGroupedTree'
m
notEmpty
toGroupedTree'
m
notEmpty
|
notEmpty
==
mempty
=
mempty
|
notEmpty
==
mempty
=
mempty
|
otherwise
=
Map
.
mapWithKey
(
addGroup
m
)
notEmpty
|
otherwise
=
Map
.
mapWithKey
(
addGroup
m
)
notEmpty
...
@@ -89,9 +91,3 @@ toGroupedTree' m notEmpty
...
@@ -89,9 +91,3 @@ toGroupedTree' m notEmpty
)
)
v
v
src/Gargantext/Core/Text/List/Social.hs
View file @
ad759fa0
...
@@ -86,13 +86,28 @@ flowSocialList flowPriority user nt flc =
...
@@ -86,13 +86,28 @@ flowSocialList flowPriority user nt flc =
->
FlowCont
Text
FlowListScores
->
FlowCont
Text
FlowListScores
->
[
ListId
]
->
[
ListId
]
->
m
(
FlowCont
Text
FlowListScores
)
->
m
(
FlowCont
Text
FlowListScores
)
flowSocialListByModeWith
nt''
flc''
ns
=
flowSocialListByModeWith
nt''
flc''
listes
=
mapM
(
\
l
->
getListNgrams
[
l
]
nt''
)
ns
getHistoryScores
History_User
nt''
flc''
listes
{-
mapM (\l -> getListNgrams [l] nt'') listes
>>= pure
>>= pure
. toFlowListScores (keepAllParents nt'') flc''
. toFlowListScores (keepAllParents nt'') flc''
-}
-----------------------------------------------------------------
-----------------------------------------------------------------
getHistoryScores
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
,
HasNodeError
err
,
HasTreeError
err
)
=>
History
->
NgramsType
->
FlowCont
Text
FlowListScores
->
[
ListId
]
->
m
(
FlowCont
Text
FlowListScores
)
getHistoryScores
hist
nt
fl
listes
=
do
hist'
<-
addScorePatches
nt
listes
fl
<$>
getHistory
hist
nt
listes
-- printDebug "hist" hist'
pure
hist'
getHistory
::
(
RepoCmdM
env
err
m
getHistory
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
,
CmdM
env
err
m
...
@@ -107,18 +122,3 @@ getHistory hist nt listes =
...
@@ -107,18 +122,3 @@ getHistory hist nt listes =
history
hist
[
nt
]
listes
<$>
getRepo
history
hist
[
nt
]
listes
<$>
getRepo
getHistoryScores
::
(
RepoCmdM
env
err
m
,
CmdM
env
err
m
,
HasNodeError
err
,
HasTreeError
err
)
=>
History
->
NgramsType
->
FlowCont
Text
FlowListScores
->
[
ListId
]
->
m
(
FlowCont
Text
FlowListScores
)
getHistoryScores
hist
nt
fl
listes
=
addScorePatches
nt
listes
fl
<$>
getHistory
hist
nt
listes
src/Gargantext/Core/Text/List/Social/Patch.hs
View file @
ad759fa0
...
@@ -65,7 +65,6 @@ Children are not modified in this specific case.
...
@@ -65,7 +65,6 @@ Children are not modified in this specific case.
-- | Old list get -1 score
-- | Old list get -1 score
-- New list get +1 score
-- New list get +1 score
-- Hence others lists lay around 0 score
-- Hence others lists lay around 0 score
-- TODO add children
addScorePatch
fl
(
NgramsTerm
t
,
(
NgramsPatch
children'
(
Patch
.
Replace
old_list
new_list
)))
=
addScorePatch
fl
(
NgramsTerm
t
,
(
NgramsPatch
children'
(
Patch
.
Replace
old_list
new_list
)))
=
-- | Adding New Children score
-- | Adding New Children score
addScorePatch
fl'
(
NgramsTerm
t
,
NgramsPatch
children'
Patch
.
Keep
)
addScorePatch
fl'
(
NgramsTerm
t
,
NgramsPatch
children'
Patch
.
Keep
)
...
@@ -73,27 +72,30 @@ addScorePatch fl (NgramsTerm t, (NgramsPatch children' (Patch.Replace old_list n
...
@@ -73,27 +72,30 @@ addScorePatch fl (NgramsTerm t, (NgramsPatch children' (Patch.Replace old_list n
-- | Adding New ListType score
-- | Adding New ListType score
fl'
=
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
old_list
(
-
1
))
fl'
=
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
old_list
(
-
1
))
&
flc_scores
.
at
t
%~
(
score
fls_listType
new_list
(
1
))
&
flc_scores
.
at
t
%~
(
score
fls_listType
new_list
(
1
))
&
flc_cont
%~
(
Map
.
delete
t
)
-- | Patching existing Ngrams with children
-- | Patching existing Ngrams with children
addScorePatch
fl
(
NgramsTerm
p
,
NgramsPatch
children'
Patch
.
Keep
)
=
addScorePatch
fl
(
NgramsTerm
p
,
NgramsPatch
children'
Patch
.
Keep
)
=
foldl'
add
'
fl
$
patchMSet_toList
children'
foldl'
add
Child
fl
$
patchMSet_toList
children'
where
where
-- | Adding a child
-- | Adding a child
add
'
fl'
(
NgramsTerm
t
,
Patch
.
Replace
Nothing
(
Just
_
))
=
doLink
(
1
)
p
t
fl'
add
Child
fl'
(
NgramsTerm
t
,
Patch
.
Replace
Nothing
(
Just
_
))
=
doLink
(
1
)
p
t
fl'
-- | Removing a child
-- | Removing a child
add
'
fl'
(
NgramsTerm
t
,
Patch
.
Replace
(
Just
_
)
Nothing
)
=
doLink
(
-
1
)
p
t
fl'
add
Child
fl'
(
NgramsTerm
t
,
Patch
.
Replace
(
Just
_
)
Nothing
)
=
doLink
(
-
1
)
p
t
fl'
-- | This case should not happen: does Nothing
-- | This case should not happen: does Nothing
add
'
fl'
_
=
fl'
add
Child
fl'
_
=
fl'
-- | Inserting a new Ngrams
-- | Inserting a new Ngrams
addScorePatch
fl
(
NgramsTerm
t
,
NgramsReplace
Nothing
(
Just
nre
))
=
addScorePatch
fl
(
NgramsTerm
t
,
NgramsReplace
Nothing
(
Just
nre
))
=
childrenScore
1
t
(
nre
^.
nre_children
)
childrenScore
1
t
(
nre
^.
nre_children
)
$
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
$
nre
^.
nre_list
)
1
$
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
$
nre
^.
nre_list
)
1
&
flc_cont
%~
(
Map
.
delete
t
)
addScorePatch
fl
(
NgramsTerm
t
,
NgramsReplace
(
Just
old_nre
)
maybe_new_nre
)
=
addScorePatch
fl
(
NgramsTerm
t
,
NgramsReplace
(
Just
old_nre
)
maybe_new_nre
)
=
let
fl'
=
childrenScore
(
-
1
)
t
(
old_nre
^.
nre_children
)
let
fl'
=
childrenScore
(
-
1
)
t
(
old_nre
^.
nre_children
)
$
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
$
old_nre
^.
nre_list
)
(
-
1
)
$
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
$
old_nre
^.
nre_list
)
(
-
1
)
&
flc_cont
%~
(
Map
.
delete
t
)
in
case
maybe_new_nre
of
in
case
maybe_new_nre
of
Nothing
->
fl'
Nothing
->
fl'
Just
new_nre
->
addScorePatch
fl'
(
NgramsTerm
t
,
NgramsReplace
Nothing
(
Just
new_nre
))
Just
new_nre
->
addScorePatch
fl'
(
NgramsTerm
t
,
NgramsReplace
Nothing
(
Just
new_nre
))
...
...
src/Gargantext/Core/Text/List/Social/Prelude.hs
View file @
ad759fa0
...
@@ -25,6 +25,7 @@ import Data.Semigroup (Semigroup(..))
...
@@ -25,6 +25,7 @@ import Data.Semigroup (Semigroup(..))
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.Text.Metrics.Freq
(
getMaxFromMap
)
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Main
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
...
@@ -96,9 +97,7 @@ parentUnionsExcl :: Ord a
...
@@ -96,9 +97,7 @@ parentUnionsExcl :: Ord a
->
Map
a
b
->
Map
a
b
parentUnionsExcl
=
Map
.
unions
parentUnionsExcl
=
Map
.
unions
------------------------------------------------------------------------
------------------------------------------------------------------------
hasParent
::
Text
hasParent
::
Text
->
Map
Text
(
Map
Parent
Int
)
->
Map
Text
(
Map
Parent
Int
)
->
Maybe
Parent
->
Maybe
Parent
...
@@ -114,12 +113,19 @@ hasParent t m = case Map.lookup t m of
...
@@ -114,12 +113,19 @@ hasParent t m = case Map.lookup t m of
-- Just 'z'
-- Just 'z'
-- >>> keyWithMaxValue $ DM.fromList $ zip (['a'..'z'] :: [Char]) ([-1,-2..]::[Int])
-- >>> keyWithMaxValue $ DM.fromList $ zip (['a'..'z'] :: [Char]) ([-1,-2..]::[Int])
-- Nothing
-- Nothing
keyWithMaxValue
::
(
Ord
b
,
Num
b
)
=>
Map
a
b
->
Maybe
a
keyWithMaxValue
::
(
Ord
a
,
Ord
b
,
Num
b
)
=>
Map
a
b
->
Maybe
a
keyWithMaxValue
m
=
do
keyWithMaxValue
m
=
do
(
k
,
a
)
<-
fst
<$>
Map
.
maxViewWithKey
m
k
<-
headMay
$
getMaxFromMap
m
if
a
>
0
maxValue
<-
Map
.
lookup
k
m
then
Just
k
if
maxValue
>
0
else
Nothing
then
pure
k
else
Nothing
findMax
::
(
Ord
b
,
Num
b
)
=>
Map
a
b
->
Maybe
(
a
,
b
)
findMax
m
=
case
Map
.
null
m
of
True
->
Nothing
False
->
Just
$
Map
.
findMax
m
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
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