mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
documentation module, implemented for German to produce inflection tables
This commit is contained in:
66
lib/src/abstract/Documentation.gf
Normal file
66
lib/src/abstract/Documentation.gf
Normal file
@@ -0,0 +1,66 @@
|
||||
abstract Documentation = Cat ** {
|
||||
|
||||
-- Generating documentation for the library, for instance, inflection tables
|
||||
-- AR 12/12/2013 under LGPL/BSD
|
||||
|
||||
cat
|
||||
Category ; -- name of category e.g. "noun"
|
||||
ParameterType ; -- name of parameter type e.g. "number"
|
||||
Parameter ; -- name of parameter e.g. "plural"
|
||||
|
||||
Heading ; -- grammatical term used as heading e.g. "Noun" ---- TODO capitalization
|
||||
Inflection ; -- inflection table
|
||||
|
||||
fun
|
||||
noun_Category : Category ;
|
||||
adjective_Category : Category ;
|
||||
verb_Category : Category ;
|
||||
|
||||
number_ParameterType : ParameterType ;
|
||||
gender_ParameterType : ParameterType ;
|
||||
case_ParameterType : ParameterType ;
|
||||
person_ParameterType : ParameterType ;
|
||||
tense_ParameterType : ParameterType ;
|
||||
degree_ParameterType : ParameterType ;
|
||||
|
||||
singular_Parameter : Parameter ;
|
||||
plural_Parameter : Parameter ;
|
||||
|
||||
masculine_Parameter : Parameter ;
|
||||
feminine_Parameter : Parameter ;
|
||||
neuter_Parameter : Parameter ;
|
||||
|
||||
nominative_Parameter : Parameter ;
|
||||
accusative_Parameter : Parameter ;
|
||||
genitive_Parameter : Parameter ;
|
||||
dative_Parameter : Parameter ;
|
||||
|
||||
imperative_Parameter : Parameter ;
|
||||
indicative_Parameter : Parameter ;
|
||||
conjunctive_Parameter : Parameter ;
|
||||
infinitive_Parameter : Parameter ;
|
||||
|
||||
present_Parameter : Parameter ;
|
||||
past_Parameter : Parameter ;
|
||||
future_Parameter : Parameter ;
|
||||
conditional_Parameter : Parameter ;
|
||||
|
||||
participle_Parameter : Parameter ;
|
||||
participle_Parameter : Parameter ;
|
||||
|
||||
positive_Parameter : Parameter ;
|
||||
comparative_Parameter : Parameter ;
|
||||
superlative_Parameter : Parameter ;
|
||||
|
||||
person1_Parameter : Parameter ;
|
||||
person2_Parameter : Parameter ;
|
||||
person3_Parameter : Parameter ;
|
||||
|
||||
nounHeading : N -> Heading ;
|
||||
|
||||
InflectionN : N -> Inflection ;
|
||||
InflectionA : A -> Inflection ;
|
||||
InflectionV : V -> Inflection ;
|
||||
InflectionV2 : V2 -> Inflection ;
|
||||
|
||||
}
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
abstract Lang =
|
||||
Grammar,
|
||||
Lexicon
|
||||
Lexicon,
|
||||
Construction,
|
||||
Documentation
|
||||
** {
|
||||
flags startcat=Phr ;
|
||||
} ;
|
||||
|
||||
108
lib/src/german/DocumentationGer.gf
Normal file
108
lib/src/german/DocumentationGer.gf
Normal file
@@ -0,0 +1,108 @@
|
||||
--# -path=.:../abstract:../common
|
||||
|
||||
concrete DocumentationGer of Documentation = CatGer ** open
|
||||
ResGer,
|
||||
ParadigmsGer,
|
||||
(G = GrammarGer),
|
||||
Prelude,
|
||||
HTML
|
||||
in {
|
||||
|
||||
|
||||
lincat
|
||||
Category = G.N ;
|
||||
ParameterType = G.N ;
|
||||
Parameter = G.N ;
|
||||
|
||||
Heading = {s : Str} ;
|
||||
Inflection = {s : Str} ;
|
||||
|
||||
|
||||
lin
|
||||
noun_Category = mkN "Substantiv" ;
|
||||
adjective_Category = mkN "Adjektiv" ;
|
||||
verb_Category = mkN "Verb" ;
|
||||
|
||||
singular_Parameter = mkN "Singular" ;
|
||||
plural_Parameter = mkN "Plural" ;
|
||||
|
||||
nominative_Parameter = mkN "Nominativ" ;
|
||||
genitive_Parameter = mkN "Genitiv" ;
|
||||
dative_Parameter = mkN "Dativ" ;
|
||||
accusative_Parameter = mkN "Akkusativ" ;
|
||||
|
||||
|
||||
|
||||
nounHeading n = ss (n.s ! Sg ! Nom) ;
|
||||
|
||||
oper
|
||||
tdf : Str -> Str = \s -> td (intag "i" s) ;
|
||||
heading : N -> Str = \n -> (nounHeading n).s ;
|
||||
lin
|
||||
InflectionN noun = {
|
||||
s = heading1 (heading noun_Category) ++ frameTable (
|
||||
tr (th "" ++ th (heading singular_Parameter) ++ th (heading plural_Parameter) ) ++
|
||||
tr (th (heading nominative_Parameter) ++ tdf (noun.s ! Sg ! Nom) ++ tdf (noun.s ! Pl ! Nom)) ++
|
||||
tr (th (heading genitive_Parameter) ++ tdf (noun.s ! Sg ! Gen) ++ tdf (noun.s ! Pl ! Gen)) ++
|
||||
tr (th (heading dative_Parameter) ++ tdf (noun.s ! Sg ! Dat) ++ tdf (noun.s ! Pl ! Dat)) ++
|
||||
tr (th (heading accusative_Parameter) ++ tdf (noun.s ! Sg ! Acc) ++ tdf (noun.s ! Pl ! Acc))
|
||||
)
|
||||
} ;
|
||||
|
||||
InflectionA adj =
|
||||
let
|
||||
gforms : Degree -> ResGer.Case -> Str = \d,c ->
|
||||
tdf (adj.s ! d ! (AMod (GSg Masc) c)) ++
|
||||
tdf (adj.s ! d ! (AMod (GSg Fem) c)) ++
|
||||
tdf (adj.s ! d ! (AMod (GSg Neutr) c)) ++
|
||||
tdf (adj.s ! d ! (AMod GPl c)) ;
|
||||
dtable : Str -> Degree -> Str = \s,d ->
|
||||
paragraph (heading2 s ++ frameTable (
|
||||
tr (th [] ++ th "Maskulinum" ++ th "Femininum" ++ th "Neutrum" ++ th "Plural") ++
|
||||
tr (th "Nominativ" ++ gforms d Nom) ++
|
||||
tr (th "Genitiv" ++ gforms d Gen) ++
|
||||
tr (th "Dativ" ++ gforms d Dat) ++
|
||||
tr (th "Akkusativ" ++ gforms d Acc) ++
|
||||
tr (th "Prädikativ" ++ intagAttr "td" "colspan=4" (adj.s ! d ! APred))
|
||||
))
|
||||
in {
|
||||
s = heading1 (nounHeading adjective_Category).s ++
|
||||
dtable "Positiv" Posit ++ dtable "Komparativ" Compar ++ dtable "Superlativ" Superl ;
|
||||
} ;
|
||||
|
||||
InflectionV, InflectionV2 = \verb ->
|
||||
let
|
||||
vfin : VForm -> Str = \f ->
|
||||
verb.s ! f ++ verb.prefix ;
|
||||
gforms : Number -> Person -> Str = \n,p ->
|
||||
tdf (vfin (VFin False (VPresInd n p))) ++
|
||||
tdf (vfin (VFin False (VPresSubj n p)))
|
||||
++ tdf (vfin (VFin False (VImpfInd n p))) --# notpresent
|
||||
++ tdf (vfin (VFin False (VImpfSubj n p))) --# notpresent
|
||||
;
|
||||
in {
|
||||
s =
|
||||
heading1 (nounHeading verb_Category).s ++
|
||||
paragraph (frameTable (
|
||||
tr (th "" ++ intagAttr "th" "colspan=2" "Präsens" ++ intagAttr "th" "colspan=2" "Präteritum") ++
|
||||
tr (th "" ++ th "Indikativ" ++ th "Konjunktiv I" ++ th "Indikativ" ++ th "Konjunktiv II") ++
|
||||
tr (th "Sg.1" ++ gforms Sg P1) ++
|
||||
tr (th "Sg.2" ++ gforms Sg P2) ++
|
||||
tr (th "Sg.3" ++ gforms Sg P3) ++
|
||||
tr (th "Pl.1" ++ gforms Pl P1) ++
|
||||
tr (th "Pl.2" ++ gforms Pl P2) ++
|
||||
tr (th "Pl.3" ++ gforms Pl P3)
|
||||
)) ++
|
||||
paragraph (
|
||||
frameTable (
|
||||
tr (th "Imperativ Sg.2" ++ tdf (vfin (VImper Sg))) ++
|
||||
tr (th "Imperativ Pl.2" ++ tdf (vfin (VImper Pl))) ++
|
||||
tr (th "Infinitiv" ++ tdf (verb.s ! (VInf False))) ++
|
||||
tr (th "Präsespartizip" ++ tdf (verb.s ! (VPresPart APred))) ++
|
||||
tr (th "Perfektpartizip" ++ tdf (verb.s ! (VPastPart APred))) ++
|
||||
tr (th "Hilfsverb" ++ td (case verb.aux of {VHaben => "haben" ; VSein => "sein"}))
|
||||
))
|
||||
} ;
|
||||
|
||||
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
concrete LangGer of Lang =
|
||||
GrammarGer,
|
||||
LexiconGer
|
||||
LexiconGer,
|
||||
ConstructionGer,
|
||||
DocumentationGer
|
||||
** {
|
||||
|
||||
flags startcat = Phr ; unlexer = text ; lexer = text ;
|
||||
|
||||
@@ -14,13 +14,14 @@ concrete ParseGer of ParseEngAbs =
|
||||
RelativeGer,
|
||||
IdiomGer [NP, VP, Tense, Cl, ProgrVP, ExistNP, SelfAdvVP, SelfAdVVP, SelfNP],
|
||||
ConstructionGer,
|
||||
DocumentationGer,
|
||||
ExtraGer [NP, Quant, VPSlash, VP, Tense, GenNP, PassVPSlash, PassAgentVPSlash,
|
||||
Temp, Pol, Conj, VPS, ListVPS, S, MkVPS, BaseVPS, ConsVPS, ConjVPS, PredVPS,
|
||||
VPI, VPIForm, VPIInf, VPIPresPart, ListVPI, VV, MkVPI, BaseVPI, ConsVPI, ConjVPI, ComplVPIVV,
|
||||
ClSlash, RCl, EmptyRelSlash],
|
||||
|
||||
DictEngGer **
|
||||
open MorphoGer, ResGer, ParadigmsGer, SyntaxGer, Prelude in {
|
||||
open MorphoGer, ResGer, ParadigmsGer, SyntaxGer, Prelude, HTML in {
|
||||
|
||||
flags literal=Symb ; coding = utf8 ;
|
||||
|
||||
@@ -123,4 +124,5 @@ lin
|
||||
|
||||
UttAdV adv = adv;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user