1 {-# OPTIONS_GHC -Wno-orphans #-}
3 module Phylomemy.Indexation where
6 import Data.Map.Strict qualified as Map
7 import Data.Monoid (Monoid (..))
9 import Data.Set qualified as Set
10 import Data.Text.Short (ShortText)
11 import Data.Time (UTCTime)
12 import Data.Validity (Validity (..), declare, delve, trivialValidation)
13 import Data.Validity.Map ()
14 import Data.Validity.Set ()
15 import Data.Validity.Time ()
16 import GHC.Generics (Generic)
17 import Text.Show (Show)
21 -- | A contiguous sequence of n terms
22 newtype Ngram = Ngram ShortText
23 deriving (Eq, Generic, Ord)
26 instance Validity Ngram where
27 validate = trivialValidation
29 -- | A 'Root' is a set of `Ngram`s conveying the same meaning
30 -- (according to the analyst).
33 , rootEquivalents :: Set.Set Ngram
35 deriving (Eq, Generic, Ord, Show)
37 instance Validity Root where
40 [ delve "rootLabel" (rootLabel r)
42 "The rootLabel is not a member of the rootEquivalents"
43 (Set.notMember (rootLabel r) (rootEquivalents r))
44 , delve "rootEquivalents" (rootEquivalents r)
47 type Foundations = Set.Set Root
49 data Document = Document
50 { documentDate :: Date
51 , documentRoots :: Map.Map Root ()
53 deriving (Eq, Generic, Show)
54 instance Validity Document
59 -- , periodScales :: [Scale]
61 deriving (Eq, Generic, Show)
62 instance Validity Period
64 type Vocabulary = Map.Map Root ()