Debian Codegraph @

importers/ding2tei/src/Language/Ding/Enrich.hs

raw symbols SCIP
1 {-
2 - Language/Ding/Enrich.hs - enrich the Ding AST
3 -
4 - Copyright 2020 Einhard Leichtfuß
5 -
6 - This file is part of ding2tei-haskell.
7 -
8 - ding2tei-haskell is free software: you can redistribute it and/or modify
9 - it under the terms of the GNU Affero General Public License as published
10 - by the Free Software Foundation, either version 3 of the License, or
11 - (at your option) any later version.
12 -
13 - ding2tei-haskell is distributed in the hope that it will be useful,
14 - but WITHOUT ANY WARRANTY; without even the implied warranty of
15 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 - GNU Affero General Public License for more details.
17 -
18 - You should have received a copy of the GNU Affero General Public License
19 - along with ding2tei-haskell. If not, see <https://www.gnu.org/licenses/>.
20 -}
21
22 {-|
23 - Enrich the Ding AST with various information.
24 - This partially starts a translation towards TEI.
25 -}
26 module Language.Ding.Enrich
27 ( enrichUndirected
28 , enrichDirected
29 ) where
30
31 import Language.Ding.Enrich.Example (inferExamples)
32 import Language.Ding.Enrich.Grammar (enrichGrammar)
33 import Language.Ding.Syntax (Ding)
34 import Data.NatLang.Dictionary (Dictionary(..), Body(..))
35
36 -- | Enrich the Ding AST in a way that does not depend on the order of
37 -- languages.
38 -- That is, `enrichUndirected . inverse = inverse . enrichUndirected'.
39 enrichUndirected :: Ding -> Ding
40 enrichUndirected (Dictionary header srcLang tgtLang (Body ls))
41 = Dictionary header srcLang tgtLang $ Body $ map enrichGrammar ls
42
43 -- | Enrich the Ding AST considering it a directed dictionary, with a source
44 -- and target language.
45 -- This function affects elements in the source and target language
46 -- differently.
47 enrichDirected :: Ding -> Ding
48 enrichDirected (Dictionary header srcLang tgtLang (Body ls))
49 = Dictionary header srcLang tgtLang $ Body $ map inferExamples ls
50
51
52 -- vi: ft=haskell ts=2 sw=2 et