1 {-# LANGUAGE OverloadedLists #-}
3 module Language.EnglishSpec where
5 import Data.ByteString.Builder qualified as ByteString.Builder
6 import Data.GenValidity.Map ()
7 import Data.GenValidity.Sequence ()
8 import Data.GenValidity.Set ()
9 import Data.GenValidity.Text ()
10 import Data.List qualified as List
11 import Data.Map.Strict qualified as Map
12 import Data.Set qualified as Set
13 import Data.Text qualified as Text
14 import Data.Text.Encoding qualified as Text
15 import Data.Text.Lazy.Encoding qualified as Text.Lazy
16 import Data.Text.Short qualified as ShortText
17 import Data.Validity.Map ()
18 import Data.Validity.Set ()
19 import Data.Validity.Text ()
21 import Language.English
22 import Language.English qualified as English
23 import Language.Pronunciation qualified as Pron
24 import Paths_worksheets qualified as Self
25 import System.Directory qualified as IO
26 import System.FilePath (joinPath, pathSeparator, (<.>), (</>))
27 import System.FilePath.Posix qualified as File
28 import System.IO qualified as IO
30 import Text.Blaze.Html5.Attributes qualified as HA
31 import Utils.Pronunciation qualified as Pron
33 import Wiktionary qualified
34 import Worksheets.Utils.HTML (Html, className, classes, cm, styles, (!))
35 import Worksheets.Utils.HTML qualified as HTML
36 import Worksheets.Utils.IPA qualified as IPA
37 import Worksheets.Utils.Paper qualified as Paper
38 import Worksheets.Utils.Prelude
39 import Worksheets.Utils.SQL qualified as SQL
40 import Prelude (error, even, mod)
42 spec :: HasCallStack => Spec
44 -- Pron.lexerRender $ English.pronunciationDict
45 describe "pronunciation" do
47 forM_ sentences \sentence ->
48 Pron.pronunciationParserTest English.pronunciationRules sentence
51 mangleSupraSegmentalFeatures :: [IPA.Syllable []] -> [[IPA.Segment]]
52 mangleSupraSegmentalFeatures = \case
54 IPA.Syllable syl : ts -> syl : mangleSupraSegmentalFeatures ts
55 IPA.WithSuprasegmentalFeature IPA.Linking syl : ts ->
56 case mangleSupraSegmentalFeatures ts of
57 [] -> [dropSupraSegmentalFeatures syl]
58 x : xs -> (dropSupraSegmentalFeatures syl <> x) : xs
59 IPA.WithSuprasegmentalFeature _feat syl : xs ->
60 mangleSupraSegmentalFeatures (syl : xs)
63 -- cardsHtml "syllabes" $ English.syllablesTable & English.syllablesTableToHTML
65 sentences :: Set [Pron.ExampleLiteral]
71 , English.pronunciationRules