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 (:
33 type Ngrams = (Text, Text, Text)
35 type ErrorMessage = String
38 -- All the Database is structred like a hierarchical Tree
39 data Tree b a = LeafT a | NodeT b [Tree b a]
40 deriving (Show, Read, Eq)
42 -- Garg Network is a network of all Garg nodes
43 --gargNetwork = undefined
45 -- | Garg Node is Database Schema Typed as specification
46 -- gargNode gathers all the Nodes of all users on one Node
47 gargNode :: [Tree NodeType NodeType]
50 -- | User Tree simplified
51 userTree :: Tree NodeType NodeType
52 userTree = NodeT NodeUser [projectTree]
55 projectTree :: Tree NodeType NodeType
56 projectTree = NodeT Project [corpusTree]
59 corpusTree :: Tree NodeType NodeType
60 corpusTree = NodeT Corpus ( [ LeafT Document ]
63 <> [ LeafT Classification]
66 -- TODO make instances of Nodes
67 data NodeType = NodeUser | Project | Corpus | Document | DocumentCopy
71 deriving (Show, Read, Eq)
73 data Classification = Favorites | MyClassifcation
75 data Lists = StopList | MainList | MapList | GroupList
77 data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
78 | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
82 -- | NodePoly indicates that Node has a Polymorphism Type
83 type Node json = NodePoly NodeId NodeTypeId NodeUserId NodeParentId NodeName UTCTime json -- NodeVector
84 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
87 type NodeParentId = Int
90 --type NodeVector = Vector
92 --type NodeUser = Node HyperdataUser
94 -- | Then a Node can be either a Folder or a Corpus or a Document
95 type NodeUser = Node HyperdataUser
96 type Folder = Node HyperdataFolder
98 type Corpus = Node HyperdataCorpus
99 type Document = Node HyperdataDocument
101 -- | Community Manager Use Case
102 type Annuaire = Corpus
103 type Individu = Document
105 -- | Favorites Node enable Node categorization
106 type Favorites = Node HyperdataFavorites
108 -- | Favorites Node enable Swap Node with some synonyms for clarity
109 type NodeSwap = Node HyperdataResource
111 -- | Then a Node can be a List which as some synonyms
112 type List = Node HyperdataList
116 type GroupList = List
118 -- | Then a Node can be a Score which as some synonyms
119 type Score = Node HyperdataScore
120 type Occurrences = Score
121 type Cooccurrences = Score
122 type Specclusion = Score
123 type Genclusion = Score
126 ---- TODO All these Tfidf* will be replaced with TFICF
127 type TfidfCorpus = Tficf
128 type TfidfGlobal = Tficf
129 type TirankLocal = Tficf
130 type TirankGlobal = Tficf
132 ---- | Then a Node can be either a Graph or a Phylo or a Notebook
133 type Graph = Node HyperdataGraph
134 type Phylo = Node HyperdataPhylo
135 type Notebook = Node HyperdataNotebook
138 nodeTypes :: [(NodeType, NodeTypeId)]
139 nodeTypes = [ (NodeUser , 1)
150 -- , (Occurrences , 10)
151 -- , (Cooccurrences , 9)
153 -- , (Specclusion , 11)
154 -- , (Genclusion , 18)
157 -- , (TfidfCorpus , 13)
158 -- , (TfidfGlobal , 14)
160 -- , (TirankLocal , 16)
161 -- , (TirankGlobal , 17)
164 -- , (Favorites , 15)
168 nodeTypeId :: NodeType -> NodeTypeId
169 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)