2 Module : Gargantext.API.Ngrams
3 Description : Server API
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
13 -- get data of NgramsTable
14 -- post :: update NodeNodeNgrams
17 get ngrams filtered by NgramsType
22 {-# LANGUAGE DeriveGeneric #-}
23 {-# LANGUAGE NoImplicitPrelude #-}
24 {-# LANGUAGE OverloadedStrings #-}
25 {-# LANGUAGE TemplateHaskell #-}
26 {-# LANGUAGE FlexibleInstances #-}
28 module Gargantext.API.Ngrams
31 import Data.Aeson (FromJSON, ToJSON)
32 import Data.Aeson.TH (deriveJSON)
34 import Data.Map.Strict (Map)
35 import Data.Map.Strict.Patch (Patch, apply, transformWith)
36 import Data.Text (Text)
38 import GHC.Generics (Generic)
40 import Gargantext.Database.Ngram (NgramsId)
41 import Gargantext.Database.User (UserId)
42 import Gargantext.Core.Types (ListType(..))
43 import Gargantext.Core.Types.Main (Tree(..))
44 import Gargantext.Core.Utils.Prefix (unPrefix)
45 import Gargantext.Prelude
48 NgramsElement { _ne_id :: Int
50 , _ne_list :: ListType
52 $(deriveJSON (unPrefix "_ne_") ''NgramsElement)
55 data NgramsTable = NgramsTable { _ngramsTable :: [Tree NgramsElement] }
58 instance ToJSON NgramsTable
59 instance FromJSON NgramsTable
61 instance FromJSON (Tree NgramsElement)
63 instance ToJSON (Tree NgramsElement)
65 --data Action = InGroup NgramsId NgramsId
66 -- | OutGroup NgramsId NgramsId
67 -- | SetListType NgramsId ListType
70 NgramsPatch { list_types :: Map UserId ListType
71 , add_children :: Set NgramsId
72 , rem_children :: Set NgramsId
75 data Patch = Map NgramsId NgramsPatch
77 -- applyPatchBack :: Patch -> IO Patch
78 -- isEmptyPatch = Map.all (\x -> Set.isEmpty (add_children x) && Set.isEmpty ... )
80 -------------------------------------------------------------------
81 -------------------------------------------------------------------
82 -------------------------------------------------------------------