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
177
Issues
177
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
436eec32
Commit
436eec32
authored
Nov 18, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] working for all ngrams but NgramsTerms with simple Tree (1 depth)
parent
b5ad70d8
Pipeline
#1223
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
24 deletions
+16
-24
Group.hs
src/Gargantext/Core/Text/List/Group.hs
+2
-2
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+14
-21
WithStem.hs
src/Gargantext/Core/Text/List/Group/WithStem.hs
+0
-1
No files found.
src/Gargantext/Core/Text/List/Group.hs
View file @
436eec32
...
...
@@ -43,10 +43,10 @@ toGroupedText groupParams scores =
------------------------------------------------------------------------
toGroupedText_test
::
Bool
-- Map Stem (GroupedText Int)
--
toGroupedText_test :: Bool -- Map Stem (GroupedText Int)
toGroupedText_test
=
-- fromGroupedScores $ fromListScores from
toGroupedText
params
from
datas
==
result
toGroupedText
params
from
datas
--
== result
where
params
=
GroupedTextParams
identity
(
Set
.
size
.
snd
)
fst
snd
from
::
Map
Text
FlowListScores
...
...
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
436eec32
...
...
@@ -14,10 +14,11 @@ Portability : POSIX
module
Gargantext.Core.Text.List.Group.WithScores
where
import
Control.Lens
(
makeLenses
,
over
,
view
)
import
Control.Lens
(
makeLenses
,
view
,
set
)
import
Data.Semigroup
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Data.Text
(
Text
)
import
Gargantext.Core.Types
(
ListType
(
..
))
-- (MasterCorpusId, UserCorpusId)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
...
...
@@ -56,32 +57,24 @@ instance Semigroup a => Semigroup (GroupedTextScores a) where
groupWithScores
::
Map
Text
FlowListScores
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
groupWithScores
scores
ms
=
foldl'
(
addScore
scores
)
start
(
Map
.
toList
ms
)
where
start
=
fromGroupedScores
$
fromListScores
scores
groupWithScores
scores
ms
=
addScore
ms
$
fromGroupedScores
$
fromListScores
scores
-- | Add scores depending on being either parent or child or orphan
addScore
::
Map
Text
FlowListScores
addScore
::
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
->
(
Text
,
Set
NodeId
)
->
Map
Text
(
GroupedTextScores
(
Set
NodeId
))
addScore
scores
ms
(
t
,
ns
)
=
Map
.
alter
(
isParent
ns
)
t
ms
addScore
mapNs
=
Map
.
mapWithKey
scoring
where
-- is parent case
isParent
ns'
(
Just
(
GroupedTextScores
l
s
c
))
=
let
ns''
=
ns'
<>
s
in
Just
(
GroupedTextScores
l
ns''
c
)
scoring
k
g
=
set
gts_score
(
Set
.
unions
$
catMaybes
$
map
(
\
n
->
Map
.
lookup
n
mapNs
)
$
[
k
]
<>
(
Set
.
toList
$
view
gts_children
g
)
)
g
-- is either child or orphan case
isParent
ns'
Nothing
=
Just
$
GroupedTextScores
Nothing
ns'
Set
.
empty
{- case Map.lookup t scores of
-- is child case
Just fls -> case keyWithMaxValue $ view fls_parents fls of
Just parent -> over gts_score (<> ns') <$> Map.lookup parent ms
Nothing -> panic "[G.C.T.G.WS.addScore] Should not happen"
-- is Orphan case
Nothing -> Just $ GroupedTextScores Nothing ns' Set.empty
-}
------------------------------------------------------------------------
fromGroupedScores
::
Map
Parent
GroupedWithListScores
->
Map
Parent
(
GroupedTextScores
(
Set
NodeId
))
...
...
src/Gargantext/Core/Text/List/Group/WithStem.hs
View file @
436eec32
...
...
@@ -26,7 +26,6 @@ import Gargantext.Core (Lang(..))
import
Gargantext.Core.Text
(
size
)
import
Gargantext.Core.Types
(
ListType
(
..
))
-- (MasterCorpusId, UserCorpusId)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Core.Text.List.Group.WithScores
import
Gargantext.Core.Text.Terms.Mono.Stem
(
stem
)
import
Gargantext.Prelude
...
...
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