Commit 64987614 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

ExtractNgrams on HyperdataContact is in principle pure

parent bd3c38fd
...@@ -40,17 +40,16 @@ import Gargantext.Prelude ...@@ -40,17 +40,16 @@ import Gargantext.Prelude
------------------------------------------------------------------------ ------------------------------------------------------------------------
instance ExtractNgrams HyperdataContact where instance ExtractNgrams HyperdataContact where
extractNgrams _ncs l hc = HashMap.mapKeys (cleanExtractedNgrams 255) <$> extract l hc extractNgrams _ncs _l = pure . HashMap.mapKeys (cleanExtractedNgrams 255) . extract
where where
extract :: TermType Lang extract :: HyperdataContact
-> HyperdataContact -> HashMap.HashMap ExtractedNgrams (Map NgramsType TermsWeight, TermsCount)
-> DBCmd err (HashMap.HashMap ExtractedNgrams (Map NgramsType TermsWeight, TermsCount)) extract hc' =
extract _l hc' = do
let authors = map text2ngrams let authors = map text2ngrams
$ maybe ["Nothing"] (\a -> [a]) $ maybe ["Nothing"] (\a -> [a])
$ view (hc_who . _Just . cw_lastName) hc' $ view (hc_who . _Just . cw_lastName) hc'
pure $ HashMap.fromList $ [(SimpleNgrams a', (DM.singleton Authors 1, 1)) | a' <- authors ] in HashMap.fromList $ [(SimpleNgrams a', (DM.singleton Authors 1, 1)) | a' <- authors ]
-- | Main ngrams extraction functionality. -- | Main ngrams extraction functionality.
......
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