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