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 -- TODO force the logic of the architecture
25 data Tree a = Empty | Node' a (Tree a) (Tree a) deriving (Show)
27 data NodeType = NodeUser
28 | Folder | Project | Corpus | Document
31 | List | StopList | MainList | MapList | GroupList
32 | Score | Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
33 | Tficf | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
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
44 type NodeParentId = Int
48 --type NodeUser = Node HyperdataUser
50 -- | Then a Node can be either a Folder or a Corpus or a Document
51 type Folder = Node HyperdataFolder
53 type Corpus = Node HyperdataCorpus
54 type Document = Node HyperdataDocument
56 -- | Community Manager Use Case
57 type Annuaire = Corpus
58 type Individu = Document
60 -- | Favorites Node enable Node categorization
61 type Favorites = Node HyperdataFavorites
63 -- | Favorites Node enable Swap Node with some synonyms for clarity
64 type NodeSwap = Node HyperdataResource
66 -- | Then a Node can be a List which as some synonyms
67 type List = Node HyperdataList
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
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
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
93 nodeTypes :: [(NodeType, NodeTypeId)]
108 , (Cooccurrences , 9)
118 , (TirankGlobal , 17)
125 nodeTypeId :: NodeType -> NodeTypeId
126 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)