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