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

[FEAT] adding nbContexts in result of CLI cooc count by Year.

parent c077b02c
...@@ -65,13 +65,16 @@ import Gargantext.Text.Metrics.Count (coocOnContexts, Coocs) ...@@ -65,13 +65,16 @@ import Gargantext.Text.Metrics.Count (coocOnContexts, Coocs)
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- OUTPUT format -- OUTPUT format
data CoocByYear = CoocByYear { year :: Int data CoocByYear = CoocByYear { year :: Int
, nbContexts :: NbContexts
, coocurrences :: Map (Text, Text) Coocs , coocurrences :: Map (Text, Text) Coocs
} deriving (Show, Generic) } deriving (Show, Generic)
data CoocByYears = CoocByYears { years :: [CoocByYear] } data CoocByYears = CoocByYears { years :: [CoocByYear] }
deriving (Show, Generic) deriving (Show, Generic)
type NbContexts = Int
instance ToJSON CoocByYear instance ToJSON CoocByYear
instance ToJSON CoocByYears instance ToJSON CoocByYears
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -84,7 +87,7 @@ filterTermsAndCooc patterns (year, ts) = do ...@@ -84,7 +87,7 @@ filterTermsAndCooc patterns (year, ts) = do
log "start" log "start"
r <- coocOnContexts identity <$> mapM (\x -> {-log "work" >>-} terms' patterns x) ts r <- coocOnContexts identity <$> mapM (\x -> {-log "work" >>-} terms' patterns x) ts
log "stop" log "stop"
pure $ CoocByYear year (DM.mapKeys (both DT.unwords) r) pure $ CoocByYear year (length ts) (DM.mapKeys (both DT.unwords) r)
where where
log m = do log m = do
......
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