2 -- Licence: https://gitlab.iscpif.fr/humanities/gargantext/blob/stable/LICENSE
3 -- Author: Alexandre Delanoë (alexandre.delanoe@iscpif.fr)
5 module Data.Gargantext.Types.Main where
7 import Data.Monoid ((<>))
8 import Protolude (fromMaybe)
10 --import Data.ByteString (ByteString())
11 import Data.Text (Text)
12 import Data.Time (UTCTime)
13 import Data.Gargantext.Types.Node ( NodePoly, HyperdataUser
14 , HyperdataFolder , HyperdataCorpus , HyperdataDocument
15 , HyperdataFavorites, HyperdataResource
16 , HyperdataList , HyperdataScore
23 -- | Language of a Text
24 -- For simplicity, we suppose text has an homogenous language
25 data Language = EN | FR -- | DE | IT | SP
28 -- > DE == deutch (not implemented yet)
29 -- > IT == italian (not implemented yet)
30 -- > SP == spanish (not implemented yet)
31 -- > ... add your language and help us to implement it (:
34 -- All the Database is structred like a hierarchical Tree
35 data Tree a = NodeT a [Tree a]
36 deriving (Show, Read, Eq)
39 -- data Tree a = NodeT a [Tree a]
44 -- Garg Network is a network of all Garg nodes
45 --gargNetwork = undefined
47 -- | Garg Node is Database Schema Typed as specification
48 -- gargNode gathers all the Nodes of all users on one Node
49 gargNode :: [Tree NodeType]
52 -- | User Tree simplified
53 userTree :: Tree NodeType
54 userTree = NodeT NodeUser [projectTree]
57 projectTree :: Tree NodeType
58 projectTree = NodeT Project [corpusTree]
61 corpusTree :: Tree NodeType
62 corpusTree = NodeT Corpus ( [ leafT Document ]
65 <> [ leafT Classification]
68 -- TODO make instances of Nodes
70 -- * why NodeUser and not just User ?
71 -- * is this supposed to hold data ?
72 data NodeType = NodeUser | Project | Corpus | Document | DocumentCopy
76 deriving (Show, Read, Eq)
78 data Classification = Favorites | MyClassifcation
80 data Lists = StopList | MainList | MapList | GroupList
82 data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
83 | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
87 -- | NodePoly indicates that Node has a Polymorphism Type
88 type Node json = NodePoly NodeId NodeTypeId NodeUserId (Maybe NodeParentId) NodeName UTCTime json -- NodeVector
89 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
92 type NodeParentId = Int
95 --type NodeVector = Vector
97 --type NodeUser = Node HyperdataUser
99 -- | Then a Node can be either a Folder or a Corpus or a Document
100 type NodeUser = Node HyperdataUser
101 type Folder = Node HyperdataFolder
102 type Project = Folder -- NP Node HyperdataProject ?
103 type Corpus = Node HyperdataCorpus
104 type Document = Node HyperdataDocument
106 -- | Community Manager Use Case
107 type Annuaire = Corpus
108 type Individu = Document
110 -- | Favorites Node enable Node categorization
111 type Favorites = Node HyperdataFavorites
113 -- | Favorites Node enable Swap Node with some synonyms for clarity
114 type NodeSwap = Node HyperdataResource
116 -- | Then a Node can be a List which has some synonyms
117 type List = Node HyperdataList
121 type GroupList = List
123 -- | Then a Node can be a Score which has some synonyms
124 type Score = Node HyperdataScore
125 type Occurrences = Score
126 type Cooccurrences = Score
127 type Specclusion = Score
128 type Genclusion = Score
131 ---- TODO All these Tfidf* will be replaced with TFICF
132 type TfidfCorpus = Tficf
133 type TfidfGlobal = Tficf
134 type TirankLocal = Tficf
135 type TirankGlobal = Tficf
137 ---- | Then a Node can be either a Graph or a Phylo or a Notebook
138 type Graph = Node HyperdataGraph
139 type Phylo = Node HyperdataPhylo
140 type Notebook = Node HyperdataNotebook
143 nodeTypes :: [(NodeType, NodeTypeId)]
144 nodeTypes = [ (NodeUser , 1)
155 -- , (Occurrences , 10)
156 -- , (Cooccurrences , 9)
158 -- , (Specclusion , 11)
159 -- , (Genclusion , 18)
162 -- , (TfidfCorpus , 13)
163 -- , (TfidfGlobal , 14)
165 -- , (TirankLocal , 16)
166 -- , (TirankGlobal , 17)
169 -- , (Favorites , 15)
173 nodeTypeId :: NodeType -> NodeTypeId
174 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)
178 -- Temporary types to be removed
179 type Ngrams = (Text, Text, Text)
180 type ErrorMessage = String