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