]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Types/Main.hs
Merge branch 'master' into fromRFC3339
[gargantext.git] / src / Gargantext / Types / Main.hs
1 {-|
2 Module : Gargantext.Types.Main
3 Description : Short 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-name-shadowing #-}
15
16 {-# LANGUAGE DeriveGeneric #-}
17 {-# LANGUAGE FlexibleInstances #-}
18 {-# LANGUAGE OverloadedStrings #-}
19
20 ------------------------------------------------------------------------
21 module Gargantext.Types.Main where
22 ------------------------------------------------------------------------
23
24 import Prelude
25 import Protolude (fromMaybe)
26
27 import Data.Eq (Eq())
28 import Data.Monoid ((<>))
29 import Data.Text (Text)
30 import Data.List (lookup)
31
32 import Gargantext.Types.Node
33
34 ------------------------------------------------------------------------
35 ------------------------------------------------------------------------
36
37 -- | Language of a Text
38 -- For simplicity, we suppose text has an homogenous language
39 data Language = EN | FR -- | DE | IT | SP
40 -- > EN == english
41 -- > FR == french
42 -- > DE == deutch (not implemented yet)
43 -- > IT == italian (not implemented yet)
44 -- > SP == spanish (not implemented yet)
45 -- > ... add your language and help us to implement it (:
46
47
48 -- All the Database is structred like a hierarchical Tree
49 data Tree a = NodeT a [Tree a]
50 deriving (Show, Read, Eq)
51
52
53 -- data Tree a = NodeT a [Tree a]
54 -- same as Data.Tree
55 leafT :: a -> Tree a
56 leafT x = NodeT x []
57
58 -- Garg Network is a network of all Garg nodes
59 --gargNetwork = undefined
60
61 -- | Garg Node is Database Schema Typed as specification
62 -- gargNode gathers all the Nodes of all users on one Node
63 gargNode :: [Tree NodeType]
64 gargNode = [userTree]
65
66 -- | User Tree simplified
67 userTree :: Tree NodeType
68 userTree = NodeT NodeUser [projectTree]
69
70 -- | Project Tree
71 projectTree :: Tree NodeType
72 projectTree = NodeT Project [corpusTree]
73
74 -- | Corpus Tree
75 corpusTree :: Tree NodeType
76 corpusTree = NodeT Corpus ( [ leafT Document ]
77 <> [ leafT Lists ]
78 <> [ leafT Metrics ]
79 <> [ leafT Classification]
80 )
81
82 -- TODO make instances of Nodes
83 -- NP
84 -- * why NodeUser and not just User ?
85 -- * is this supposed to hold data ?
86
87
88 data Classification = Favorites | MyClassifcation
89
90 data Lists = StopList | MainList | MapList | GroupList
91
92 -- data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
93 -- | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
94
95
96 -- | Community Manager Use Case
97 type Annuaire = Corpus
98 type Individu = Document
99
100 -- | Favorites Node enable Node categorization
101 type Favorites = Node HyperdataFavorites
102
103 -- | Favorites Node enable Swap Node with some synonyms for clarity
104 type NodeSwap = Node HyperdataResource
105
106 -- | Then a Node can be a List which has some synonyms
107 type List = Node HyperdataList
108 type StopList = List
109 type MainList = List
110 type MapList = List
111 type GroupList = List
112
113 -- | Then a Node can be a Score which has some synonyms
114 type Score = Node HyperdataScore
115 type Occurrences = Score
116 type Cooccurrences = Score
117 type Specclusion = Score
118 type Genclusion = Score
119 type Cvalue = Score
120 type Tficf = Score
121 ---- TODO All these Tfidf* will be replaced with TFICF
122 type TfidfCorpus = Tficf
123 type TfidfGlobal = Tficf
124 type TirankLocal = Tficf
125 type TirankGlobal = Tficf
126 --
127 ---- | Then a Node can be either a Graph or a Phylo or a Notebook
128 type Graph = Node HyperdataGraph
129 type Phylo = Node HyperdataPhylo
130 type Notebook = Node HyperdataNotebook
131
132
133 nodeTypes :: [(NodeType, NodeTypeId)]
134 nodeTypes = [ (NodeUser , 1)
135 , (Project , 2)
136 , (Corpus , 3)
137 , (Document , 4)
138 --, (NodeSwap , 19)
139 ------ Lists
140 -- , (StopList , 5)
141 -- , (GroupList , 6)
142 -- , (MainList , 7)
143 -- , (MapList ,  8)
144 ---- Scores
145 , (Occurrences , 10)
146 -- , (Cooccurrences , 9)
147 --
148 -- , (Specclusion , 11)
149 -- , (Genclusion , 18)
150 -- , (Cvalue , 12)
151 --
152 -- , (TfidfCorpus , 13)
153 -- , (TfidfGlobal , 14)
154 --
155 -- , (TirankLocal , 16)
156 -- , (TirankGlobal , 17)
157 --
158 ---- Node management
159 -- , (Favorites , 15)
160 --
161 ]
162 --
163 nodeTypeId :: NodeType -> NodeTypeId
164 nodeTypeId tn = fromMaybe (error $ "Typename " <> show tn <> " does not exist")
165 (lookup tn nodeTypes)
166
167
168
169
170 -- Temporary types to be removed
171 type Ngrams = (Text, Text, Text)
172 type ErrorMessage = Text
173
174 -- Queries
175 type ParentId = NodeId
176 type Limit = Int
177 type Offset = Int
178
179