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.Prelude
11 import Data.Gargantext.Types.Node ( NodePoly
12 , HyperdataFolder , HyperdataCorpus , HyperdataDocument
13 , HyperdataFavorites, HyperdataResource
14 , HyperdataList , HyperdataScore
20 -- | TODO add Symbolic Node / Document
21 -- TODO make instances of Nodes
23 -- All the Database is structred like a hierachical Tree
24 -- Where a is a NodeType:
25 data Tree a = Empty | Node' a (Tree a) (Tree a) deriving (Show)
27 --gargTree :: Tree NodeType
28 --gargTree = Node' NodeUser Empty
30 -- (Project Empty Empty)
35 data NodeType = NodeUser
36 | Folder | Project | Corpus | Document
39 | List | StopList | MainList | MapList | GroupList
40 | Score | Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
41 | Tficf | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
47 -- | NodePoly indicates that Node has a Polymorphism Type
48 type Node json = NodePoly Integer NodeTypeId Integer Integer Text UTCTime json
49 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
52 --type NodeUser = Node HyperdataUser
54 -- | Then a Node can be either a Folder or a Corpus or a Document
55 type Folder = Node HyperdataFolder
57 type Corpus = Node HyperdataCorpus
58 type Document = Node HyperdataDocument
60 -- | Community Manager Use Case
61 type Annuaire = Corpus
62 type Individu = Document
64 -- | Favorites Node enable Node categorization
65 type Favorites = Node HyperdataFavorites
67 -- | Favorites Node enable Swap Node with some synonyms for clarity
68 type NodeSwap = Node HyperdataResource
70 -- | Then a Node can be a List which as some synonyms
71 type List = Node HyperdataList
77 -- | Then a Node can be a Score which as some synonyms
78 type Score = Node HyperdataScore
79 type Occurrences = Score
80 type Cooccurrences = Score
81 type Specclusion = Score
82 type Genclusion = Score
85 -- TODO All these Tfidf* will be replaced with TFICF
86 type TfidfCorpus = Tficf
87 type TfidfGlobal = Tficf
88 type TirankLocal = Tficf
89 type TirankGlobal = Tficf
91 -- | Then a Node can be either a Graph or a Phylo or a Notebook
92 type Graph = Node HyperdataGraph
93 type Phylo = Node HyperdataPhylo
94 type Notebook = Node HyperdataNotebook
97 nodeTypes :: [(NodeType, NodeTypeId)]
112 , (Cooccurrences , 9)
122 , (TirankGlobal , 17)
129 nodeTypeId :: NodeType -> NodeTypeId
130 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)