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
b5ad70d8
Commit
b5ad70d8
authored
Nov 18, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TESTS+FIX] SocialList : orphans
parent
aa9f19ea
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
6 deletions
+62
-6
Group.hs
src/Gargantext/Core/Text/List/Group.hs
+52
-0
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+6
-5
WithStem.hs
src/Gargantext/Core/Text/List/Group/WithStem.hs
+4
-1
No files found.
src/Gargantext/Core/Text/List/Group.hs
View file @
b5ad70d8
...
...
@@ -42,6 +42,58 @@ toGroupedText groupParams scores =
------------------------------------------------------------------------
toGroupedText_test
::
Bool
-- Map Stem (GroupedText Int)
toGroupedText_test
=
-- fromGroupedScores $ fromListScores from
toGroupedText
params
from
datas
==
result
where
params
=
GroupedTextParams
identity
(
Set
.
size
.
snd
)
fst
snd
from
::
Map
Text
FlowListScores
from
=
Map
.
fromList
[(
"A. Rahmani"
,
FlowListScores
{
_fls_parents
=
Map
.
fromList
[(
"T. Reposeur"
,
1
)]
,
_fls_listType
=
Map
.
fromList
[(
MapTerm
,
2
)]})
,(
"B. Tamain"
,
FlowListScores
{
_fls_parents
=
Map
.
fromList
[(
"T. Reposeur"
,
1
)]
,
_fls_listType
=
Map
.
fromList
[(
MapTerm
,
2
)]})
]
datas
::
Map
Text
(
Set
NodeId
)
datas
=
Map
.
fromList
[(
"A. Rahmani"
,
Set
.
fromList
[
1
,
2
])
,(
"T. Reposeur"
,
Set
.
fromList
[
3
,
4
])
,(
"B. Tamain"
,
Set
.
fromList
[
5
,
6
])
]
result
::
Map
Stem
(
GroupedText
Int
)
result
=
Map
.
fromList
[(
"A. Rahmani"
,
GroupedText
{
_gt_listType
=
Nothing
,
_gt_label
=
"A. Rahmani"
,
_gt_score
=
2
,
_gt_children
=
Set
.
empty
,
_gt_size
=
2
,
_gt_stem
=
"A. Rahmani"
,
_gt_nodes
=
Set
.
fromList
[
1
,
2
]
}
)
,(
"B. Tamain"
,
GroupedText
{
_gt_listType
=
Nothing
,
_gt_label
=
"B. Tamain"
,
_gt_score
=
2
,
_gt_children
=
Set
.
empty
,
_gt_size
=
2
,
_gt_stem
=
"B. Tamain"
,
_gt_nodes
=
Set
.
fromList
[
5
,
6
]
}
)
,(
"T. Reposeur"
,
GroupedText
{
_gt_listType
=
Nothing
,
_gt_label
=
"T. Reposeur"
,
_gt_score
=
2
,
_gt_children
=
Set
.
fromList
[
"A. Rahmani"
,
"B. Tamain"
]
,
_gt_size
=
2
,
_gt_stem
=
"T. Reposeur"
,
_gt_nodes
=
Set
.
fromList
[
3
,
4
]
}
)
]
------------------------------------------------------------------------
-- | To be removed
addListType
::
Map
Text
ListType
->
GroupedText
a
->
GroupedText
a
...
...
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
b5ad70d8
...
...
@@ -32,7 +32,7 @@ import qualified Data.Map as Map
data
GroupedWithListScores
=
GroupedWithListScores
{
_gwls_children
::
!
(
Set
Text
)
,
_gwls_listType
::
!
(
Maybe
ListType
)
}
}
deriving
(
Show
)
makeLenses
''
G
roupedWithListScores
instance
Semigroup
GroupedWithListScores
where
(
<>
)
(
GroupedWithListScores
c1
l1
)
...
...
@@ -44,7 +44,7 @@ data GroupedTextScores score =
GroupedTextScores
{
_gts_listType
::
!
(
Maybe
ListType
)
,
_gts_score
::
score
,
_gts_children
::
!
(
Set
Text
)
}
}
deriving
(
Show
)
makeLenses
'G
r
oupedTextScores
instance
Semigroup
a
=>
Semigroup
(
GroupedTextScores
a
)
where
(
<>
)
(
GroupedTextScores
l1
s1
c1
)
...
...
@@ -72,14 +72,15 @@ addScore scores ms (t, ns) = Map.alter (isParent ns) t ms
isParent
ns'
(
Just
(
GroupedTextScores
l
s
c
))
=
let
ns''
=
ns'
<>
s
in
Just
(
GroupedTextScores
l
ns''
c
)
-- is either child or orphan case
isParent
ns'
Nothing
=
case
Map
.
lookup
t
scores
of
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
"Should not happen"
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
...
...
src/Gargantext/Core/Text/List/Group/WithStem.hs
View file @
b5ad70d8
...
...
@@ -26,6 +26,7 @@ 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
...
...
@@ -67,15 +68,17 @@ data GroupedText score =
,
_gt_size
::
!
Int
,
_gt_stem
::
!
Stem
-- needed ?
,
_gt_nodes
::
!
(
Set
NodeId
)
}
deriving
Show
--}
}
deriving
(
Show
,
Eq
)
--}
{-
instance Show score => Show (GroupedText score) where
show (GroupedText lt l s _ _ _ _) = show l <> " : " <> show lt <> " : " <> show s
--}
{-
instance (Eq a) => Eq (GroupedText a) where
(==) (GroupedText _ _ score1 _ _ _ _)
(GroupedText _ _ score2 _ _ _ _) = (==) score1 score2
-}
instance
(
Eq
a
,
Ord
a
)
=>
Ord
(
GroupedText
a
)
where
compare
(
GroupedText
_
_
score1
_
_
_
_
)
...
...
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