]> Git — Sourcephile - gargantext.git/blob - src/Data/Gargantext/Types/Main.hs
[CLEAN] Moving CoreNLP in Ngrams folder.
[gargantext.git] / src / Data / Gargantext / Types / Main.hs
1 -- | CNRS Copyrights
2 -- Licence: https://gitlab.iscpif.fr/humanities/gargantext/blob/stable/LICENSE
3 -- Author: Alexandre Delanoë (alexandre.delanoe@iscpif.fr)
4
5 module Data.Gargantext.Types.Main where
6
7 import Protolude (fromMaybe)
8 import Data.Text (Text)
9 import Data.Time (UTCTime)
10 import Data.Gargantext.Types.Node ( NodePoly
11 , HyperdataFolder , HyperdataCorpus , HyperdataDocument
12 , HyperdataFavorites, HyperdataResource
13 , HyperdataList , HyperdataScore
14 , HyperdataGraph
15 , HyperdataPhylo
16 , HyperdataNotebook
17 )
18
19
20
21 data Language = EN | FR -- | DE | IT | SP
22 -- > EN == english
23 -- > FR == french
24 -- > DE == deutch (not implemented yet)
25 -- > IT == italian (not implemented yet)
26 -- > SP == spanish (not implemented yet)
27 -- > ... add your language and help us to implement it (:
28
29
30 type Ngrams = (Text, Text, Text)
31
32 -- | TODO add Symbolic Node / Document
33 -- TODO make instances of Nodes
34
35 -- All the Database is structred like a hierachical Tree
36 -- Where a is a NodeType:
37 -- TODO force the logic of the architecture
38 data Tree a = Empty | Node' a (Tree a) (Tree a) deriving (Show)
39
40 data NodeType = NodeUser
41 | Folder | Project | Corpus | Document
42 | Favorites
43 | NodeSwap
44 | List | StopList | MainList | MapList | GroupList
45 | Score | Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
46 | Tficf | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
47
48 deriving (Show, Eq)
49
50
51
52 -- | NodePoly indicates that Node has a Polymorphism Type
53 type Node json = NodePoly NodeId NodeTypeId NodeUserId NodeParentId NodeName UTCTime json
54 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
55 type NodeTypeId = Int
56 type NodeId = Int
57 type NodeParentId = Int
58 type NodeUserId = Int
59 type NodeName = Text
60
61 --type NodeUser = Node HyperdataUser
62
63 -- | Then a Node can be either a Folder or a Corpus or a Document
64 type Folder = Node HyperdataFolder
65 type Project = Folder
66 type Corpus = Node HyperdataCorpus
67 type Document = Node HyperdataDocument
68
69 -- | Community Manager Use Case
70 type Annuaire = Corpus
71 type Individu = Document
72
73 -- | Favorites Node enable Node categorization
74 type Favorites = Node HyperdataFavorites
75
76 -- | Favorites Node enable Swap Node with some synonyms for clarity
77 type NodeSwap = Node HyperdataResource
78
79 -- | Then a Node can be a List which as some synonyms
80 type List = Node HyperdataList
81 type StopList = List
82 type MainList = List
83 type MapList = List
84 type GroupList = List
85
86 -- | Then a Node can be a Score which as some synonyms
87 type Score = Node HyperdataScore
88 type Occurrences = Score
89 type Cooccurrences = Score
90 type Specclusion = Score
91 type Genclusion = Score
92 type Cvalue = Score
93 type Tficf = Score
94 -- TODO All these Tfidf* will be replaced with TFICF
95 type TfidfCorpus = Tficf
96 type TfidfGlobal = Tficf
97 type TirankLocal = Tficf
98 type TirankGlobal = Tficf
99
100 -- | Then a Node can be either a Graph or a Phylo or a Notebook
101 type Graph = Node HyperdataGraph
102 type Phylo = Node HyperdataPhylo
103 type Notebook = Node HyperdataNotebook
104
105
106 nodeTypes :: [(NodeType, NodeTypeId)]
107 nodeTypes = [
108 --(NodeUser , 1)
109 --
110 (Project , 2)
111 , (NodeSwap , 19)
112 , (Corpus , 3)
113 , (Document , 4)
114 ------ Lists
115 , (StopList , 5)
116 , (GroupList , 6)
117 , (MainList , 7)
118 , (MapList ,  8)
119 -- Scores
120 , (Occurrences , 10)
121 , (Cooccurrences , 9)
122
123 , (Specclusion , 11)
124 , (Genclusion , 18)
125 , (Cvalue , 12)
126
127 , (TfidfCorpus , 13)
128 , (TfidfGlobal , 14)
129
130 , (TirankLocal , 16)
131 , (TirankGlobal , 17)
132
133 -- Node management
134 , (Favorites , 15)
135
136 ]
137 --
138 nodeTypeId :: NodeType -> NodeTypeId
139 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)