]> Git — Sourcephile - gargantext.git/blob - src/Data/Gargantext/Types/Main.hs
[FIX] hard path in dependencies.
[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 Protolude (fromMaybe)
8
9 --import Data.ByteString (ByteString())
10 import Data.Text (Text)
11 import Data.Time (UTCTime)
12 import Data.Gargantext.Types.Node ( NodePoly
13 , HyperdataFolder , HyperdataCorpus , HyperdataDocument
14 , HyperdataFavorites, HyperdataResource
15 , HyperdataList , HyperdataScore
16 , HyperdataGraph
17 , HyperdataPhylo
18 , HyperdataNotebook
19 )
20
21
22 -- | Language of a Text
23 -- For simplicity, we suppose text has an homogenous language
24 data Language = EN | FR -- | DE | IT | SP
25 -- > EN == english
26 -- > FR == french
27 -- > DE == deutch (not implemented yet)
28 -- > IT == italian (not implemented yet)
29 -- > SP == spanish (not implemented yet)
30 -- > ... add your language and help us to implement it (:
31
32 type Ngrams = (Text, Text, Text)
33
34 type ErrorMessage = String
35
36
37 -- | TODO add Symbolic Node / Document
38 -- TODO make instances of Nodes
39
40 -- All the Database is structred like a hierachical Tree
41 data Tree a = Leaf a | Node' [Tree a]
42
43 data NodeType = NodeUser
44 | Folder | Project | Corpus | Document
45 | Favorites
46 | NodeSwap
47 | List | StopList | MainList | MapList | GroupList
48 | Score | Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
49 | Tficf | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
50
51 deriving (Show, Eq)
52
53
54
55 -- | NodePoly indicates that Node has a Polymorphism Type
56 type Node json = NodePoly NodeId NodeTypeId NodeUserId NodeParentId NodeName UTCTime json
57 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
58 type NodeTypeId = Int
59 type NodeId = Int
60 type NodeParentId = Int
61 type NodeUserId = Int
62 type NodeName = Text
63
64 --type NodeUser = Node HyperdataUser
65
66 -- | Then a Node can be either a Folder or a Corpus or a Document
67 type Folder = Node HyperdataFolder
68 type Project = Folder
69 type Corpus = Node HyperdataCorpus
70 type Document = Node HyperdataDocument
71
72 -- | Community Manager Use Case
73 type Annuaire = Corpus
74 type Individu = Document
75
76 -- | Favorites Node enable Node categorization
77 type Favorites = Node HyperdataFavorites
78
79 -- | Favorites Node enable Swap Node with some synonyms for clarity
80 type NodeSwap = Node HyperdataResource
81
82 -- | Then a Node can be a List which as some synonyms
83 type List = Node HyperdataList
84 type StopList = List
85 type MainList = List
86 type MapList = List
87 type GroupList = List
88
89 -- | Then a Node can be a Score which as some synonyms
90 type Score = Node HyperdataScore
91 type Occurrences = Score
92 type Cooccurrences = Score
93 type Specclusion = Score
94 type Genclusion = Score
95 type Cvalue = Score
96 type Tficf = Score
97 -- TODO All these Tfidf* will be replaced with TFICF
98 type TfidfCorpus = Tficf
99 type TfidfGlobal = Tficf
100 type TirankLocal = Tficf
101 type TirankGlobal = Tficf
102
103 -- | Then a Node can be either a Graph or a Phylo or a Notebook
104 type Graph = Node HyperdataGraph
105 type Phylo = Node HyperdataPhylo
106 type Notebook = Node HyperdataNotebook
107
108
109 nodeTypes :: [(NodeType, NodeTypeId)]
110 nodeTypes = [
111 --(NodeUser , 1)
112 --
113 (Project , 2)
114 , (NodeSwap , 19)
115 , (Corpus , 3)
116 , (Document , 4)
117 ------ Lists
118 , (StopList , 5)
119 , (GroupList , 6)
120 , (MainList , 7)
121 , (MapList ,  8)
122 -- Scores
123 , (Occurrences , 10)
124 , (Cooccurrences , 9)
125
126 , (Specclusion , 11)
127 , (Genclusion , 18)
128 , (Cvalue , 12)
129
130 , (TfidfCorpus , 13)
131 , (TfidfGlobal , 14)
132
133 , (TirankLocal , 16)
134 , (TirankGlobal , 17)
135
136 -- Node management
137 , (Favorites , 15)
138
139 ]
140 --
141 nodeTypeId :: NodeType -> NodeTypeId
142 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)