]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NgramsPostag.hs
merge
[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.Core
26 import Gargantext.Database.Schema.Prelude
27 import Gargantext.API.Ngrams.Types
28 import Gargantext.Prelude
29 import qualified Database.PostgreSQL.Simple as PGS
30
31 data NgramsPostagPoly id
32 lang_id
33 algo_id
34 postag
35 ngrams_id
36 lemm_id
37 score
38 = NgramsPostagPoly { _ngramsPostag_id :: !id
39 , _ngramsPostag_lang_id :: !lang_id
40 , _ngramsPostag_algo_id :: !algo_id
41 , _ngramsPostag_postag :: !postag
42 , _ngramsPostag_ngrams_id :: !ngrams_id
43 , _ngramsPostag_lemm_id :: !lemm_id
44 , _ngramsPostag_score :: !score
45 } deriving (Show)
46
47 ------------------------------------------------------------------------
48 data PosTag = PosTag { unPosTag :: Text }
49 | NER { unNER :: Text } -- TODO
50
51 ------------------------------------------------------------------------
52 type NgramsPostag = NgramsPostagPoly (Maybe Int) Lang PostTagAlgo (Maybe PosTag) NgramsTerm NgramsTerm (Maybe Int)
53
54 type NgramsPostagDB = NgramsPostagPoly (Maybe Int) Int Int (Maybe Text) Int Int Int
55
56
57
58 ------------------------------------------------------------------------
59
60 type NgramsPosTagWrite = NgramsPostagPoly (Maybe (Column PGInt4))
61 (Column PGInt4)
62 (Column PGInt4)
63 (Maybe (Column PGText))
64 (Column PGInt4)
65 (Column PGInt4)
66 (Maybe (Column PGInt4))
67
68 type NgramsPosTagRead = NgramsPostagPoly (Column PGInt4)
69 (Column PGInt4)
70 (Column PGInt4)
71 (Column PGText)
72 (Column PGInt4)
73 (Column PGInt4)
74 (Column PGInt4)
75
76 type NgramsPosTagReadNull = NgramsPostagPoly (Column (Nullable PGInt4))
77 (Column (Nullable PGInt4))
78 (Column (Nullable PGInt4))
79 (Column (Nullable PGText))
80 (Column (Nullable PGInt4))
81 (Column (Nullable PGInt4))
82 (Column (Nullable PGInt4))
83 makeLenses ''NgramsPostagPoly
84
85 instance PGS.ToRow NgramsPostagDB where
86 toRow (NgramsPostagPoly f0 f1 f2 f3 f4 f5 f6) = [ toField f0
87 , toField f1
88 , toField f2
89 , toField f3
90 , toField f4
91 , toField f5
92 , toField f6
93 ]