{-# LANGUAGE OverloadedStrings #-}

-- | This module provides automatic sentence generators.
module Study.Framework.Lojban.SentenceGenerators
( generateNonbridi
) where

import Core
import Util (generatorFromList)
import Data.List (intersect)
import System.Random (StdGen)
import qualified Data.Text as T

-- | Generates a random nonbridi utterance.
generateNonbridi :: Vocabulary -> StdGen -> (T.Text, StdGen)
generateNonbridi :: Vocabulary -> StdGen -> (Text, StdGen)
generateNonbridi Vocabulary
vocabulary = [Text] -> StdGen -> (Text, StdGen)
forall a. [a] -> StdGen -> (a, StdGen)
generatorFromList ([Text] -> StdGen -> (Text, StdGen))
-> [Text] -> StdGen -> (Text, StdGen)
forall a b. (a -> b) -> a -> b
$ [Text]
pronouns [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text]
nouns where
    pronouns :: [Text]
pronouns = [Text]
cmavoList [Text] -> [Text] -> [Text]
forall a. Eq a => [a] -> [a] -> [a]
`intersect` [ Text
"mi", Text
"do", Text
"ti", Text
"ta" ]
    nouns :: [Text]
nouns =
        if Text
"lo" Text -> [Text] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Text]
cmavoList then
            [Text
"lo " Text -> Text -> Text
`T.append` Text
brivla Text -> Text -> Text
`T.append` Text
" ku" | Text
brivla <- [Text]
brivlaList]
        else
            []
    cmavoList :: [Text]
cmavoList = Vocabulary -> [Text]
vocabularyCmavoList Vocabulary
vocabulary
    brivlaList :: [Text]
brivlaList = Vocabulary -> [Text]
vocabularyBrivlaList Vocabulary
vocabulary