| 1 |
{- |
| 2 |
- Language/Ding/Show/Grammar.hs - convert grammar annotations to strings |
| 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 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
module Language.Ding.Show.Grammar |
| 34 |
( showGLC |
| 35 |
, showPOS |
| 36 |
, showNumber |
| 37 |
, showCase |
| 38 |
) where |
| 39 |
|
| 40 |
import Data.NatLang.Grammar |
| 41 |
|
| 42 |
|
| 43 |
showGLC :: GramLexCategory -> [String] |
| 44 |
showGLC (PartOfSpeech pos) = showPOS pos |
| 45 |
showGLC (Gender gen) = pure $ showGender gen |
| 46 |
showGLC (Number num) = pure $ showNumber num |
| 47 |
showGLC (Case cas) = pure $ showCase cas |
| 48 |
|
| 49 |
showPOS :: PartOfSpeech -> [String] |
| 50 |
showPOS Noun = pure "noun" |
| 51 |
showPOS (Verb []) = pure "v" |
| 52 |
showPOS (Verb vTypes) = map showTypedVerb vTypes |
| 53 |
showPOS Adjective = pure "adj" |
| 54 |
showPOS Adverb = pure "adv" |
| 55 |
showPOS Preposition = pure "prp" |
| 56 |
showPOS Conjunction = pure "conj" |
| 57 |
showPOS Article = pure "art" |
| 58 |
showPOS (Pronoun []) = pure "pron" |
| 59 |
showPOS (Pronoun pTypes) = map showTypedPronoun pTypes |
| 60 |
showPOS Numeral = pure "num" |
| 61 |
showPOS Interjection = pure "interj" |
| 62 |
showPOS Particle = pure "particle" |
| 63 |
|
| 64 |
showTypedVerb :: VerbType -> String |
| 65 |
showTypedVerb Transitive = "vt" |
| 66 |
showTypedVerb Intransitive = "vi" |
| 67 |
showTypedVerb Reflexive = "vr" |
| 68 |
|
| 69 |
showTypedPronoun :: PronounType -> String |
| 70 |
showTypedPronoun Personal = "ppron" |
| 71 |
showTypedPronoun Interrogative = "pron interrog" |
| 72 |
showTypedPronoun Relative = "pron relativ" |
| 73 |
|
| 74 |
showGender :: Gender -> String |
| 75 |
showGender Feminine = "f" |
| 76 |
showGender Masculine = "m" |
| 77 |
showGender Neuter = "n" |
| 78 |
|
| 79 |
showNumber :: Number -> String |
| 80 |
showNumber (Singular False) = "sing" |
| 81 |
showNumber (Singular True) = "no pl" |
| 82 |
showNumber (Plural False) = "pl" |
| 83 |
showNumber (Plural True) = "no sing" |
| 84 |
|
| 85 |
showCase :: Case -> String |
| 86 |
showCase Nominative = "Nom." |
| 87 |
showCase Genitive = "Gen." |
| 88 |
showCase Accusative = "Akk." |
| 89 |
showCase Dative = "Dat." |
| 90 |
|
| 91 |
|
| 92 |
-- vi: ft=haskell ts=2 sw=2 et |