Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Przemyslaw Kaminski
haskell-gargantext
Commits
b7ee566a
Commit
b7ee566a
authored
Feb 07, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] ViewScore instances
parent
15f32749
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
Group.hs
src/Gargantext/Core/Text/List/Group.hs
+1
-1
Prelude.hs
src/Gargantext/Core/Text/List/Group/Prelude.hs
+25
-5
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+2
-2
No files found.
src/Gargantext/Core/Text/List/Group.hs
View file @
b7ee566a
...
...
@@ -29,7 +29,7 @@ import Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Prelude
import
qualified
Data.HashMap.Strict
as
HashMap
------------------------------------------------------------------------
toGroupedTree
::
(
Ord
a
,
Monoid
a
)
toGroupedTree
::
(
Ord
a
,
Monoid
a
,
HasSize
a
)
=>
FlowCont
NgramsTerm
FlowListScores
->
HashMap
NgramsTerm
a
->
FlowCont
NgramsTerm
(
GroupedTreeScores
a
)
...
...
src/Gargantext/Core/Text/List/Group/Prelude.hs
View file @
b7ee566a
...
...
@@ -23,13 +23,12 @@ import Data.Monoid
import
Data.Semigroup
import
Data.Set
(
Set
)
import
Gargantext.API.Ngrams.Types
(
NgramsElement
,
mkNgramsElement
,
NgramsTerm
(
..
),
RootParent
(
..
),
mSetFromList
)
import
Gargantext.Core.Text.Metrics
(
Scored
(
..
),
scored_genInc
)
import
Gargantext.Core.Types
(
ListType
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Prelude
import
qualified
Data.HashMap.Strict
as
HashMap
import
qualified
Data.List
as
List
import
qualified
Data.Set
as
Set
import
Prelude
(
foldl1
)
type
Stem
=
NgramsTerm
------------------------------------------------------------------------
...
...
@@ -91,6 +90,21 @@ instance SetListType (HashMap NgramsTerm (GroupedTreeScores a)) where
------
class
HasSize
a
where
hasSize
::
a
->
Integer
instance
HasSize
Double
where
hasSize
=
round
instance
HasSize
(
Set
a
)
where
hasSize
=
fromIntegral
.
Set
.
size
instance
(
HasSize
a
,
Semigroup
a
)
=>
ViewScore
(
GroupedTreeScores
a
)
Integer
where
viewScore
=
hasSize
.
viewScores
{-
-- TODO clean this instances
instance ViewScore (GroupedTreeScores Double) Double where
viewScore = viewScores
...
...
@@ -100,19 +114,25 @@ instance ViewScores (GroupedTreeScores Double) Double where
parent = view gts'_score g
children = map viewScores $ HashMap.elems $ view gts'_children g
instance ViewScore (GroupedTreeScores (Set NodeId)) Int where
viewScore = Set.size . viewScores
instance ViewScore (GroupedTreeScores (Scored NgramsTerm)) Double where
viewScore = view (gts'_score . scored_genInc)
instance ViewScores (GroupedTreeScores (Set NodeId)) (Set NodeId) where
viewScores g = Set.unions $ parent : children
where
parent = view gts'_score g
children = map viewScores $ HashMap.elems $ view gts'_children g
-}
instance
Semigroup
a
=>
ViewScores
(
GroupedTreeScores
a
)
a
where
viewScores
g
=
foldl1
(
<>
)
$
parent
:
children
where
parent
=
view
gts'_score
g
children
=
map
viewScores
$
HashMap
.
elems
$
view
gts'_children
g
instance
ViewScore
(
GroupedTreeScores
(
Scored
NgramsTerm
))
Double
where
viewScore
=
view
(
gts'_score
.
scored_genInc
)
------
instance
HasTerms
(
HashMap
NgramsTerm
(
GroupedTreeScores
a
))
where
...
...
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
b7ee566a
...
...
@@ -28,14 +28,14 @@ import qualified Data.HashMap.Strict as HashMap
------------------------------------------------------------------------
-- | Main function
groupWithScores'
::
(
Eq
a
,
Ord
a
,
Monoid
a
)
groupWithScores'
::
(
Eq
a
,
Ord
a
,
Monoid
a
,
HasSize
a
)
=>
FlowCont
NgramsTerm
FlowListScores
->
(
NgramsTerm
->
a
)
->
FlowCont
NgramsTerm
(
GroupedTreeScores
a
)
groupWithScores'
flc
scores
=
FlowCont
groups
orphans
where
-- parent/child relation is inherited from social lists
groups
=
HashMap
.
filter
(
\
v
->
view
gts'_score
v
/=
mempty
)
groups
=
HashMap
.
filter
(
\
v
->
view
Score
v
>
0
)
$
toGroupedTree'
$
toMapMaybeParent
scores
$
(
view
flc_scores
flc
<>
view
flc_cont
flc
)
...
...
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