]> Git — Sourcephile - gargantext.git/blob - src/Data/Gargantext/Types/Main.hs
[TYPO]
[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 -- Where a is a NodeType:
42 -- TODO force the logic of the architecture
43 data Tree a = Empty | Node' a (Tree a) (Tree a) deriving (Show)
44
45 data NodeType = NodeUser
46 | Folder | Project | Corpus | Document
47 | Favorites
48 | NodeSwap
49 | List | StopList | MainList | MapList | GroupList
50 | Score | Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
51 | Tficf | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
52
53 deriving (Show, Eq)
54
55
56
57 -- | NodePoly indicates that Node has a Polymorphism Type
58 type Node json = NodePoly NodeId NodeTypeId NodeUserId NodeParentId NodeName UTCTime json
59 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
60 type NodeTypeId = Int
61 type NodeId = Int
62 type NodeParentId = Int
63 type NodeUserId = Int
64 type NodeName = Text
65
66 --type NodeUser = Node HyperdataUser
67
68 -- | Then a Node can be either a Folder or a Corpus or a Document
69 type Folder = Node HyperdataFolder
70 type Project = Folder
71 type Corpus = Node HyperdataCorpus
72 type Document = Node HyperdataDocument
73
74 -- | Community Manager Use Case
75 type Annuaire = Corpus
76 type Individu = Document
77
78 -- | Favorites Node enable Node categorization
79 type Favorites = Node HyperdataFavorites
80
81 -- | Favorites Node enable Swap Node with some synonyms for clarity
82 type NodeSwap = Node HyperdataResource
83
84 -- | Then a Node can be a List which as some synonyms
85 type List = Node HyperdataList
86 type StopList = List
87 type MainList = List
88 type MapList = List
89 type GroupList = List
90
91 -- | Then a Node can be a Score which as some synonyms
92 type Score = Node HyperdataScore
93 type Occurrences = Score
94 type Cooccurrences = Score
95 type Specclusion = Score
96 type Genclusion = Score
97 type Cvalue = Score
98 type Tficf = Score
99 -- TODO All these Tfidf* will be replaced with TFICF
100 type TfidfCorpus = Tficf
101 type TfidfGlobal = Tficf
102 type TirankLocal = Tficf
103 type TirankGlobal = Tficf
104
105 -- | Then a Node can be either a Graph or a Phylo or a Notebook
106 type Graph = Node HyperdataGraph
107 type Phylo = Node HyperdataPhylo
108 type Notebook = Node HyperdataNotebook
109
110
111 nodeTypes :: [(NodeType, NodeTypeId)]
112 nodeTypes = [
113 --(NodeUser , 1)
114 --
115 (Project , 2)
116 , (NodeSwap , 19)
117 , (Corpus , 3)
118 , (Document , 4)
119 ------ Lists
120 , (StopList , 5)
121 , (GroupList , 6)
122 , (MainList , 7)
123 , (MapList ,  8)
124 -- Scores
125 , (Occurrences , 10)
126 , (Cooccurrences , 9)
127
128 , (Specclusion , 11)
129 , (Genclusion , 18)
130 , (Cvalue , 12)
131
132 , (TfidfCorpus , 13)
133 , (TfidfGlobal , 14)
134
135 , (TirankLocal , 16)
136 , (TirankGlobal , 17)
137
138 -- Node management
139 , (Favorites , 15)
140
141 ]
142 --
143 nodeTypeId :: NodeType -> NodeTypeId
144 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)