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)
9 --import Data.ByteString (ByteString())
10 import Data.Text (Text)
11 import Data.Time (UTCTime)
12 import Data.Gargantext.Types.Node ( NodePoly
13 , HyperdataFolder , HyperdataCorpus , HyperdataDocument
14 , HyperdataFavorites, HyperdataResource
15 , HyperdataList , HyperdataScore
22 -- | Language of a Text
23 -- For simplicity, we suppose text has an homogenous language
24 data Language = EN | FR -- | DE | IT | SP
27 -- > DE == deutch (not implemented yet)
28 -- > IT == italian (not implemented yet)
29 -- > SP == spanish (not implemented yet)
30 -- > ... add your language and help us to implement it (:
32 type Ngrams = (Text, Text, Text)
34 type ErrorMessage = String
37 -- | TODO add Symbolic Node / Document
38 -- TODO make instances of Nodes
40 -- All the Database is structred like a hierachical Tree
41 -- Where a is a NodeType:
42 -- TODO force the logic of the architecture
43 data Tree a = Empty | Node' a (Tree a) (Tree a) deriving (Show)
45 data NodeType = NodeUser
46 | Folder | Project | Corpus | Document
49 | List | StopList | MainList | MapList | GroupList
50 | Score | Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
51 | Tficf | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
57 -- | NodePoly indicates that Node has a Polymorphism Type
58 type Node json = NodePoly NodeId NodeTypeId NodeUserId NodeParentId NodeName UTCTime json
59 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
62 type NodeParentId = Int
66 --type NodeUser = Node HyperdataUser
68 -- | Then a Node can be either a Folder or a Corpus or a Document
69 type Folder = Node HyperdataFolder
71 type Corpus = Node HyperdataCorpus
72 type Document = Node HyperdataDocument
74 -- | Community Manager Use Case
75 type Annuaire = Corpus
76 type Individu = Document
78 -- | Favorites Node enable Node categorization
79 type Favorites = Node HyperdataFavorites
81 -- | Favorites Node enable Swap Node with some synonyms for clarity
82 type NodeSwap = Node HyperdataResource
84 -- | Then a Node can be a List which as some synonyms
85 type List = Node HyperdataList
91 -- | Then a Node can be a Score which as some synonyms
92 type Score = Node HyperdataScore
93 type Occurrences = Score
94 type Cooccurrences = Score
95 type Specclusion = Score
96 type Genclusion = Score
99 -- TODO All these Tfidf* will be replaced with TFICF
100 type TfidfCorpus = Tficf
101 type TfidfGlobal = Tficf
102 type TirankLocal = Tficf
103 type TirankGlobal = Tficf
105 -- | Then a Node can be either a Graph or a Phylo or a Notebook
106 type Graph = Node HyperdataGraph
107 type Phylo = Node HyperdataPhylo
108 type Notebook = Node HyperdataNotebook
111 nodeTypes :: [(NodeType, NodeTypeId)]
126 , (Cooccurrences , 9)
136 , (TirankGlobal , 17)
143 nodeTypeId :: NodeType -> NodeTypeId
144 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)