2 Module : Gargantext.Database.Schema.NodeNgrams
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 NodeNgrams register Context of Ngrams (named Cgrams then)
14 {-# OPTIONS_GHC -fno-warn-orphans #-}
16 {-# LANGUAGE Arrows #-}
17 {-# LANGUAGE FlexibleContexts #-}
18 {-# LANGUAGE FlexibleInstances #-}
19 {-# LANGUAGE FunctionalDependencies #-}
20 {-# LANGUAGE QuasiQuotes #-}
21 {-# LANGUAGE MultiParamTypeClasses #-}
22 {-# LANGUAGE NoImplicitPrelude #-}
23 {-# LANGUAGE OverloadedStrings #-}
24 {-# LANGUAGE RankNTypes #-}
25 {-# LANGUAGE TemplateHaskell #-}
27 module Gargantext.Database.Schema.NodeNgrams where
29 import Data.List.Extra (nubOrd)
31 import Data.Maybe (Maybe, fromMaybe)
32 import Data.Text (Text)
33 import Gargantext.Database.Schema.Prelude
34 import Gargantext.Core.Types
35 import Gargantext.Database.Admin.Utils
36 import Gargantext.Database.Schema.Ngrams (NgramsType, ngramsTypeId, fromNgramsTypeId)
37 import Gargantext.Prelude
38 import qualified Data.List as List
39 import qualified Data.Map as Map
42 data NodeNgramsPoly id
51 = NodeNgrams { _nng_id :: !id
52 , _nng_node_id :: !node_id'
53 , _nng_node_subtype :: !node_subtype
54 , _nng_ngrams_id :: !ngrams_id
55 , _nng_ngrams_type :: !ngrams_type
56 , _nng_ngrams_field :: !ngrams_field
57 , _nng_ngrams_tag :: !ngrams_tag
58 , _nng_ngrams_class :: !ngrams_class
59 , _nng_ngrams_weight :: !weight
60 } deriving (Show, Eq, Ord)
63 type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (PGInt4)))
65 (Maybe (Column (PGInt4)))
67 (Maybe (Column (PGInt4)))
68 (Maybe (Column (PGInt4)))
69 (Maybe (Column (PGInt4)))
70 (Maybe (Column (PGInt4)))
71 (Maybe (Column (PGFloat8)))
73 type NodeNodeRead = NodeNgramsPoly (Column PGInt4)
83 type NodeNgramsReadNull = NodeNgramsPoly (Column (Nullable PGInt4))
84 (Column (Nullable PGInt4))
85 (Column (Nullable PGInt4))
86 (Column (Nullable PGInt4))
88 (Column (Nullable PGInt4))
89 (Column (Nullable PGInt4))
90 (Column (Nullable PGInt4))
91 (Column (Nullable PGInt4))
92 (Column (Nullable PGFloat8))
94 type NodeNgramsId = Int
96 type NgramsField = Int
98 type NgramsClass = Int
99 type NgramsText = Text
101 -- Example of list Ngrams
102 -- type ListNgrams = NodeNgramsPoly (Maybe Int) ListType Text
105 NodeNgramsPoly (Maybe NodeNgramsId) NodeId ListType NgramsText
106 NgramsType (Maybe NgramsField) (Maybe NgramsTag) (Maybe NgramsClass)