{-# LANGUAGE OverloadedStrings #-} -- | Kriah โ€” naming and identification. -- -- Architecture ยง3.1: -- kriah :: [(Category, Content)] -> [(Name, Category, Content)] -- "Assign stable names to distinguished categories" -- -- After havdalah separates, kriah names what was separated. -- The names come from the roots themselves โ€” a category's name -- is derived from the dominant root or domain within it. module Shoresh.Kriah ( kriah , nameCategory , NamedCategory(..) ) where import Shoresh.Types import Data.Text (Text) import qualified Data.Text as T -- | A named category โ€” the result of kriah. data NamedCategory = NamedCategory { ncName :: !Text , ncDomain :: !SemanticDomain , ncEntries :: ![ShoreshEntry] } deriving (Show) -- | Assign stable names to distinguished categories. kriah :: [(SemanticDomain, [ShoreshEntry])] -> [NamedCategory] kriah = map nameCategory -- | Name a single category from its domain and entries. -- The name is the domain name plus the most frequent root. nameCategory :: (SemanticDomain, [ShoreshEntry]) -> NamedCategory nameCategory (domain, entries) = let domName = T.pack (show domain) rootSuffix = case entries of (e:_) -> " (" <> shoreshToText (seShoresh e) <> ")" [] -> "" in NamedCategory { ncName = domName <> rootSuffix , ncDomain = domain , ncEntries = entries }