]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Types/Main.hs
[MOCK] all routes completed, builds but need to be adapted to fite the practices.
[gargantext.git] / src / Gargantext / Types / Main.hs
1 {-|
2 Module : .Gargantext.Types.Main
3 Description : Short description
4 Copyright : (c) CNRS, 2017
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Here is a longer description of this module, containing some
11 commentary with @some markup@.
12 -}
13
14 {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
15
16 {-# LANGUAGE DeriveGeneric #-}
17 {-# LANGUAGE FlexibleInstances #-}
18 {-# LANGUAGE OverloadedStrings #-}
19
20 module Gargantext.Types.Main where
21
22 import Prelude
23
24 import Data.Eq (Eq())
25 import Data.Monoid ((<>))
26 import Protolude (fromMaybe)
27 --import Data.ByteString (ByteString())
28 import Data.Text (Text)
29 import Data.List (lookup)
30 import Gargantext.Types.Node
31
32
33 -- | Language of a Text
34 -- For simplicity, we suppose text has an homogenous language
35 data Language = EN | FR -- | DE | IT | SP
36 -- > EN == english
37 -- > FR == french
38 -- > DE == deutch (not implemented yet)
39 -- > IT == italian (not implemented yet)
40 -- > SP == spanish (not implemented yet)
41 -- > ... add your language and help us to implement it (:
42
43
44 -- All the Database is structred like a hierarchical Tree
45 data Tree a = NodeT a [Tree a]
46 deriving (Show, Read, Eq)
47
48
49 -- data Tree a = NodeT a [Tree a]
50 -- same as Data.Tree
51 leafT :: a -> Tree a
52 leafT x = NodeT x []
53
54 -- Garg Network is a network of all Garg nodes
55 --gargNetwork = undefined
56
57 -- | Garg Node is Database Schema Typed as specification
58 -- gargNode gathers all the Nodes of all users on one Node
59 gargNode :: [Tree NodeType]
60 gargNode = [userTree]
61
62 -- | User Tree simplified
63 userTree :: Tree NodeType
64 userTree = NodeT NodeUser [projectTree]
65
66 -- | Project Tree
67 projectTree :: Tree NodeType
68 projectTree = NodeT Project [corpusTree]
69
70 -- | Corpus Tree
71 corpusTree :: Tree NodeType
72 corpusTree = NodeT Corpus ( [ leafT Document ]
73 <> [ leafT Lists ]
74 <> [ leafT Metrics ]
75 <> [ leafT Classification]
76 )
77
78 -- TODO make instances of Nodes
79 -- NP
80 -- * why NodeUser and not just User ?
81 -- * is this supposed to hold data ?
82
83
84 data Classification = Favorites | MyClassifcation
85
86 data Lists = StopList | MainList | MapList | GroupList
87
88 -- data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
89 -- | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
90
91
92 -- | Community Manager Use Case
93 type Annuaire = Corpus
94 type Individu = Document
95
96 -- | Favorites Node enable Node categorization
97 type Favorites = Node HyperdataFavorites
98
99 -- | Favorites Node enable Swap Node with some synonyms for clarity
100 type NodeSwap = Node HyperdataResource
101
102 -- | Then a Node can be a List which has some synonyms
103 type List = Node HyperdataList
104 type StopList = List
105 type MainList = List
106 type MapList = List
107 type GroupList = List
108
109 -- | Then a Node can be a Score which has some synonyms
110 type Score = Node HyperdataScore
111 type Occurrences = Score
112 type Cooccurrences = Score
113 type Specclusion = Score
114 type Genclusion = Score
115 type Cvalue = Score
116 type Tficf = Score
117 ---- TODO All these Tfidf* will be replaced with TFICF
118 type TfidfCorpus = Tficf
119 type TfidfGlobal = Tficf
120 type TirankLocal = Tficf
121 type TirankGlobal = Tficf
122 --
123 ---- | Then a Node can be either a Graph or a Phylo or a Notebook
124 type Graph = Node HyperdataGraph
125 type Phylo = Node HyperdataPhylo
126 type Notebook = Node HyperdataNotebook
127
128
129 nodeTypes :: [(NodeType, NodeTypeId)]
130 nodeTypes = [ (NodeUser , 1)
131 , (Project , 2)
132 , (Corpus , 3)
133 , (Document , 4)
134 --, (NodeSwap , 19)
135 ------ Lists
136 -- , (StopList , 5)
137 -- , (GroupList , 6)
138 -- , (MainList , 7)
139 -- , (MapList ,  8)
140 ---- Scores
141 , (Occurrences , 10)
142 -- , (Cooccurrences , 9)
143 --
144 -- , (Specclusion , 11)
145 -- , (Genclusion , 18)
146 -- , (Cvalue , 12)
147 --
148 -- , (TfidfCorpus , 13)
149 -- , (TfidfGlobal , 14)
150 --
151 -- , (TirankLocal , 16)
152 -- , (TirankGlobal , 17)
153 --
154 ---- Node management
155 -- , (Favorites , 15)
156 --
157 ]
158 --
159 nodeTypeId :: NodeType -> NodeTypeId
160 nodeTypeId tn = fromMaybe (error $ "Typename " <> show tn <> " does not exist")
161 (lookup tn nodeTypes)
162
163
164
165
166 -- Temporary types to be removed
167 type Ngrams = (Text, Text, Text)
168 type ErrorMessage = Text
169
170 -- Queries
171 type ParentId = NodeId
172 type Limit = Int
173 type Offset = Int
174
175