]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NodeNgrams.hs
Merge remote-tracking branch 'origin/445-dev-doc-upload-lang' into dev
[gargantext.git] / src / Gargantext / Database / Schema / NodeNgrams.hs
1 {-|
2 Module : Gargantext.Database.Schema.NodeNgrams
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 NodeNgrams register Context of Ngrams (named Cgrams then)
11
12 -}
13
14 {-# OPTIONS_GHC -fno-warn-orphans #-}
15
16 {-# LANGUAGE Arrows #-}
17 {-# LANGUAGE FunctionalDependencies #-}
18 {-# LANGUAGE QuasiQuotes #-}
19 {-# LANGUAGE TemplateHaskell #-}
20
21 module Gargantext.Database.Schema.NodeNgrams where
22
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
28
29
30 data NodeNgramsPoly id
31 node_id'
32 node_subtype
33 ngrams_id
34 ngrams_type
35 ngrams_field
36 ngrams_tag
37 ngrams_class
38 weight
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)
49
50
51 type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (SqlInt4)))
52 (Column (SqlInt4))
53 (Maybe (Column (SqlInt4)))
54 (Column (SqlInt4))
55 (Maybe (Column (SqlInt4)))
56 (Maybe (Column (SqlInt4)))
57 (Maybe (Column (SqlInt4)))
58 (Maybe (Column (SqlInt4)))
59 (Maybe (Column (SqlFloat8)))
60
61 type NodeNgramsRead = NodeNgramsPoly (Column SqlInt4)
62 (Column SqlInt4)
63 (Column SqlInt4)
64 (Column SqlInt4)
65 (Column SqlInt4)
66 (Column SqlInt4)
67 (Column SqlInt4)
68 (Column SqlInt4)
69 (Column SqlFloat8)
70
71
72 type NodeNgramsReadNull = NodeNgramsPoly (Column (Nullable SqlInt4))
73 (Column (Nullable SqlInt4))
74 (Column (Nullable SqlInt4))
75 (Column (Nullable SqlInt4))
76
77 (Column (Nullable SqlInt4))
78 (Column (Nullable SqlInt4))
79 (Column (Nullable SqlInt4))
80 (Column (Nullable SqlInt4))
81 (Column (Nullable SqlFloat8))
82 type NodeNgramsId = Int
83 type NgramsField = Int
84 type NgramsTag = Int
85 type NgramsClass = Int
86 type NgramsText = Text
87
88 -- Example of list Ngrams
89 -- type ListNgrams = NodeNgramsPoly (Maybe Int) ListType Text
90
91 type NodeNgramsW =
92 NodeNgramsPoly (Maybe NodeNgramsId) NodeId ListType NgramsText
93 NgramsType (Maybe NgramsField) (Maybe NgramsTag) (Maybe NgramsClass)
94 Double
95
96 $(makeAdaptorAndInstance "pNodeNgrams" ''NodeNgramsPoly)
97 makeLenses ''NodeNgramsPoly
98
99 nodeNgramsTable :: Table NodeNgramsWrite NodeNgramsRead
100 nodeNgramsTable =
101 Table "node_ngrams"
102 ( pNodeNgrams
103 NodeNgrams { _nng_id = optionalTableField "id"
104 , _nng_node_id = requiredTableField "node_id"
105 , _nng_node_subtype = optionalTableField "node_subtype"
106 , _nng_ngrams_id = requiredTableField "ngrams_id"
107 , _nng_ngrams_type = optionalTableField "ngrams_type"
108 , _nng_ngrams_field = optionalTableField "ngrams_field"
109 , _nng_ngrams_tag = optionalTableField "ngrams_tag"
110 , _nng_ngrams_class = optionalTableField "ngrams_class"
111 , _nng_ngrams_weight = optionalTableField "weight"
112 }
113 )