Commit d069c6ec authored by Grégoire Locqueville's avatar Grégoire Locqueville

Clarification of some functions' role

The `filterNodes` function's name and type signature were confusing, so
they were changed to make it evident that the filtering function for an
antry is applied to its total number of cooccurrences.
parent 612e9aad
Pipeline #7588 passed with stages
in 38 minutes and 48 seconds
Ggtxt.DB.Query.Table.Node: selectNodesWith' (et peut-être selectNodesWith ?) :
Renommer pour clarifier qu'on sélectionne à partir de l'ID du *parent*
Documenter :ggload dans la doc dev
makeSubcorpusFromQuery : traiter le cas où on reuse parent list (implique
probablement d'augmenter la fonction copyNode, voir si je n'ai pas stashé mes
changements qqpart)
Supprimer bin/build qui fait appel à stack (le remplacer par qqch d'autre ?)
Ajouter un bin/repl qui lance cabal repl depuis un nix shell
Faire deux build profiles: niveaux d'optim différents, prints
Éclaircir pk il y a 2 tables qui semblent faire la jointure entre nodes et ngrams :
- nodes_ngrams
- node_stories
Documenter process/branches
Ggtxt.DB.Action.Share : qualifier/spécifier les imports de Ggtxt.Database
Virer Ggtxt.Core.Flow.Types si possible
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -138,11 +138,11 @@ occurrences = occurrencesOn _terms_stem
-- 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
-- into something more descriptive
countOccurrences :: (Foldable f, Ord a, Num n)
=> f a -- ^ The collection whose items will be counted
-> Map a n -- ^ A map whose keys are items of the input
-- collection, and whose values are the number of
-- times those items appear in the input collection
countOccurrences :: (Foldable f, Ord a)
=> f a -- ^ The collection whose items will be counted
-> Map a Int -- ^ A map whose keys are items of the input
-- collection, and whose values are the number of
-- times those items appear in the input collection
countOccurrences collection =
foldl' (\occurenceMap item -> insertWith (+) item 1 occurenceMap)
empty
......
......@@ -33,7 +33,7 @@ import Gargantext.Core.Viz.Graph.Bridgeness (bridgeness, nodeId2comId, setNodes2
import Gargantext.Core.Viz.Graph.Index (createIndices, toIndex, map2mat, mat2map, Index, MatrixShape(..))
import Gargantext.Core.Viz.Graph.Tools.IGraph (mkGraphUfromEdges, spinglass)
import Gargantext.Core.Viz.Graph.Types (Attributes(..), BridgenessMethod, Edge(..), Graph(..), MultiPartite(..), Node(..), Partite(..), Strength(..), LegendField(..))
import Gargantext.Core.Viz.Graph.Utils (edgesFilter, nodesFilter)
import Gargantext.Core.Viz.Graph.Utils (edgesFilter, filterNodesByCount)
import Gargantext.Prelude
import Graph.BAC.ProxemyOptim qualified as BAC
import Graph.Types (ClusterNode(..))
......@@ -189,7 +189,7 @@ data2graph multi labels' occurences bridge conf partitions =
]
-- Remove vertices not connected to any other node, i.e. vertices that have
-- zero edge joining them to other vertices
(bridge', toKeep) = nodesFilter (> 0) bridge
(bridge', toKeep) = filterNodesByCount (> 0) bridge
edges = [ Edge { edge_source = show s
, edge_hidden = Nothing
......
......@@ -81,8 +81,17 @@ edgesFilter m = Map.fromList $ catMaybes results
keys = Set.toList $ Set.fromList (x <> y)
(x,y) = unzip $ Map.keys m
nodesFilter :: (Show a, Show b, Ord a, Ord b, Num b) => (b -> Bool) -> Map (a,a) b -> (Map (a,a) b, Set a)
nodesFilter f m = (m', toKeep)
-- | Filter nodes depending on how many times they (co)occur.
-- More specifically, for a given value `x :: a`, this sums all entries in the
-- map that have `x` as a value, and then it filters by applying `f` to the sum.
-- Warning: This counts the value at `(x, x)` twice.
filterNodesByCount :: (Show node, Ord node)
=> (Int -> Bool) -- ^ Filtering function
-> Map (node, node) b -- ^ Input map
-> (Map (node, node) b, Set node)
-- ^ The map without the filtered out nodes, and the set of
-- remaining nodes
filterNodesByCount f m = (m', toKeep)
where
m' = Map.filterWithKey (\(a,b) _ -> Set.member a toKeep && Set.member b toKeep) m
toKeep = Set.fromList
......
File added
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment