]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/NodeNgram.hs
[GRAPH] Old graph format of gargantext utils to convert.
[gargantext.git] / src / Gargantext / Database / NodeNgram.hs
1 {-|
2 Module : Gargantext.Database.NodeNgram
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 Here is a longer description of this module, containing some
11 commentary with @some markup@.
12 -}
13
14 {-# OPTIONS_GHC -fno-warn-orphans #-}
15
16 {-# LANGUAGE Arrows #-}
17 {-# LANGUAGE FlexibleInstances #-}
18 {-# LANGUAGE FunctionalDependencies #-}
19 {-# LANGUAGE MultiParamTypeClasses #-}
20 {-# LANGUAGE NoImplicitPrelude #-}
21 {-# LANGUAGE TemplateHaskell #-}
22
23
24 module Gargantext.Database.NodeNgram where
25
26 import Prelude
27 import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
28 import Control.Lens.TH (makeLensesWith, abbreviatedFields)
29
30 import Opaleye
31
32 data NodeNgramPoly id node_id ngram_id weight
33 = NodeNgram { nodeNgram_NodeNgramId :: id
34 , nodeNgram_NodeNgramNodeId :: node_id
35 , nodeNgram_NodeNgramNgramId :: ngram_id
36 , nodeNgram_NodeNgramWeight :: weight
37 } deriving (Show)
38
39 type NodeNgramWrite = NodeNgramPoly (Column PGInt4 )
40 (Column PGInt4 )
41 (Column PGInt4 )
42 (Column PGFloat8)
43
44 type NodeNgramRead = NodeNgramPoly (Column PGInt4 )
45 (Column PGInt4 )
46 (Column PGInt4 )
47 (Column PGFloat8)
48
49 type NodeNgram = NodeNgramPoly Int Int Int Double
50
51 $(makeAdaptorAndInstance "pNodeNgram" ''NodeNgramPoly)
52 $(makeLensesWith abbreviatedFields ''NodeNgramPoly)
53
54
55 nodeNgramTable :: Table NodeNgramWrite NodeNgramRead
56 nodeNgramTable = Table "nodes_ngrams" ( pNodeNgram NodeNgram
57 { nodeNgram_NodeNgramId = required "id"
58 , nodeNgram_NodeNgramNodeId = required "node_id"
59 , nodeNgram_NodeNgramNgramId = required "ngram_id"
60 , nodeNgram_NodeNgramWeight = required "weight"
61 }
62 )
63
64 queryNodeNgramTable :: Query NodeNgramRead
65 queryNodeNgramTable = queryTable nodeNgramTable
66