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 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
19 -- | TODO add Symbolic Node / Document
20 -- TODO make instances of Nodes
22 -- All the Database is structred like a hierachical Tree
23 -- Where a is a NodeType:
24 data Tree a = Empty | Node' a (Tree a) (Tree a) deriving (Show)
26 --gargTree :: Tree NodeType
27 --gargTree = Node' NodeUser Empty
29 -- (Project Empty Empty)
34 data NodeType = NodeUser
35 | Folder | Project | Corpus | Document
38 | List | StopList | MainList | MapList | GroupList
39 | Score | Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
40 | Tficf | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
46 -- | NodePoly indicates that Node has a Polymorphism Type
47 type Node json = NodePoly Integer NodeTypeId Integer Integer Text UTCTime json
48 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
51 --type NodeUser = Node HyperdataUser
53 -- | Then a Node can be either a Folder or a Corpus or a Document
54 type Folder = Node HyperdataFolder
56 type Corpus = Node HyperdataCorpus
57 type Document = Node HyperdataDocument
59 -- | Community Manager Use Case
60 type Annuaire = Corpus
61 type Individu = Document
63 -- | Favorites Node enable Node categorization
64 type Favorites = Node HyperdataFavorites
66 -- | Favorites Node enable Swap Node with some synonyms for clarity
67 type NodeSwap = Node HyperdataResource
69 -- | Then a Node can be a List which as some synonyms
70 type List = Node HyperdataList
76 -- | Then a Node can be a Score which as some synonyms
77 type Score = Node HyperdataScore
78 type Occurrences = Score
79 type Cooccurrences = Score
80 type Specclusion = Score
81 type Genclusion = Score
84 -- TODO All these Tfidf* will be replaced with TFICF
85 type TfidfCorpus = Tficf
86 type TfidfGlobal = Tficf
87 type TirankLocal = Tficf
88 type TirankGlobal = Tficf
90 -- | Then a Node can be either a Graph or a Phylo or a Notebook
91 type Graph = Node HyperdataGraph
92 type Phylo = Node HyperdataPhylo
93 type Notebook = Node HyperdataNotebook
96 nodeTypes :: [(NodeType, NodeTypeId)]
111 , (Cooccurrences , 9)
121 , (TirankGlobal , 17)
128 nodeTypeId :: NodeType -> NodeTypeId
129 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)