]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NgramsPostag.hs
[FIX] more strict data
[gargantext.git] / src / Gargantext / Database / Schema / NgramsPostag.hs
1 {-|
2 Module : Gargantext.Database.Schema.NgramsPostag
3 Description : Ngram connection to the 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 Each Ngrams has a pos-tagging version to ease the default groups of
11 ngrams in NgramsTerm Lists.
12
13 -}
14
15 {-# LANGUAGE Arrows #-}
16 {-# LANGUAGE FunctionalDependencies #-}
17 {-# LANGUAGE QuasiQuotes #-}
18 {-# LANGUAGE TemplateHaskell #-}
19
20 module Gargantext.Database.Schema.NgramsPostag
21 where
22
23 import Control.Lens
24 import Data.Text (Text)
25 import Gargantext.Database.Schema.Prelude
26 import Gargantext.Prelude
27 import qualified Database.PostgreSQL.Simple as PGS
28
29 data NgramsPostagPoly id
30 lang_id
31 algo_id
32 postag
33 ngrams_id
34 lemm_id
35 score
36 = NgramsPostagPoly { _ngramsPostag_id :: !id
37 , _ngramsPostag_lang_id :: !lang_id
38 , _ngramsPostag_algo_id :: !algo_id
39 , _ngramsPostag_postag :: !postag
40 , _ngramsPostag_ngrams_id :: !ngrams_id
41 , _ngramsPostag_lemm_id :: !lemm_id
42 , _ngramsPostag_score :: !score
43 } deriving (Show)
44
45 ------------------------------------------------------------------------
46 data PosTag = PosTag { unPosTag :: !Text }
47 | NER { unNER :: !Text } -- TODO
48
49 ------------------------------------------------------------------------
50 -- type NgramsPostag = NgramsPostagPoly (Maybe Int) Lang PostTagAlgo (Maybe PosTag) NgramsTerm NgramsTerm (Maybe Int)
51 type NgramsPostagDB = NgramsPostagPoly (Maybe Int) Int Int (Maybe Text) Int Int Int
52
53 ------------------------------------------------------------------------
54 type NgramsPosTagWrite = NgramsPostagPoly (Maybe (Column PGInt4))
55 (Column PGInt4)
56 (Column PGInt4)
57 (Maybe (Column PGText))
58 (Column PGInt4)
59 (Column PGInt4)
60 (Maybe (Column PGInt4))
61
62 type NgramsPosTagRead = NgramsPostagPoly (Column PGInt4)
63 (Column PGInt4)
64 (Column PGInt4)
65 (Column PGText)
66 (Column PGInt4)
67 (Column PGInt4)
68 (Column PGInt4)
69
70 type NgramsPosTagReadNull = NgramsPostagPoly (Column (Nullable PGInt4))
71 (Column (Nullable PGInt4))
72 (Column (Nullable PGInt4))
73 (Column (Nullable PGText))
74 (Column (Nullable PGInt4))
75 (Column (Nullable PGInt4))
76 (Column (Nullable PGInt4))
77 makeLenses ''NgramsPostagPoly
78
79 instance PGS.ToRow NgramsPostagDB where
80 toRow (NgramsPostagPoly f0 f1 f2 f3 f4 f5 f6) = [ toField f0
81 , toField f1
82 , toField f2
83 , toField f3
84 , toField f4
85 , toField f5
86 , toField f6
87 ]