Debian Codegraph @

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

raw symbols SCIP
1 {-
2 - Language/TEI/Syntax.hs - general AST structures
3 -
4 - Copyright 2020,2022 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 {-|
24 - The TEI AST.
25 -
26 - The types are quite closely related to TEI's XML elements (see
27 - `Language.TEI.ToXML' on how they translate.
28 -
29 - This does only support a small subset of TEI (for dictionaries), as is
30 - needed to represent the information that stems from the Ding dictionary.
31 -
32 - AST elements that are common to both Ding and TEI are to be found in
33 - `Data.NatLang'.
34 -
35 - The TEI header is not explicitly represented, instead the Ding header type
36 - is used.
37 -}
38 module Language.TEI.Syntax
39 ( TEI
40 , Entry(..)
41 , Form(..)
42 , Sense(..)
43 , Translation(..)
44 ) where
45
46 import Data.NatLang.Dictionary (Dictionary)
47 import Data.NatLang.Grammar (GrammarInfo)
48 import Data.NatLang.Usage (Usage)
49 import Data.NatLang.InflectedForms (InflectedForms)
50 import qualified Language.Ding.Syntax as Ding (Header)
51 import Language.TEI.Syntax.Reference (Ident, ReferenceGroup)
52 import Data.NatLang.Example (Example)
53
54
55 -- | A TEI dictionary, with a Ding header.
56 type TEI = Dictionary Ding.Header Entry
57
58
59 -- | A TEI entry, with a unique identifier, a form (containing the headword,
60 -- i.a.), grammar annotation and a list of senses (containing translations,
61 -- i.a.).
62 -- Note that annotated grammar information should pertain to all senses.
63 data Entry = Entry
64 { entryIdent :: Ident
65 , entryForm :: Form
66 , entryGrammar :: [GrammarInfo]
67 , entrySenses :: [Sense]
68 }
69 deriving Show
70
71
72 -- | A form, containing a single headword and potentially some related forms.
73 -- Pronunciation information, that also belongs to a `<form>' is added by a
74 -- separate tool, after TEI XML generation.
75 data Form = Form
76 { formOrth :: String -- ^ headword
77 , formAbbrevs :: [String]
78 , formInflected :: Maybe InflectedForms
79 }
80 deriving (Show, Eq, Ord)
81
82
83 -- | A sense, containing translations and annotations.
84 data Sense = Sense
85 { senseGrammar :: [GrammarInfo]
86 , senseUsages :: [Usage]
87 , senseTranslations :: [Translation]
88 , senseExamples :: [Example]
89 , senseReferences :: [ReferenceGroup]
90 -- ^ References, grouped by type.
91 -- No two reference groups with the same type should occur.
92 , senseNotes :: [String] -- ^ from suffixing Ding-<()>-annotations
93 }
94 deriving (Show, Eq, Ord)
95
96
97 -- | A translation to a headword, together with annotations. Corresponds
98 -- to `<cit type="trans" />'.
99 data Translation = Translation
100 { translationOrth :: String
101 , translationGrammar :: [GrammarInfo]
102 , translationUsages :: [Usage]
103 , translationAbbrevs :: [String]
104 , translationInflected :: Maybe InflectedForms
105 , translationNotes :: [String]
106 }
107 deriving (Show, Eq, Ord)
108
109
110 -- vi: ft=haskell ts=2 sw=2 et