]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/ContextNodeNgrams.hs
[ngrams] first version of ngrams counting in docs
[gargantext.git] / src / Gargantext / Database / Schema / ContextNodeNgrams.hs
1 {-|
2 Module : Gargantext.Database.Schema.NodeNodeNgrams
3 Description : TODO: remove this module and table in database
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# OPTIONS_GHC -fno-warn-orphans #-}
13
14 {-# LANGUAGE Arrows #-}
15 {-# LANGUAGE FunctionalDependencies #-}
16 {-# LANGUAGE TemplateHaskell #-}
17
18 module Gargantext.Database.Schema.ContextNodeNgrams
19 where
20
21 import Prelude
22 import Gargantext.Core.Types (TermsCount)
23 import Gargantext.Database.Schema.Prelude
24 import Gargantext.Database.Schema.Ngrams (NgramsTypeId, NgramsId)
25 import Gargantext.Database.Admin.Types.Node
26
27
28
29 type ContextNodeNgrams =
30 ContextNodeNgramsPoly ContextId ListId NgramsId NgramsTypeId Double TermsCount
31
32
33 data ContextNodeNgramsPoly c n ngrams_id ngt w dc
34 = ContextNodeNgrams { _cnng_context_id :: !c
35 , _cnng_node_id :: !n
36 , _cnng_ngrams_id :: !ngrams_id
37 , _cnng_ngramsType :: !ngt
38 , _cnng_weight :: !w
39 , _cnng_doc_count :: !dc
40 } deriving (Show)
41
42 type ContextNodeNgramsWrite =
43 ContextNodeNgramsPoly (Column SqlInt4 )
44 (Column SqlInt4 )
45 (Column SqlInt4 )
46 (Column SqlInt4 )
47 (Column SqlFloat8)
48 (Column SqlInt4 )
49
50 type ContextNodeNgramsRead =
51 ContextNodeNgramsPoly (Column SqlInt4 )
52 (Column SqlInt4 )
53 (Column SqlInt4 )
54 (Column SqlInt4 )
55 (Column SqlFloat8)
56 (Column SqlInt4 )
57
58 type ContextNodeNgramsReadNull =
59 ContextNodeNgramsPoly (Column (Nullable SqlInt4 ))
60 (Column (Nullable SqlInt4 ))
61 (Column (Nullable SqlInt4 ))
62 (Column (Nullable SqlInt4 ))
63 (Column (Nullable SqlFloat8))
64 (Column (Nullable SqlInt4 ))
65
66 $(makeAdaptorAndInstance "pContextNodeNgrams" ''ContextNodeNgramsPoly)
67 makeLenses ''ContextNodeNgramsPoly
68
69
70 contextNodeNgramsTable :: Table ContextNodeNgramsWrite ContextNodeNgramsRead
71 contextNodeNgramsTable = Table "context_node_ngrams"
72 ( pContextNodeNgrams ContextNodeNgrams
73 { _cnng_context_id = requiredTableField "context_id"
74 , _cnng_node_id = requiredTableField "node_id"
75 , _cnng_ngrams_id = requiredTableField "ngrams_id"
76 , _cnng_ngramsType = requiredTableField "ngrams_type"
77 , _cnng_weight = requiredTableField "weight"
78 , _cnng_doc_count = requiredTableField "doc_count"
79 }
80 )