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 OverloadedStrings #-}
20 ------------------------------------------------------------------------
21 module Gargantext.Types.Main where
22 ------------------------------------------------------------------------
24 import Data.Maybe (fromMaybe)
26 import Data.Monoid ((<>))
27 import Data.Text (Text, pack)
28 import Data.List (lookup)
30 import Gargantext.Types.Node
31 import Gargantext.Prelude
33 ------------------------------------------------------------------------
34 ------------------------------------------------------------------------
35 -- | Language of a Text
36 -- For simplicity, we suppose text has an homogenous language
37 data Language = EN | FR
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 (:
46 -- All the Database is structred like a hierarchical Tree
47 data Tree a = NodeT a [Tree a]
48 deriving (Show, Read, Eq)
50 -- data Tree a = NodeT a [Tree a]
55 -- Garg Network is a network of all Garg nodes
56 --gargNetwork = undefined
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]
63 -- | User Tree simplified
64 userTree :: Tree NodeType
65 userTree = NodeT NodeUser [projectTree]
68 projectTree :: Tree NodeType
69 projectTree = NodeT Project [corpusTree]
72 corpusTree :: Tree NodeType
73 corpusTree = NodeT Corpus ( [ leafT Document ]
76 <> [ leafT Classification]
79 -- TODO make instances of Nodes
81 -- * why NodeUser and not just User ?
82 -- * is this supposed to hold data ?
85 data Classification = Favorites | MyClassifcation
87 data Lists = StopList | MainList | MapList | GroupList
89 -- data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
90 -- | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
93 -- | Community Manager Use Case
94 type Annuaire = Corpus
95 type Individu = Document
97 -- | Favorites Node enable Node categorization
98 type Favorites = Node HyperdataFavorites
100 -- | Favorites Node enable Swap Node with some synonyms for clarity
101 type NodeSwap = Node HyperdataResource
103 -- | Then a Node can be a List which has some synonyms
104 type List = Node HyperdataList
108 type GroupList = List
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
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
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
130 nodeTypes :: [(NodeType, NodeTypeId)]
131 nodeTypes = [ (NodeUser , 1)
143 -- , (Cooccurrences , 9)
145 -- , (Specclusion , 11)
146 -- , (Genclusion , 18)
149 -- , (TfidfCorpus , 13)
150 -- , (TfidfGlobal , 14)
152 -- , (TirankLocal , 16)
153 -- , (TirankGlobal , 17)
156 -- , (Favorites , 15)
160 nodeTypeId :: NodeType -> NodeTypeId
161 nodeTypeId tn = fromMaybe (panic $ pack $ "Typename " <> show tn <> " does not exist")
162 (lookup tn nodeTypes)
165 -- Temporary types to be removed
166 type Ngrams = (Text, Text, Text)
167 type ErrorMessage = Text
170 type ParentId = NodeId