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
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 hierachical Tree
39 data Tree b a = LeafT a | NodeT b [Tree b a]
40 deriving (Show, Read, Eq)
42 -- Garg Database Schema Typed as specification
43 gargDatabase :: [Tree NodeType NodeType]
44 gargDatabase = [userTree]
46 -- | User Tree simplified
47 userTree :: Tree NodeType NodeType
48 userTree = NodeT NodeUser [projectTree]
51 projectTree :: Tree NodeType NodeType
52 projectTree = NodeT Project [corpusTree]
55 corpusTree :: Tree NodeType NodeType
56 corpusTree = NodeT Corpus ( [ LeafT Document ]
62 -- | TODO add Symbolic Node / Document
63 -- TODO make instances of Nodes
64 data NodeType = NodeUser | Project | Corpus | Document | DocumentCopy
70 data Lists = StopList | MainList | MapList | GroupList
72 data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
73 | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
81 -- | NodePoly indicates that Node has a Polymorphism Type
82 type Node json = NodePoly NodeId NodeTypeId NodeUserId NodeParentId NodeName UTCTime json
83 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
86 type NodeParentId = Int
90 --type NodeUser = Node HyperdataUser
92 -- | Then a Node can be either a Folder or a Corpus or a Document
93 type Folder = Node HyperdataFolder
95 type Corpus = Node HyperdataCorpus
96 type Document = Node HyperdataDocument
98 -- | Community Manager Use Case
99 type Annuaire = Corpus
100 type Individu = Document
102 -- | Favorites Node enable Node categorization
103 type Favorites = Node HyperdataFavorites
105 -- | Favorites Node enable Swap Node with some synonyms for clarity
106 type NodeSwap = Node HyperdataResource
108 -- | Then a Node can be a List which as some synonyms
109 type List = Node HyperdataList
113 type GroupList = List
115 -- | Then a Node can be a Score which as some synonyms
116 --type Score = Node HyperdataScore
117 --type Occurrences = Score
118 --type Cooccurrences = Score
119 --type Specclusion = Score
120 --type Genclusion = Score
121 --type Cvalue = Score
123 ---- TODO All these Tfidf* will be replaced with TFICF
124 --type TfidfCorpus = Tficf
125 --type TfidfGlobal = Tficf
126 --type TirankLocal = Tficf
127 --type TirankGlobal = Tficf
129 ---- | Then a Node can be either a Graph or a Phylo or a Notebook
130 --type Graph = Node HyperdataGraph
131 --type Phylo = Node HyperdataPhylo
132 --type Notebook = Node HyperdataNotebook
135 --nodeTypes :: [(NodeType, NodeTypeId)]
149 -- , (Occurrences , 10)
150 -- , (Cooccurrences , 9)
152 -- , (Specclusion , 11)
153 -- , (Genclusion , 18)
156 -- , (TfidfCorpus , 13)
157 -- , (TfidfGlobal , 14)
159 -- , (TirankLocal , 16)
160 -- , (TirankGlobal , 17)
163 -- , (Favorites , 15)
167 --nodeTypeId :: NodeType -> NodeTypeId
168 --nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)