Debian Codegraph @

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

raw symbols SCIP
1 {-
2 - Language/Ding/Syntax.hs - general AST structures
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 - General Ding AST types.
24 -
25 - This does not include elements of the AST that are common to both Ding and
26 - TEI, which may instead by found in `Data.NatLang'.
27 -}
28 module Language.Ding.Syntax
29 ( Ding
30 , Header(..)
31 , Line(..)
32 , Entry(..)
33 , Group(..)
34 , Unit(..)
35 ) where
36
37 import Data.NatLang.Dictionary (Dictionary)
38 import Data.NatLang.Example (Example)
39 import Data.NatLang.Grammar (GrammarInfo)
40 import Data.NatLang.InflectedForms (InflectedForms)
41 import Data.NatLang.Usage (Usage)
42
43
44 -- | A whole dictionary (set of German-English translation pairs), together
45 -- with a header.
46 type Ding = Dictionary Header Line
47
48 -- | The header of the Ding.
49 data Header = Header
50 { headerVersion :: String
51 , headerVersionDate :: String
52 , headerCopyrightHolder :: String
53 , headerCopyrightPeriod :: String
54 , headerLicense :: String
55 , headerURL :: String
56 }
57 deriving Show
58
59 -- | A set of related entries.
60 newtype Line = Line [Entry]
61 deriving Show
62
63 -- | A pair of corresponding `Group's.
64 -- Upon parsing from the Ding, the order of languages is the same as there.
65 -- The order may be flipped later though.
66 data Entry = Entry Group Group
67 deriving (Show, Eq, Ord)
68
69 -- | A set of `Unit's matching the same translation.
70 -- It may be empty, in which case a later created corresponding TEI entry may
71 -- have zero translations (if the `Group' is on the target language's side).
72 -- If an empty `Group' is on the source language's side, it is not at all
73 -- represented in the resulting TEI.
74 newtype Group = Group [Unit]
75 deriving (Show, Eq, Ord)
76
77 -- TODO: ? Represent units being abbreviations differently?
78 -- - e.g.: add UnitType argument -- @type="abbrev"
79 -- | A single (key-)word or phrase, in one language, with annotations.
80 data Unit = Unit
81 { unitHeadword :: String
82 , unitPlain :: String -- ^ includes literal <()>-annotations
83 , unitGrammar :: [GrammarInfo]
84 , unitUsages :: [Usage]
85 , unitPrefixes :: [String]
86 , unitSuffixes :: [String]
87 , unitAbbrevs :: [String]
88 , unitInflected :: Maybe InflectedForms
89 , unitReferences :: [String] -- ~tilde references
90 , unitExamples :: [Example] -- initially none, added during enrichment
91 }
92 deriving (Show, Eq, Ord)
93
94
95 -- vi: ft=haskell ts=2 sw=2 et