1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{-|
Module : Gargantext.Database.Schema.NodeNgrams
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
NodeNgrams register Context of Ngrams (named Cgrams then)
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module Gargantext.Database.Schema.NodeNgrams where
import Gargantext.Core.Text.Ngrams (NgramsType)
import Gargantext.Core.Types.Main ( ListType )
import Gargantext.Database.Admin.Types.Node ( NodeId )
import Gargantext.Database.Schema.Prelude
import Gargantext.Prelude
data NodeNgramsPoly id
node_id'
node_subtype
ngrams_id
ngrams_type
ngrams_field
ngrams_tag
ngrams_class
weight
= NodeNgrams { _nng_id :: !id
, _nng_node_id :: !node_id'
, _nng_node_subtype :: !node_subtype
, _nng_ngrams_id :: !ngrams_id
, _nng_ngrams_type :: !ngrams_type
, _nng_ngrams_field :: !ngrams_field
, _nng_ngrams_tag :: !ngrams_tag
, _nng_ngrams_class :: !ngrams_class
, _nng_ngrams_weight :: !weight
} deriving (Show, Eq, Ord)
type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (SqlInt4)))
(Column (SqlInt4))
(Maybe (Column (SqlInt4)))
(Column (SqlInt4))
(Maybe (Column (SqlInt4)))
(Maybe (Column (SqlInt4)))
(Maybe (Column (SqlInt4)))
(Maybe (Column (SqlInt4)))
(Maybe (Column (SqlFloat8)))
type NodeNgramsRead = NodeNgramsPoly (Column SqlInt4)
(Column SqlInt4)
(Column SqlInt4)
(Column SqlInt4)
(Column SqlInt4)
(Column SqlInt4)
(Column SqlInt4)
(Column SqlInt4)
(Column SqlFloat8)
type NodeNgramsId = Int
type NgramsField = Int
type NgramsTag = Int
type NgramsClass = Int
type NgramsText = Text
-- Example of list Ngrams
-- type ListNgrams = NodeNgramsPoly (Maybe Int) ListType Text
type NodeNgramsW =
NodeNgramsPoly (Maybe NodeNgramsId) NodeId ListType NgramsText
NgramsType (Maybe NgramsField) (Maybe NgramsTag) (Maybe NgramsClass)
Double
$(makeAdaptorAndInstance "pNodeNgrams" ''NodeNgramsPoly)
makeLenses ''NodeNgramsPoly
nodeNgramsTable :: Table NodeNgramsWrite NodeNgramsRead
nodeNgramsTable =
Table "node_ngrams"
( pNodeNgrams
NodeNgrams { _nng_id = optionalTableField "id"
, _nng_node_id = requiredTableField "node_id"
, _nng_node_subtype = optionalTableField "node_subtype"
, _nng_ngrams_id = requiredTableField "ngrams_id"
, _nng_ngrams_type = optionalTableField "ngrams_type"
, _nng_ngrams_field = optionalTableField "ngrams_field"
, _nng_ngrams_tag = optionalTableField "ngrams_tag"
, _nng_ngrams_class = optionalTableField "ngrams_class"
, _nng_ngrams_weight = optionalTableField "weight"
}
)