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