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 FunctionalDependencies #-}
18 {-# LANGUAGE QuasiQuotes #-}
19 {-# LANGUAGE TemplateHaskell #-}
21 module Gargantext.Database.Schema.NodeNgrams where
23 import Data.Text (Text)
24 import Gargantext.Core.Types
25 import Gargantext.Database.Schema.Ngrams (NgramsType)
26 import Gargantext.Database.Schema.Prelude
27 import Gargantext.Prelude
30 data NodeNgramsPoly id
39 = NodeNgrams { _nng_id :: !id
40 , _nng_node_id :: !node_id'
41 , _nng_node_subtype :: !node_subtype
42 , _nng_ngrams_id :: !ngrams_id
43 , _nng_ngrams_type :: !ngrams_type
44 , _nng_ngrams_field :: !ngrams_field
45 , _nng_ngrams_tag :: !ngrams_tag
46 , _nng_ngrams_class :: !ngrams_class
47 , _nng_ngrams_weight :: !weight
48 } deriving (Show, Eq, Ord)
51 type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (SqlInt4)))
53 (Maybe (Column (SqlInt4)))
55 (Maybe (Column (SqlInt4)))
56 (Maybe (Column (SqlInt4)))
57 (Maybe (Column (SqlInt4)))
58 (Maybe (Column (SqlInt4)))
59 (Maybe (Column (SqlFloat8)))
61 type NodeNgramsRead = NodeNgramsPoly (Column SqlInt4)
71 type NodeNgramsId = Int
72 type NgramsField = Int
74 type NgramsClass = Int
75 type NgramsText = Text
77 -- Example of list Ngrams
78 -- type ListNgrams = NodeNgramsPoly (Maybe Int) ListType Text
81 NodeNgramsPoly (Maybe NodeNgramsId) NodeId ListType NgramsText
82 NgramsType (Maybe NgramsField) (Maybe NgramsTag) (Maybe NgramsClass)
85 $(makeAdaptorAndInstance "pNodeNgrams" ''NodeNgramsPoly)
86 makeLenses ''NodeNgramsPoly
88 nodeNgramsTable :: Table NodeNgramsWrite NodeNgramsRead
92 NodeNgrams { _nng_id = optionalTableField "id"
93 , _nng_node_id = requiredTableField "node_id"
94 , _nng_node_subtype = optionalTableField "node_subtype"
95 , _nng_ngrams_id = requiredTableField "ngrams_id"
96 , _nng_ngrams_type = optionalTableField "ngrams_type"
97 , _nng_ngrams_field = optionalTableField "ngrams_field"
98 , _nng_ngrams_tag = optionalTableField "ngrams_tag"
99 , _nng_ngrams_class = optionalTableField "ngrams_class"
100 , _nng_ngrams_weight = optionalTableField "weight"