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
193
Issues
193
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
612e9aad
Commit
612e9aad
authored
May 19, 2025
by
Grégoire Locqueville
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply low-hanging changes suggested during code review
parent
b88373d3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
15 deletions
+16
-15
Learn.hs
src/Gargantext/Core/Text/Learn.hs
+2
-2
Count.hs
src/Gargantext/Core/Text/Metrics/Count.hs
+2
-2
Chart.hs
src/Gargantext/Core/Viz/Chart.hs
+2
-2
Tools.hs
src/Gargantext/Core/Viz/Graph/Tools.hs
+4
-2
IGraph.hs
src/Gargantext/Core/Viz/Graph/Tools/IGraph.hs
+4
-5
Utils.hs
src/Gargantext/Core/Viz/Graph/Utils.hs
+2
-2
No files found.
src/Gargantext/Core/Text/Learn.hs
View file @
612e9aad
...
@@ -31,7 +31,7 @@ import Data.Text (pack, unpack, toLower)
...
@@ -31,7 +31,7 @@ import Data.Text (pack, unpack, toLower)
import
Data.Tuple.Extra
(
both
)
import
Data.Tuple.Extra
(
both
)
import
GHC.Generics
import
GHC.Generics
import
Gargantext.Core
(
Lang
(
..
),
allLangs
)
import
Gargantext.Core
(
Lang
(
..
),
allLangs
)
import
Gargantext.Core.Text.Metrics.Count
(
occurrencesSimple
)
import
Gargantext.Core.Text.Metrics.Count
(
countOccurrences
)
import
Gargantext.Core.Text.Samples.DE
qualified
as
DE
import
Gargantext.Core.Text.Samples.DE
qualified
as
DE
import
Gargantext.Core.Text.Samples.EN
qualified
as
EN
import
Gargantext.Core.Text.Samples.EN
qualified
as
EN
import
Gargantext.Core.Text.Samples.ES
qualified
as
ES
import
Gargantext.Core.Text.Samples.ES
qualified
as
ES
...
@@ -197,7 +197,7 @@ wordToBook ns n txt = EventBook ef en
...
@@ -197,7 +197,7 @@ wordToBook ns n txt = EventBook ef en
where
where
chks
=
allChunks
ns
n
txt
chks
=
allChunks
ns
n
txt
en
=
DM
.
fromList
$
map
(
\
(
n'
,
ns'
)
->
(
n'
,
length
ns'
))
$
zip
ns
chks
en
=
DM
.
fromList
$
map
(
\
(
n'
,
ns'
)
->
(
n'
,
length
ns'
))
$
zip
ns
chks
ef
=
foldl'
DM
.
union
DM
.
empty
$
map
occurrencesSimple
chks
ef
=
foldl'
DM
.
union
DM
.
empty
$
map
countOccurrences
chks
op
::
(
Freq
->
Freq
->
Freq
)
->
EventBook
->
EventBook
->
EventBook
op
::
(
Freq
->
Freq
->
Freq
)
->
EventBook
->
EventBook
->
EventBook
op
f
(
EventBook
ef1
en1
)
op
f
(
EventBook
ef1
en1
)
...
...
src/Gargantext/Core/Text/Metrics/Count.hs
View file @
612e9aad
...
@@ -138,12 +138,12 @@ occurrences = occurrencesOn _terms_stem
...
@@ -138,12 +138,12 @@ occurrences = occurrencesOn _terms_stem
-- Note: Compared to `occurences`, this is the more elementary function, maybe
-- Note: Compared to `occurences`, this is the more elementary function, maybe
-- it would make more sense to rename this one into `occurences` and the other
-- it would make more sense to rename this one into `occurences` and the other
-- into something more descriptive
-- into something more descriptive
occurrencesSimple
::
(
Foldable
f
,
Ord
a
,
Num
n
)
countOccurrences
::
(
Foldable
f
,
Ord
a
,
Num
n
)
=>
f
a
-- ^ The collection whose items will be counted
=>
f
a
-- ^ The collection whose items will be counted
->
Map
a
n
-- ^ A map whose keys are items of the input
->
Map
a
n
-- ^ A map whose keys are items of the input
-- collection, and whose values are the number of
-- collection, and whose values are the number of
-- times those items appear in the input collection
-- times those items appear in the input collection
occurrencesSimple
collection
=
countOccurrences
collection
=
foldl'
(
\
occurenceMap
item
->
insertWith
(
+
)
item
1
occurenceMap
)
foldl'
(
\
occurenceMap
item
->
insertWith
(
+
)
item
1
occurenceMap
)
empty
empty
collection
collection
...
...
src/Gargantext/Core/Viz/Chart.hs
View file @
612e9aad
...
@@ -21,7 +21,7 @@ import Gargantext.API.Ngrams.NgramsTree ( toTree, NgramsTree )
...
@@ -21,7 +21,7 @@ import Gargantext.API.Ngrams.NgramsTree ( toTree, NgramsTree )
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
getListNgrams
,
getRepo
,
mapTermListRoot
)
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
getListNgrams
,
getRepo
,
mapTermListRoot
)
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
NgramsTerm
)
)
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
NgramsTerm
)
)
import
Gargantext.Core.NodeStory.Types
(
NodeStoryEnv
)
import
Gargantext.Core.NodeStory.Types
(
NodeStoryEnv
)
import
Gargantext.Core.Text.Metrics.Count
(
occurrencesSimple
)
import
Gargantext.Core.Text.Metrics.Count
(
countOccurrences
)
import
Gargantext.Core.Text.Ngrams
(
NgramsType
)
import
Gargantext.Core.Text.Ngrams
(
NgramsType
)
import
Gargantext.Core.Types.Main
(
ListType
)
import
Gargantext.Core.Types.Main
(
ListType
)
import
Gargantext.Database.Admin.Types.Node
(
NodeType
(
NodeList
),
CorpusId
,
contextId2NodeId
)
import
Gargantext.Database.Admin.Types.Node
(
NodeType
(
NodeList
),
CorpusId
,
contextId2NodeId
)
...
@@ -43,7 +43,7 @@ histoData cId = do
...
@@ -43,7 +43,7 @@ histoData cId = do
$
V
.
fromList
$
V
.
fromList
$
sortOn
fst
-- TODO Vector.sortOn
$
sortOn
fst
-- TODO Vector.sortOn
$
toList
$
toList
$
occurrencesSimple
dates
$
countOccurrences
dates
pure
(
Histo
ls
css
)
pure
(
Histo
ls
css
)
...
...
src/Gargantext/Core/Viz/Graph/Tools.hs
View file @
612e9aad
...
@@ -97,8 +97,10 @@ cooc2graphWith bridgenessMethod multi similarity threshold strength myCooc = do
...
@@ -97,8 +97,10 @@ cooc2graphWith bridgenessMethod multi similarity threshold strength myCooc = do
pure
$
data2graph
multi
ti
diag
bridgeness'
confluence'
(
setNodes2clusterNodes
partitions
)
pure
$
data2graph
multi
ti
diag
bridgeness'
confluence'
(
setNodes2clusterNodes
partitions
)
-- | A converter from the partition type returned by `spinglass`
-- | Given a list of sets, each identifying the nodes in a cluster, returns
-- to the partition type required by `bridgeness`
-- a list of 'ClusterNode' where each node has been uniquely labeled
-- by its community ID. This allows flattening the input sets without conflicts
-- on nodes with the same ID (as they would belong to a different community).
partitionsToClusterNodes
::
[
Set
Int
]
->
[
ClusterNode
]
partitionsToClusterNodes
::
[
Set
Int
]
->
[
ClusterNode
]
partitionsToClusterNodes
setlist
=
setlist
partitionsToClusterNodes
setlist
=
setlist
&
fmap
toList
-- Convert sets to lists
&
fmap
toList
-- Convert sets to lists
...
...
src/Gargantext/Core/Viz/Graph/Tools/IGraph.hs
View file @
612e9aad
...
@@ -20,7 +20,6 @@ module Gargantext.Core.Viz.Graph.Tools.IGraph
...
@@ -20,7 +20,6 @@ module Gargantext.Core.Viz.Graph.Tools.IGraph
import
Data.Serialize
(
Serialize
)
import
Data.Serialize
(
Serialize
)
import
IGraph
hiding
(
mkGraph
,
neighbors
,
edges
,
nodes
,
Node
,
Graph
)
import
IGraph
hiding
(
mkGraph
,
neighbors
,
edges
,
nodes
,
Node
,
Graph
)
import
Protolude
import
Protolude
import
Gargantext.Prelude
(
saveAsFileDebug
)
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
import
qualified
Data.Map.Strict
as
Map
import
qualified
Data.Map.Strict
as
Map
import
qualified
IGraph
as
IG
import
qualified
IGraph
as
IG
...
@@ -62,7 +61,6 @@ spinglassAux seed graph = do
...
@@ -62,7 +61,6 @@ spinglassAux seed graph = do
-- The clusters we get are composed of vertex IDs corresponding to the internal
-- The clusters we get are composed of vertex IDs corresponding to the internal
-- representation of IGraph graphs, so we need to retrieve the vertex labels:
-- representation of IGraph graphs, so we need to retrieve the vertex labels:
let
clusterLabels
=
(
fmap
.
fmap
)
(
IG
.
nodeLab
graph
)
rawClusters
let
clusterLabels
=
(
fmap
.
fmap
)
(
IG
.
nodeLab
graph
)
rawClusters
saveAsFileDebug
"/tmp/res"
clusterLabels
-- log the result
pure
clusterLabels
-- return the result
pure
clusterLabels
-- return the result
...
@@ -80,7 +78,8 @@ edgeList2UGraph edgeList =
...
@@ -80,7 +78,8 @@ edgeList2UGraph edgeList =
-- Warning: there is no guarantee, as far as I know, that the underlying
-- Warning: there is no guarantee, as far as I know, that the underlying
-- representation of the nodes corresponds to the original `Int`.
-- representation of the nodes corresponds to the original `Int`.
mkGraphUfromEdges
::
[(
Int
,
Int
)]
->
IG
.
Graph
'U
()
()
mkGraphUfromEdges
::
[(
Int
,
Int
)]
->
IG
.
Graph
'U
()
()
mkGraphUfromEdges
es
=
IG
.
mkGraph
(
List
.
replicate
n
()
)
$
zip
es
$
repeat
()
mkGraphUfromEdges
es
=
IG
.
mkGraph
(
List
.
replicate
n
()
)
$
fmap
makeLEdge
es
where
where
(
a
,
b
)
=
List
.
unzip
es
makeLEdge
e
=
(
e
,
()
)
n
=
List
.
length
(
List
.
nub
$
a
<>
b
)
n
=
Set
.
size
nodes
nodes
=
Set
.
fromList
$
map
fst
es
src/Gargantext/Core/Viz/Graph/Utils.hs
View file @
612e9aad
...
@@ -23,7 +23,7 @@ import Data.Matrix hiding (identity)
...
@@ -23,7 +23,7 @@ import Data.Matrix hiding (identity)
import
Data.Set
qualified
as
Set
import
Data.Set
qualified
as
Set
import
Data.Vector
(
Vector
)
import
Data.Vector
(
Vector
)
import
Data.Vector
qualified
as
Vector
import
Data.Vector
qualified
as
Vector
import
Gargantext.Core.Text.Metrics.Count
(
occurrencesSimple
)
import
Gargantext.Core.Text.Metrics.Count
(
countOccurrences
)
import
Gargantext.Prelude
import
Gargantext.Prelude
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -88,7 +88,7 @@ nodesFilter f m = (m', toKeep)
...
@@ -88,7 +88,7 @@ nodesFilter f m = (m', toKeep)
toKeep
=
Set
.
fromList
toKeep
=
Set
.
fromList
$
Map
.
keys
$
Map
.
keys
$
Map
.
filter
f
$
Map
.
filter
f
$
occurrencesSimple
$
countOccurrences
$
tupleConcat
$
tupleConcat
$
List
.
unzip
$
List
.
unzip
$
Map
.
keys
m
$
Map
.
keys
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