]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Schema/NgramsPostag.hs
[REFACT/CLEAN] TextFlow
[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 type NgramsPostagDB = NgramsPostagPoly (Maybe Int) Int Int (Maybe Text) Int Int Int
54
55 ------------------------------------------------------------------------
56 type NgramsPosTagWrite = NgramsPostagPoly (Maybe (Column PGInt4))
57 (Column PGInt4)
58 (Column PGInt4)
59 (Maybe (Column PGText))
60 (Column PGInt4)
61 (Column PGInt4)
62 (Maybe (Column PGInt4))
63
64 type NgramsPosTagRead = NgramsPostagPoly (Column PGInt4)
65 (Column PGInt4)
66 (Column PGInt4)
67 (Column PGText)
68 (Column PGInt4)
69 (Column PGInt4)
70 (Column PGInt4)
71
72 type NgramsPosTagReadNull = NgramsPostagPoly (Column (Nullable PGInt4))
73 (Column (Nullable PGInt4))
74 (Column (Nullable PGInt4))
75 (Column (Nullable PGText))
76 (Column (Nullable PGInt4))
77 (Column (Nullable PGInt4))
78 (Column (Nullable PGInt4))
79 makeLenses ''NgramsPostagPoly
80
81 instance PGS.ToRow NgramsPostagDB where
82 toRow (NgramsPostagPoly f0 f1 f2 f3 f4 f5 f6) = [ toField f0
83 , toField f1
84 , toField f2
85 , toField f3
86 , toField f4
87 , toField f5
88 , toField f6
89 ]