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
10 Here is a longer description of this module, containing some
11 commentary with @some markup@.
14 {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
16 {-# LANGUAGE DeriveGeneric #-}
17 {-# LANGUAGE FlexibleInstances #-}
18 {-# LANGUAGE NoImplicitPrelude #-}
19 {-# LANGUAGE OverloadedStrings #-}
21 ------------------------------------------------------------------------
22 module Gargantext.Types.Main where
23 ------------------------------------------------------------------------
25 import Data.Maybe (fromMaybe)
27 import Data.Monoid ((<>))
28 import Data.Text (Text, pack)
29 import Data.List (lookup)
31 import Gargantext.Types.Node
32 import Gargantext.Prelude
34 ------------------------------------------------------------------------
35 ------------------------------------------------------------------------
36 -- | Language of a Text
37 -- For simplicity, we suppose text has an homogenous language
38 data Language = EN | FR
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 (:
47 -- All the Database is structred like a hierarchical Tree
48 data Tree a = NodeT a [Tree a]
49 deriving (Show, Read, Eq)
51 -- data Tree a = NodeT a [Tree a]
56 -- Garg Network is a network of all Garg nodes
57 --gargNetwork = undefined
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]
64 -- | User Tree simplified
65 userTree :: Tree NodeType
66 userTree = NodeT NodeUser [projectTree]
69 projectTree :: Tree NodeType
70 projectTree = NodeT Project [corpusTree]
73 corpusTree :: Tree NodeType
74 corpusTree = NodeT Corpus ( [ leafT Document ]
77 <> [ leafT Classification]
80 -- TODO make instances of Nodes
82 -- * why NodeUser and not just User ?
83 -- * is this supposed to hold data ?
86 data Classification = Favorites | MyClassifcation
88 data Lists = StopList | MainList | MapList | GroupList
90 -- data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
91 -- | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
94 -- | Community Manager Use Case
95 type Annuaire = Corpus
96 type Individu = Document
98 -- | Favorites Node enable Node categorization
99 type Favorites = Node HyperdataFavorites
101 -- | Favorites Node enable Swap Node with some synonyms for clarity
102 type NodeSwap = Node HyperdataResource
104 -- | Then a Node can be a List which has some synonyms
105 type List = Node HyperdataList
109 type GroupList = List
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
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
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
131 nodeTypes :: [(NodeType, NodeTypeId)]
132 nodeTypes = [ (NodeUser , 1)
144 -- , (Cooccurrences , 9)
146 -- , (Specclusion , 11)
147 -- , (Genclusion , 18)
150 -- , (TfidfCorpus , 13)
151 -- , (TfidfGlobal , 14)
153 -- , (TirankLocal , 16)
154 -- , (TirankGlobal , 17)
157 -- , (Favorites , 15)
161 nodeTypeId :: NodeType -> NodeTypeId
162 nodeTypeId tn = fromMaybe (panic $ pack $ "Typename " <> show tn <> " does not exist")
163 (lookup tn nodeTypes)
166 -- Temporary types to be removed
167 type ErrorMessage = Text
170 type ParentId = NodeId