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
------------------------------------------------------------------------
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
extract :: TermType Lang
-> HyperdataContact
-> DBCmd err (HashMap.HashMap ExtractedNgrams (Map NgramsType TermsWeight, TermsCount))
extract _l hc' = do
extract :: HyperdataContact
-> HashMap.HashMap ExtractedNgrams (Map NgramsType TermsWeight, TermsCount)
extract hc' =
let authors = map text2ngrams
$ maybe ["Nothing"] (\a -> [a])
$ 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.
......
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