{-# OPTIONS_GHC -Wno-redundant-constraints #-}
module Language.Drasil.Development.Sentence (
phrase, plural, phrasePoss, pluralPoss,
atStart, atStart',
titleize, titleize',
toSent,
short, introduceAbb) where
import Control.Lens ((^.))
import Language.Drasil.Classes (NamedIdea(term), Idea)
import Language.Drasil.Sentence ((+:+), sParen, sentenceTerm,
sentencePlural, sentenceShort)
import qualified Language.Drasil.Sentence as S
import qualified Language.Drasil.NounPhrase as NP
import Language.Drasil.NounPhrase.Core (NPStruct(..))
import Drasil.Database.UID (HasUID(..))
toSent :: NPStruct -> S.Sentence
toSent :: NPStruct -> Sentence
toSent (S String
s) = String -> Sentence
S.S String
s
toSent (NPStruct
s1 :-: NPStruct
s2) = NPStruct -> Sentence
toSent NPStruct
s1 Sentence -> Sentence -> Sentence
S.:+: NPStruct -> Sentence
toSent NPStruct
s2
toSent (NPStruct
s1 :+: NPStruct
s2) = NPStruct -> Sentence
toSent NPStruct
s1 Sentence -> Sentence -> Sentence
S.+:+ NPStruct -> Sentence
toSent NPStruct
s2
toSent (P Symbol
p) = Symbol -> Sentence
S.P Symbol
p
short :: Idea c => c -> S.Sentence
short :: forall c. Idea c => c -> Sentence
short c
c = UID -> Sentence
sentenceShort (c
c c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid)
introduceAbb :: Idea n => n -> S.Sentence
introduceAbb :: forall c. Idea c => c -> Sentence
introduceAbb n
n = NPStruct -> Sentence
toSent (NP -> NPStruct
forall n. NounPhrase n => n -> NPStruct
NP.titleizeNP (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)) Sentence -> Sentence -> Sentence
+:+ Sentence -> Sentence
sParen (n -> Sentence
forall c. Idea c => c -> Sentence
short n
n)
atStart, atStart' :: NamedIdea n => n -> S.Sentence
atStart :: forall n. NamedIdea n => n -> Sentence
atStart n
n = NPStruct -> Sentence
toSent (NPStruct -> Sentence) -> NPStruct -> Sentence
forall a b. (a -> b) -> a -> b
$ NP -> NPStruct
forall n. NounPhrase n => n -> NPStruct
NP.atStartNP (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)
atStart' :: forall n. NamedIdea n => n -> Sentence
atStart' n
n = NPStruct -> Sentence
toSent (NPStruct -> Sentence) -> NPStruct -> Sentence
forall a b. (a -> b) -> a -> b
$ NP -> NPStruct
forall n. NounPhrase n => n -> NPStruct
NP.atStartNP' (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)
titleize, titleize' :: NamedIdea n => n -> S.Sentence
titleize :: forall n. NamedIdea n => n -> Sentence
titleize n
n = NPStruct -> Sentence
toSent (NPStruct -> Sentence) -> NPStruct -> Sentence
forall a b. (a -> b) -> a -> b
$ NP -> NPStruct
forall n. NounPhrase n => n -> NPStruct
NP.titleizeNP (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)
titleize' :: forall n. NamedIdea n => n -> Sentence
titleize' n
n = NPStruct -> Sentence
toSent (NPStruct -> Sentence) -> NPStruct -> Sentence
forall a b. (a -> b) -> a -> b
$ NP -> NPStruct
forall n. NounPhrase n => n -> NPStruct
NP.titleizeNP' (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)
phrase :: NamedIdea n => n -> S.Sentence
phrase :: forall n. NamedIdea n => n -> Sentence
phrase n
n = UID -> Sentence
sentenceTerm (n
n n -> Getting UID n UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID n UID
forall c. HasUID c => Getter c UID
Getter n UID
uid)
plural :: NamedIdea n => n -> S.Sentence
plural :: forall n. NamedIdea n => n -> Sentence
plural n
n = UID -> Sentence
sentencePlural (n
n n -> Getting UID n UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID n UID
forall c. HasUID c => Getter c UID
Getter n UID
uid)
phrasePoss, pluralPoss :: NamedIdea n => n -> S.Sentence
phrasePoss :: forall n. NamedIdea n => n -> Sentence
phrasePoss n
a = n -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase n
a Sentence -> Sentence -> Sentence
S.:+: String -> Sentence
S.S String
"'s"
pluralPoss :: forall n. NamedIdea n => n -> Sentence
pluralPoss n
a = n -> Sentence
forall n. NamedIdea n => n -> Sentence
plural n
a Sentence -> Sentence -> Sentence
S.:+: String -> Sentence
S.S String
"'"