| 1 |
{- |
| 2 |
- Language/TEI/Show/Grammar.hs - show-like functions for grammar elements |
| 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 |
|
| 25 |
|
| 26 |
module Language.TEI.Show.Grammar |
| 27 |
( showPrimaryPOS |
| 28 |
, showVerbType |
| 29 |
, showPronounType |
| 30 |
, showGender |
| 31 |
, showPrimaryNumber |
| 32 |
, showCase |
| 33 |
, shownSingulareTantum |
| 34 |
, shownPluraleTantum |
| 35 |
) where |
| 36 |
|
| 37 |
import Data.NatLang.Grammar |
| 38 |
|
| 39 |
|
| 40 |
-- Notes: |
| 41 |
-- * The string representations are chosen according to |
| 42 |
-- Freedict/fd-dictionaries/shared/FreeDict_ontology.xml (short). |
| 43 |
-- * If not found, annotated as UNCERTAIN. |
| 44 |
-- * The existing dictionaries may serve as reference also. |
| 45 |
-- * swh-eng is the only dictionary to contain <subc> elements. |
| 46 |
-- * lat-deu is the only dictionary to contain <case> elements. |
| 47 |
-- * Some could not be found anywhere and have been guessed/invented. |
| 48 |
-- * See also <https://github.com/freedict/fd-dictionaries/wiki/FreeDict-HOWTO-%E2%80%93-Writing-A-FreeDict-Dictionary>. |
| 49 |
-- * This module encompasses show* functions, which are similar to show, as |
| 50 |
-- defined in `Show' instances. |
| 51 |
-- * They are not defined in `Show' instances, because |
| 52 |
-- a) The datatypes are shared between the Ding and TEI ASTs and it is |
| 53 |
-- inconvenient to write two complete sets of Show instances by hand. |
| 54 |
-- b) Some of the functions are not injective, they hide important |
| 55 |
-- information, which is generally undesired for `show'. |
| 56 |
-- * These problems do not exist for Usage. (UsageType has no |
| 57 |
-- representation in Ding; all other information is encoded as plain |
| 58 |
-- string) |
| 59 |
|
| 60 |
|
| 61 |
showPrimaryPOS :: PartOfSpeech -> String |
| 62 |
showPrimaryPOS Noun = "n" |
| 63 |
showPrimaryPOS (Verb _) = "v" |
| 64 |
showPrimaryPOS Adjective = "adj" |
| 65 |
showPrimaryPOS Adverb = "adv" |
| 66 |
showPrimaryPOS Preposition = "prep" |
| 67 |
showPrimaryPOS Conjunction = "conj" |
| 68 |
showPrimaryPOS Article = "art" |
| 69 |
showPrimaryPOS (Pronoun _) = "pron" |
| 70 |
showPrimaryPOS Numeral = "num" |
| 71 |
showPrimaryPOS Interjection = "int" |
| 72 |
showPrimaryPOS Particle = "ptcl" -- UNCERTAIN (common gloss) |
| 73 |
|
| 74 |
showVerbType :: VerbType -> String |
| 75 |
showVerbType Transitive = "trans" |
| 76 |
showVerbType Intransitive = "intr" |
| 77 |
showVerbType Reflexive = "refl" -- UNCERTAIN (~swh-eng) |
| 78 |
|
| 79 |
showPronounType :: PronounType -> String |
| 80 |
showPronounType Personal = "pers" -- UNCERTAIN (~swh-eng) |
| 81 |
showPronounType Interrogative = "inter" -- UNCERTAIN (~swh-eng) |
| 82 |
showPronounType Relative = "rel" -- UNCERTAIN |
| 83 |
|
| 84 |
showGender :: Gender -> String |
| 85 |
showGender Feminine = "fem" |
| 86 |
showGender Masculine = "masc" |
| 87 |
showGender Neuter = "neut" |
| 88 |
|
| 89 |
showPrimaryNumber :: Number -> String |
| 90 |
showPrimaryNumber (Singular _) = "sg" -- UNCERTAIN (~ several) |
| 91 |
showPrimaryNumber (Plural _) = "pl" -- UNCERTAIN (~ several) |
| 92 |
|
| 93 |
showCase :: Case -> String |
| 94 |
showCase Nominative = "nom" -- UNCERTAIN |
| 95 |
showCase Genitive = "gen" -- UNCERTAIN (~lat-deu) |
| 96 |
showCase Accusative = "acc" -- UNCERTAIN (~lat-deu: akk) |
| 97 |
showCase Dative = "dat" -- UNCERTAIN (~lat-deu) |
| 98 |
|
| 99 |
shownSingulareTantum :: String |
| 100 |
shownSingulareTantum = "sg only" -- UNCERTAIN |
| 101 |
|
| 102 |
shownPluraleTantum :: String |
| 103 |
shownPluraleTantum = "pl only" -- UNCERTAIN |
| 104 |
|
| 105 |
|
| 106 |
-- vi: ft=haskell ts=2 sw=2 et |