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
7173c1d5
Commit
7173c1d5
authored
Nov 24, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] bug in FlowCont Semigroup instance (intersection for cont)
parent
86473b50
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
29 deletions
+40
-29
List.hs
src/Gargantext/Core/Text/List.hs
+6
-8
Group.hs
src/Gargantext/Core/Text/List/Group.hs
+4
-3
Prelude.hs
src/Gargantext/Core/Text/List/Group/Prelude.hs
+8
-1
WithScores.hs
src/Gargantext/Core/Text/List/Group/WithScores.hs
+6
-5
WithStem.hs
src/Gargantext/Core/Text/List/Group/WithStem.hs
+10
-3
Social.hs
src/Gargantext/Core/Text/List/Social.hs
+1
-1
Prelude.hs
src/Gargantext/Core/Text/List/Social/Prelude.hs
+5
-8
No files found.
src/Gargantext/Core/Text/List.hs
View file @
7173c1d5
...
@@ -16,7 +16,7 @@ module Gargantext.Core.Text.List
...
@@ -16,7 +16,7 @@ module Gargantext.Core.Text.List
where
where
import
Control.Lens
((
^.
),
set
,
over
)
import
Control.Lens
((
^.
),
view
,
set
,
over
)
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Data.Maybe
(
catMaybes
)
import
Data.Monoid
(
mempty
)
import
Data.Monoid
(
mempty
)
...
@@ -87,32 +87,29 @@ buildNgramsOthersList ::( HasNodeError err
...
@@ -87,32 +87,29 @@ buildNgramsOthersList ::( HasNodeError err
buildNgramsOthersList
user
uCid
groupIt
(
nt
,
MapListSize
mapListSize
)
=
do
buildNgramsOthersList
user
uCid
groupIt
(
nt
,
MapListSize
mapListSize
)
=
do
ngs'
::
Map
Text
(
Set
NodeId
)
<-
getNodesByNgramsUser
uCid
nt
ngs'
::
Map
Text
(
Set
NodeId
)
<-
getNodesByNgramsUser
uCid
nt
-- | PrivateFirst for first developments since Public NodeMode is not implemented yet
socialLists'
::
FlowCont
Text
FlowListScores
socialLists'
::
FlowCont
Text
FlowListScores
<-
flowSocialList'
MySelfFirst
user
nt
(
FlowCont
Map
.
empty
<-
flowSocialList'
MySelfFirst
user
nt
(
FlowCont
Map
.
empty
$
Map
.
fromList
$
Map
.
fromList
$
List
.
zip
(
Map
.
keys
ngs'
)
$
List
.
zip
(
Map
.
keys
ngs'
)
(
List
.
cycle
[
mempty
])
(
List
.
cycle
[
mempty
])
)
)
-- PrivateFirst for first developments since Public NodeMode is not implemented yet
{-
{-
printDebug "flowSocialList'"
printDebug "flowSocialList'"
$ Map.filter (not . ((==) Map.empty) .
view fls_parents
)
$ Map.filter (not . ((==) Map.empty) .
(view fls_parents)
)
$ view flc_scores socialLists'
$ view flc_scores socialLists'
-}
-}
let
let
groupedWithList
=
toGroupedTreeText
groupIt
socialLists'
ngs'
groupedWithList
=
toGroupedTreeText
groupIt
socialLists'
ngs'
{-
{-
printDebug "groupedWithList"
printDebug "groupedWithList"
$ Map.map (\v -> (view gt_label v, view gt_children v))
$ view flc_scores groupedWithList
$ Map.filter (\v -> (Set.size $ view gt_children v) > 0)
$ groupedWithList
-}
-}
let
let
(
stopTerms
,
tailTerms
)
=
Map
.
partition
((
==
Just
StopTerm
)
.
viewListType
)
groupedWithList
(
stopTerms
,
tailTerms
)
=
Map
.
partition
((
==
Just
StopTerm
)
.
viewListType
)
$
view
flc_scores
groupedWithList
(
mapTerms
,
tailTerms'
)
=
Map
.
partition
((
==
Just
MapTerm
)
.
viewListType
)
tailTerms
(
mapTerms
,
tailTerms'
)
=
Map
.
partition
((
==
Just
MapTerm
)
.
viewListType
)
tailTerms
listSize
=
mapListSize
-
(
List
.
length
mapTerms
)
listSize
=
mapListSize
-
(
List
.
length
mapTerms
)
...
@@ -178,6 +175,7 @@ buildNgramsTermsList user uCid mCid groupParams = do
...
@@ -178,6 +175,7 @@ buildNgramsTermsList user uCid mCid groupParams = do
let
let
-- Get Local Scores now for selected grouped ngrams
-- Get Local Scores now for selected grouped ngrams
-- TODO HasTerms
selectedTerms
=
Set
.
toList
$
List
.
foldl'
selectedTerms
=
Set
.
toList
$
List
.
foldl'
(
\
set'
(
GroupedText
_
l'
_
g
_
_
_
)
->
Set
.
union
set'
(
\
set'
(
GroupedText
_
l'
_
g
_
_
_
)
->
Set
.
union
set'
$
Set
.
insert
l'
g
$
Set
.
insert
l'
g
...
...
src/Gargantext/Core/Text/List/Group.hs
View file @
7173c1d5
...
@@ -39,8 +39,9 @@ import qualified Data.List as List
...
@@ -39,8 +39,9 @@ import qualified Data.List as List
toGroupedTreeText
::
GroupParams
toGroupedTreeText
::
GroupParams
->
FlowCont
Text
FlowListScores
->
FlowCont
Text
FlowListScores
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
Set
NodeId
)
->
Map
Text
(
GroupedTreeScores
(
Set
NodeId
))
-- -> Map Text (GroupedTreeScores (Set NodeId))
toGroupedTreeText
groupParams
flc
scores
=
view
flc_scores
flow2
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
toGroupedTreeText
groupParams
flc
scores
=
{-view flc_scores-}
flow2
where
where
flow1
=
groupWithScores'
flc
scoring
flow1
=
groupWithScores'
flc
scoring
scoring
t
=
fromMaybe
Set
.
empty
$
Map
.
lookup
t
scores
scoring
t
=
fromMaybe
Set
.
empty
$
Map
.
lookup
t
scores
...
...
src/Gargantext/Core/Text/List/Group/Prelude.hs
View file @
7173c1d5
...
@@ -38,7 +38,7 @@ import qualified Data.List as List
...
@@ -38,7 +38,7 @@ import qualified Data.List as List
data
GroupedTreeScores
score
=
data
GroupedTreeScores
score
=
GroupedTreeScores
{
_gts'_listType
::
!
(
Maybe
ListType
)
GroupedTreeScores
{
_gts'_listType
::
!
(
Maybe
ListType
)
,
_gts'_children
::
!
(
Map
Text
(
GroupedTreeScores
score
))
,
_gts'_children
::
!
(
Map
Text
(
GroupedTreeScores
score
))
,
_gts'_score
::
score
,
_gts'_score
::
!
score
}
deriving
(
Show
,
Ord
,
Eq
)
}
deriving
(
Show
,
Ord
,
Eq
)
instance
(
Semigroup
a
,
Ord
a
)
=>
Semigroup
(
GroupedTreeScores
a
)
where
instance
(
Semigroup
a
,
Ord
a
)
=>
Semigroup
(
GroupedTreeScores
a
)
where
...
@@ -68,6 +68,9 @@ class Ord b => ViewScore a b | a -> b where
...
@@ -68,6 +68,9 @@ class Ord b => ViewScore a b | a -> b where
class
ToNgramsElement
a
where
class
ToNgramsElement
a
where
toNgramsElement
::
a
->
[
NgramsElement
]
toNgramsElement
::
a
->
[
NgramsElement
]
class
HasTerms
a
where
hasTerms
::
a
->
Set
Text
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Instances declartion for (GroupedTreeScores a)
-- | Instances declartion for (GroupedTreeScores a)
instance
ViewListType
(
GroupedTreeScores
a
)
where
instance
ViewListType
(
GroupedTreeScores
a
)
where
...
@@ -82,6 +85,10 @@ instance SetListType (Map Text (GroupedTreeScores a)) where
...
@@ -82,6 +85,10 @@ instance SetListType (Map Text (GroupedTreeScores a)) where
instance
ViewScore
(
GroupedTreeScores
(
Set
NodeId
))
Int
where
instance
ViewScore
(
GroupedTreeScores
(
Set
NodeId
))
Int
where
viewScore
=
Set
.
size
.
(
view
gts'_score
)
viewScore
=
Set
.
size
.
(
view
gts'_score
)
instance
HasTerms
(
Map
Text
(
GroupedTreeScores
a
))
where
hasTerms
=
undefined
instance
ToNgramsElement
(
Map
Text
(
GroupedTreeScores
a
))
where
instance
ToNgramsElement
(
Map
Text
(
GroupedTreeScores
a
))
where
toNgramsElement
=
List
.
concat
.
(
map
toNgramsElement
)
.
Map
.
toList
toNgramsElement
=
List
.
concat
.
(
map
toNgramsElement
)
.
Map
.
toList
...
...
src/Gargantext/Core/Text/List/Group/WithScores.hs
View file @
7173c1d5
...
@@ -26,7 +26,6 @@ import Gargantext.Database.Admin.Types.Node (NodeId)
...
@@ -26,7 +26,6 @@ import Gargantext.Database.Admin.Types.Node (NodeId)
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Core.Text.List.Group.Prelude
import
Gargantext.Core.Text.List.Group.Prelude
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
...
@@ -44,11 +43,10 @@ groupWithScores' flc scores = FlowCont groups orphans
...
@@ -44,11 +43,10 @@ groupWithScores' flc scores = FlowCont groups orphans
$
toMapMaybeParent
scores
$
toMapMaybeParent
scores
$
view
flc_scores
flc
$
view
flc_scores
flc
-- orphans
have been
filtered already
-- orphans
should be
filtered already
orphans
=
toGroupedTree
orphans
=
toGroupedTree
$
toMapMaybeParent
scores
$
toMapMaybeParent
scores
$
(
view
flc_cont
flc
)
$
view
flc_cont
flc
------------------------------------------------------------------------
------------------------------------------------------------------------
toMapMaybeParent
::
(
Text
->
Set
NodeId
)
toMapMaybeParent
::
(
Text
->
Set
NodeId
)
->
Map
Text
FlowListScores
->
Map
Text
FlowListScores
...
@@ -92,6 +90,9 @@ toGroupedTree' m notEmpty
...
@@ -92,6 +90,9 @@ toGroupedTree' m notEmpty
--8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<--
--8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<-- -8<--
-- TODO TO BE REMOVED
-- TODO TO BE REMOVED
data
GroupedTextScores
score
=
data
GroupedTextScores
score
=
...
...
src/Gargantext/Core/Text/List/Group/WithStem.hs
View file @
7173c1d5
...
@@ -20,6 +20,7 @@ module Gargantext.Core.Text.List.Group.WithStem
...
@@ -20,6 +20,7 @@ module Gargantext.Core.Text.List.Group.WithStem
import
Control.Lens
(
makeLenses
,
view
,
over
)
import
Control.Lens
(
makeLenses
,
view
,
over
)
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
Data.Monoid
(
mempty
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Text
(
size
)
import
Gargantext.Core.Text
(
size
)
...
@@ -36,6 +37,7 @@ import qualified Data.Text as Text
...
@@ -36,6 +37,7 @@ import qualified Data.Text as Text
-- | Main Types
-- | Main Types
data
StopSize
=
StopSize
{
unStopSize
::
!
Int
}
data
StopSize
=
StopSize
{
unStopSize
::
!
Int
}
deriving
(
Eq
)
-- | TODO: group with 2 terms only can be
-- | TODO: group with 2 terms only can be
-- discussed. Main purpose of this is offering
-- discussed. Main purpose of this is offering
...
@@ -47,13 +49,18 @@ data GroupParams = GroupParams { unGroupParams_lang :: !Lang
...
@@ -47,13 +49,18 @@ data GroupParams = GroupParams { unGroupParams_lang :: !Lang
,
unGroupParams_stopSize
::
!
StopSize
,
unGroupParams_stopSize
::
!
StopSize
}
}
|
GroupIdentity
|
GroupIdentity
deriving
(
Eq
)
------------------------------------------------------------------------
------------------------------------------------------------------------
groupWithStem'
::
GroupParams
groupWithStem'
::
GroupParams
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
groupWithStem'
=
mergeWith
.
groupWith
groupWithStem'
g
flc
|
g
==
GroupIdentity
=
FlowCont
(
(
<>
)
(
view
flc_scores
flc
)
(
view
flc_cont
flc
)
)
Map
.
empty
|
otherwise
=
mergeWith
(
groupWith
g
)
flc
-- | MergeWith : with stem, we always have an answer
-- | MergeWith : with stem, we always have an answer
-- if Maybe lems then we should add it to continuation
-- if Maybe lems then we should add it to continuation
...
@@ -69,7 +76,7 @@ mergeWith fun flc = FlowCont scores Map.empty
...
@@ -69,7 +76,7 @@ mergeWith fun flc = FlowCont scores Map.empty
scores'
=
view
flc_scores
flc
scores'
=
view
flc_scores
flc
cont'
=
Map
.
toList
$
view
flc_cont
flc
cont'
=
Map
.
toList
$
view
flc_cont
flc
-- TODO insert
i
at the right place in group hierarchy
-- TODO insert at the right place in group hierarchy
-- adding as child of the parent for now
-- adding as child of the parent for now
alter
::
Map
Stem
Text
alter
::
Map
Stem
Text
->
Map
Text
(
GroupedTreeScores
(
Set
NodeId
))
->
Map
Text
(
GroupedTreeScores
(
Set
NodeId
))
...
...
src/Gargantext/Core/Text/List/Social.hs
View file @
7173c1d5
src/Gargantext/Core/Text/List/Social/Prelude.hs
View file @
7173c1d5
...
@@ -46,12 +46,12 @@ instance (Ord a, Eq b) => Monoid (FlowCont a b) where
...
@@ -46,12 +46,12 @@ instance (Ord a, Eq b) => Monoid (FlowCont a b) where
instance
(
Eq
a
,
Ord
a
,
Eq
b
)
=>
Semigroup
(
FlowCont
a
b
)
where
instance
(
Eq
a
,
Ord
a
,
Eq
b
)
=>
Semigroup
(
FlowCont
a
b
)
where
(
<>
)
(
FlowCont
m1
s1
)
(
<>
)
(
FlowCont
m1
s1
)
(
FlowCont
m2
s2
)
(
FlowCont
m2
s2
)
|
s1
==
mempty
=
FlowCont
m
s2
=
FlowCont
m
s
|
s2
==
mempty
=
FlowCont
m
s1
|
otherwise
=
FlowCont
m
(
Map
.
intersection
s1
s2
)
where
where
m
=
Map
.
union
m1
m2
m
=
Map
.
union
m1
m2
s
=
Map
.
intersection
s1
s2
makeLenses
''
F
lowCont
-- | Datatype definition
-- | Datatype definition
data
FlowListScores
=
data
FlowListScores
=
...
@@ -62,9 +62,6 @@ data FlowListScores =
...
@@ -62,9 +62,6 @@ data FlowListScores =
}
}
deriving
(
Show
,
Generic
,
Eq
)
deriving
(
Show
,
Generic
,
Eq
)
------------------------------------------------------------------------
makeLenses
''
F
lowCont
makeLenses
''
F
lowListScores
makeLenses
''
F
lowListScores
-- | Rules to compose 2 datatype FlowListScores
-- | Rules to compose 2 datatype FlowListScores
...
...
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