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 (:
35 -- All the Database is structred like a hierarchical Tree
36 data Tree a = NodeT a [Tree a]
37 deriving (Show, Read, Eq)
40 -- data Tree a = NodeT a [Tree a]
45 -- Garg Network is a network of all Garg nodes
46 --gargNetwork = undefined
48 -- | Garg Node is Database Schema Typed as specification
49 -- gargNode gathers all the Nodes of all users on one Node
50 gargNode :: [Tree NodeType]
53 -- | User Tree simplified
54 userTree :: Tree NodeType
55 userTree = NodeT NodeUser [projectTree]
58 projectTree :: Tree NodeType
59 projectTree = NodeT Project [corpusTree]
62 corpusTree :: Tree NodeType
63 corpusTree = NodeT Corpus ( [ leafT Document ]
66 <> [ leafT Classification]
69 -- TODO make instances of Nodes
71 -- * why NodeUser and not just User ?
72 -- * is this supposed to hold data ?
73 data NodeType = NodeUser | Project | Corpus | Document | DocumentCopy
77 deriving (Show, Read, Eq)
79 data Classification = Favorites | MyClassifcation
81 data Lists = StopList | MainList | MapList | GroupList
83 data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
84 | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
88 -- | NodePoly indicates that Node has a Polymorphism Type
89 type Node json = NodePoly NodeId NodeTypeId NodeUserId (Maybe NodeParentId) NodeName UTCTime json -- NodeVector
90 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
93 type NodeParentId = Int
96 --type NodeVector = Vector
98 --type NodeUser = Node HyperdataUser
100 -- | Then a Node can be either a Folder or a Corpus or a Document
101 type NodeUser = Node HyperdataUser
102 type Folder = Node HyperdataFolder
103 type Project = Folder -- NP Node HyperdataProject ?
104 type Corpus = Node HyperdataCorpus
105 type Document = Node HyperdataDocument
107 -- | Community Manager Use Case
108 type Annuaire = Corpus
109 type Individu = Document
111 -- | Favorites Node enable Node categorization
112 type Favorites = Node HyperdataFavorites
114 -- | Favorites Node enable Swap Node with some synonyms for clarity
115 type NodeSwap = Node HyperdataResource
117 -- | Then a Node can be a List which has some synonyms
118 type List = Node HyperdataList
122 type GroupList = List
124 -- | Then a Node can be a Score which has some synonyms
125 type Score = Node HyperdataScore
126 type Occurrences = Score
127 type Cooccurrences = Score
128 type Specclusion = Score
129 type Genclusion = Score
132 ---- TODO All these Tfidf* will be replaced with TFICF
133 type TfidfCorpus = Tficf
134 type TfidfGlobal = Tficf
135 type TirankLocal = Tficf
136 type TirankGlobal = Tficf
138 ---- | Then a Node can be either a Graph or a Phylo or a Notebook
139 type Graph = Node HyperdataGraph
140 type Phylo = Node HyperdataPhylo
141 type Notebook = Node HyperdataNotebook
144 nodeTypes :: [(NodeType, NodeTypeId)]
145 nodeTypes = [ (NodeUser , 1)
156 -- , (Occurrences , 10)
157 -- , (Cooccurrences , 9)
159 -- , (Specclusion , 11)
160 -- , (Genclusion , 18)
163 -- , (TfidfCorpus , 13)
164 -- , (TfidfGlobal , 14)
166 -- , (TirankLocal , 16)
167 -- , (TirankGlobal , 17)
170 -- , (Favorites , 15)
174 nodeTypeId :: NodeType -> NodeTypeId
175 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)
179 -- Temporary types to be removed
180 type Ngrams = (Text, Text, Text)
181 type ErrorMessage = String