Commit da402977 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Cooc with diagonal (or not).

parent 1f520fdb
......@@ -84,14 +84,17 @@ groupNodesByNgrams syn occs = Map.fromListWith (<>) occs'
Nothing -> (t, ns)
Just r' -> (r',ns)
type Diagonal = Bool
getCoocByNgrams :: Map Text (Set NodeId) -> Map (Text, Text) Int
getCoocByNgrams m =
getCoocByNgrams :: Diagonal -> Map Text (Set NodeId) -> Map (Text, Text) Int
getCoocByNgrams diag m =
Map.fromList [((t1,t2)
,maybe 0 Set.size $ Set.intersection
<$> Map.lookup t1 m
<*> Map.lookup t2 m
) | (t1,t2) <- [ (x,y) | x <- Map.keys m, y <- Map.keys m, x <= y]
) | (t1,t2) <- case diag of
True -> [ (x,y) | x <- Map.keys m, y <- Map.keys m, x <= y]
False -> listToCombi identity (Map.keys m)
]
......@@ -289,7 +289,7 @@ graphAPI nId = do
lId <- defaultList cId
ngs <- filterListWithRoot GraphTerm <$> mapTermListRoot [lId] NgramsTerms
myCooc <- Map.filter (>1) <$> getCoocByNgrams
myCooc <- Map.filter (>1) <$> getCoocByNgrams False
<$> groupNodesByNgrams ngs
<$> getNodesByNgramsOnlyUser cId NgramsTerms (Map.keys ngs)
......@@ -405,7 +405,7 @@ getMetrics cId maybeListId maybeTabType maybeLimit = do
let ngs = Map.unions $ map (\t -> filterListWithRoot t ngs')
[GraphTerm, StopTerm, CandidateTerm]
myCooc <- Map.filter (>1) <$> getCoocByNgrams
myCooc <- Map.filter (>1) <$> getCoocByNgrams True
<$> groupNodesByNgrams ngs
<$> getNodesByNgramsOnlyUser cId ngramsType (Map.keys ngs)
......@@ -421,4 +421,3 @@ getMetrics cId maybeListId maybeTabType maybeLimit = do
pure $ Metrics metricsFiltered
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