]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NodeNgrams.hs
[DB/FACTO/WIP] G.D.S.Prelude
[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 FlexibleContexts #-}
18 {-# LANGUAGE FlexibleInstances #-}
19 {-# LANGUAGE FunctionalDependencies #-}
20 {-# LANGUAGE QuasiQuotes #-}
21 {-# LANGUAGE MultiParamTypeClasses #-}
22 {-# LANGUAGE NoImplicitPrelude #-}
23 {-# LANGUAGE OverloadedStrings #-}
24 {-# LANGUAGE RankNTypes #-}
25 {-# LANGUAGE TemplateHaskell #-}
26
27 module Gargantext.Database.Schema.NodeNgrams where
28
29 import Data.List.Extra (nubOrd)
30 import Data.Map (Map)
31 import Data.Maybe (Maybe, fromMaybe)
32 import Data.Text (Text)
33 import Gargantext.Database.Schema.Prelude
34 import Gargantext.Core.Types
35 import Gargantext.Database.Admin.Utils
36 import Gargantext.Database.Schema.Ngrams (NgramsType, ngramsTypeId, fromNgramsTypeId)
37 import Gargantext.Prelude
38 import qualified Data.List as List
39 import qualified Data.Map as Map
40
41
42 data NodeNgramsPoly id
43 node_id'
44 node_subtype
45 ngrams_id
46 ngrams_type
47 ngrams_field
48 ngrams_tag
49 ngrams_class
50 weight
51 = NodeNgrams { _nng_id :: !id
52 , _nng_node_id :: !node_id'
53 , _nng_node_subtype :: !node_subtype
54 , _nng_ngrams_id :: !ngrams_id
55 , _nng_ngrams_type :: !ngrams_type
56 , _nng_ngrams_field :: !ngrams_field
57 , _nng_ngrams_tag :: !ngrams_tag
58 , _nng_ngrams_class :: !ngrams_class
59 , _nng_ngrams_weight :: !weight
60 } deriving (Show, Eq, Ord)
61
62 {-
63 type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (PGInt4)))
64 (Column (PGInt4))
65 (Maybe (Column (PGInt4)))
66 (Column (PGInt4))
67 (Maybe (Column (PGInt4)))
68 (Maybe (Column (PGInt4)))
69 (Maybe (Column (PGInt4)))
70 (Maybe (Column (PGInt4)))
71 (Maybe (Column (PGFloat8)))
72
73 type NodeNodeRead = NodeNgramsPoly (Column PGInt4)
74 (Column PGInt4)
75 (Column PGInt4)
76 (Column PGInt4)
77 (Column PGInt4)
78 (Column PGInt4)
79 (Column PGInt4)
80 (Column PGInt4)
81 (Column PGFloat8)
82
83 type NodeNgramsReadNull = NodeNgramsPoly (Column (Nullable PGInt4))
84 (Column (Nullable PGInt4))
85 (Column (Nullable PGInt4))
86 (Column (Nullable PGInt4))
87
88 (Column (Nullable PGInt4))
89 (Column (Nullable PGInt4))
90 (Column (Nullable PGInt4))
91 (Column (Nullable PGInt4))
92 (Column (Nullable PGFloat8))
93 -}
94 type NodeNgramsId = Int
95 type NgramsId = Int
96 type NgramsField = Int
97 type NgramsTag = Int
98 type NgramsClass = Int
99 type NgramsText = Text
100
101 -- Example of list Ngrams
102 -- type ListNgrams = NodeNgramsPoly (Maybe Int) ListType Text
103
104 type NodeNgramsW =
105 NodeNgramsPoly (Maybe NodeNgramsId) NodeId ListType NgramsText
106 NgramsType (Maybe NgramsField) (Maybe NgramsTag) (Maybe NgramsClass)
107 Double
108