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