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