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