import Control.Concurrent
import Control.Lens ((^.), (+~), (%~), at, (.~), _Just)
import Control.Monad.Reader
-import Data.Map (Map, toList)
+import Data.Map.Strict (Map, toList)
import Data.Text (Text)
import Gargantext.API.Ngrams (saveNodeStory)
import Gargantext.API.Ngrams.Tools (getNodeStoryVar)
import Gargantext.Database.Schema.Ngrams (NgramsType(..))
import Gargantext.Prelude
import qualified Data.List as List
-import qualified Data.Map as Map
+import qualified Data.Map.Strict as Map
import qualified Data.Map.Strict.Patch as PM
import qualified Gargantext.Database.Query.Table.Ngrams as TableNgrams
-> (NgramsType, [NgramsElement])
-> [NodeNgramsW]
toNodeNgramsW'' l' (ngrams_type, elms) =
- [ NodeNgrams { _nng_id = Nothing
- , _nng_node_id = l'
- , _nng_node_subtype = list_type
- , _nng_ngrams_id = ngrams_terms'
- , _nng_ngrams_type = ngrams_type
- , _nng_ngrams_field = Nothing
- , _nng_ngrams_tag = Nothing
- , _nng_ngrams_class = Nothing
+ [ NodeNgrams { _nng_id = Nothing
+ , _nng_node_id = l'
+ , _nng_node_subtype = list_type
+ , _nng_ngrams_id = ngrams_terms'
+ , _nng_ngrams_type = ngrams_type
+ , _nng_ngrams_field = Nothing
+ , _nng_ngrams_tag = Nothing
+ , _nng_ngrams_class = Nothing
, _nng_ngrams_weight = 0 } |
- (NgramsElement { _ne_ngrams = NgramsTerm ngrams_terms'
- , _ne_size = _size
- , _ne_list = list_type
+ (NgramsElement { _ne_ngrams = NgramsTerm ngrams_terms'
+ , _ne_size = _size
+ , _ne_list = list_type
, _ne_occurrences = _occ
- , _ne_root = _root
- , _ne_parent = _parent
- , _ne_children = _children }) <- elms
+ , _ne_root = _root
+ , _ne_parent = _parent
+ , _ne_children = _children
+ }
+ ) <- elms
]
toNodeNgramsW' :: ListId
-> [(Text, [NgramsType])]
-> [NodeNgramsW]
-toNodeNgramsW' l'' ngs = [ NodeNgrams { _nng_id = Nothing
- , _nng_node_id = l''
- , _nng_node_subtype = CandidateTerm
- , _nng_ngrams_id = terms
- , _nng_ngrams_type = ngrams_type
- , _nng_ngrams_field = Nothing
- , _nng_ngrams_tag = Nothing
- , _nng_ngrams_class = Nothing
- , _nng_ngrams_weight = 0 }
+toNodeNgramsW' l'' ngs = [ NodeNgrams { _nng_id = Nothing
+ , _nng_node_id = l''
+ , _nng_node_subtype = CandidateTerm
+ , _nng_ngrams_id = terms
+ , _nng_ngrams_type = ngrams_type
+ , _nng_ngrams_field = Nothing
+ , _nng_ngrams_tag = Nothing
+ , _nng_ngrams_class = Nothing
+ , _nng_ngrams_weight = 0
+ }
| (terms, ngrams_types) <- ngs
, ngrams_type <- ngrams_types
]
& unNodeStory . at listId . _Just . a_history %~ (p :)
& unNodeStory . at listId . _Just . a_state . at ngramsType' .~ Just ns
saveNodeStory
-