]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/Node_NodeNgramsNodeNgrams.hs
Merge branch 'dev-doc-annotation-issue' of ssh://gitlab.iscpif.fr:20022/gargantext...
[gargantext.git] / src / Gargantext / Database / Schema / Node_NodeNgramsNodeNgrams.hs
1 {-|
2 Module : Gargantext.Database.Schema.Node_NodeNgrams_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 lgrams: listed ngrams
11
12 Node_NodeNgrams_NodeNgrams table is used to group ngrams
13 - first NodeId :: Referential / space node (corpus)
14 - NodeNgrams where Node is List
15 - lgrams1_id, lgrams2_id where all lgrams2_id will be added to lgrams1_id
16 - weight: score the relation
17
18 Next Step benchmark:
19 - recursive queries of postgres
20 - group with: https://en.wikipedia.org/wiki/Nested_set_model
21
22 -}
23
24 {-# OPTIONS_GHC -fno-warn-orphans #-}
25
26 {-# LANGUAGE Arrows #-}
27 {-# LANGUAGE FunctionalDependencies #-}
28 {-# LANGUAGE QuasiQuotes #-}
29 {-# LANGUAGE TemplateHaskell #-}
30
31 module Gargantext.Database.Schema.Node_NodeNgramsNodeNgrams
32 where
33
34 import Control.Lens.TH (makeLensesWith, abbreviatedFields)
35 import Data.Maybe (Maybe)
36 import Gargantext.Database.Schema.Prelude
37 import Gargantext.Database.Admin.Types.Node (CorpusId)
38 import Gargantext.Database.Schema.Node()
39 import Gargantext.Prelude
40
41 data Node_NodeNgrams_NodeNgrams_Poly node_id nng1_id nng2_id weight =
42 Node_NodeNgrams_NodeNgrams { _nnn_node_id :: !node_id
43 , _nnn_nng1_id :: !nng1_id
44 , _nnn_nng2_id :: !nng2_id
45 , _nnn_weight :: !weight
46 } deriving (Show)
47
48 type Node_NodeNgrams_NodeNgrams_Write =
49 Node_NodeNgrams_NodeNgrams_Poly
50 (Column PGInt4 )
51 (Maybe (Column PGInt4 ))
52 (Column PGInt4 )
53 (Maybe (Column PGFloat8))
54
55 type Node_NodeNgrams_NodeNgrams_Read =
56 Node_NodeNgrams_NodeNgrams_Poly
57 (Column PGInt4 )
58 (Column PGInt4 )
59 (Column PGInt4 )
60 (Column PGFloat8)
61
62 type ListNgramsId = Int
63
64 type Node_NodeNgrams_NodeNgrams =
65 Node_NodeNgrams_NodeNgrams_Poly CorpusId (Maybe ListNgramsId) ListNgramsId (Maybe Double)
66
67 $(makeAdaptorAndInstance "pNode_NodeNgrams_NodeNgrams"
68 ''Node_NodeNgrams_NodeNgrams_Poly)
69 $(makeLensesWith abbreviatedFields
70 ''Node_NodeNgrams_NodeNgrams_Poly)
71
72
73 node_NodeNgrams_NodeNgrams_Table :: Table Node_NodeNgrams_NodeNgrams_Write Node_NodeNgrams_NodeNgrams_Read
74 node_NodeNgrams_NodeNgrams_Table =
75 Table "node_nodengrams_nodengrams"
76 ( pNode_NodeNgrams_NodeNgrams Node_NodeNgrams_NodeNgrams
77 { _nnn_node_id = required "node_id"
78 , _nnn_nng1_id = optional "node_ngrams1_id"
79 , _nnn_nng2_id = required "node_ngrams2_id"
80 , _nnn_weight = optional "weight"
81 }
82 )
83
84 instance QueryRunnerColumnDefault PGInt4 (Maybe Int) where
85 queryRunnerColumnDefault = fieldQueryRunnerColumn
86
87 instance QueryRunnerColumnDefault PGFloat8 (Maybe Double) where
88 queryRunnerColumnDefault = fieldQueryRunnerColumn
89