forked from GitHub/gf-rgl
extend the names API
This commit is contained in:
@@ -100,7 +100,8 @@ concrete CatGer of Cat =
|
||||
N = ResGer.Noun ;
|
||||
N2 = ResGer.Noun ** {c2 : Preposition} ;
|
||||
N3 = ResGer.Noun ** {c2,c3 : Preposition} ;
|
||||
GN, SN = {s : Case => Str; g : Gender} ;
|
||||
GN = {s : Case => Str; g : Sex} ;
|
||||
SN = {s : Sex => Case => Str} ;
|
||||
PN = {s : Case => Str; g : Gender; n : Number} ;
|
||||
|
||||
-- tense with possibility to choose conjunctive forms
|
||||
|
||||
@@ -141,10 +141,13 @@ lin
|
||||
n = Pl
|
||||
} ;
|
||||
|
||||
lin GivenName, Surname = \n -> n ** { n = Sg } ;
|
||||
lin GivenName = \n -> { s = n.s; g = sex2gender n.g; n = Sg } ;
|
||||
lin MaleSurname = \n -> { s = n.s ! Male ; g = Masc; n = Sg } ;
|
||||
lin FemaleSurname = \n -> { s = n.s ! Female ; g = Fem; n = Sg } ;
|
||||
lin PlSurname = \n -> { s = n.s ! Male ; g = Masc; n = Pl } ;
|
||||
lin FullName gn sn = {
|
||||
s = \\c => gn.s ! Nom ++ sn.s ! c ;
|
||||
g = gn.g ;
|
||||
s = \\c => gn.s ! Nom ++ sn.s ! gn.g ! c ;
|
||||
g = sex2gender gn.g ;
|
||||
n = Sg
|
||||
} ;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ oper
|
||||
feminine : Gender ;
|
||||
neuter : Gender ;
|
||||
|
||||
male : Sex ;
|
||||
female : Sex ;
|
||||
|
||||
-- To abstract over case names, we define the following.
|
||||
|
||||
Case : Type ;
|
||||
@@ -144,6 +147,24 @@ mkN : overload {
|
||||
|
||||
} ;
|
||||
|
||||
mkGN : overload {
|
||||
mkGN : Str -> Sex -> GN ; -- regular name with genitive in "s"
|
||||
mkGN : (nom,gen : Str) -> Sex -> GN ; -- name with other genitive
|
||||
mkGN : (nom,acc,dat,gen : Str) -> Sex -> GN ; -- name with all case forms
|
||||
} ;
|
||||
|
||||
mkSN : overload {
|
||||
mkSN : Str -> GN ; -- regular name with genitive in "s", masculine
|
||||
|
||||
-- If only the genitive differs, two strings are needed.
|
||||
|
||||
mkSN : (nom,gen : Str) -> GN ; -- name with other genitive
|
||||
|
||||
-- In the worst case, all four forms are needed.
|
||||
|
||||
mkSN : (nom,acc,dat,gen : Str) -> GN ; -- name with all case forms
|
||||
} ;
|
||||
|
||||
-- To extract the number of a noun phrase
|
||||
|
||||
ifPluralNP : NP -> Bool
|
||||
@@ -370,6 +391,8 @@ mkV2 : overload {
|
||||
masculine = Masc ;
|
||||
feminine = Fem ;
|
||||
neuter = Neutr ;
|
||||
male = Male ;
|
||||
female = Female ;
|
||||
nominative = NPC Nom ;
|
||||
accusative = NPC Acc ;
|
||||
dative = NPC Dat ;
|
||||
@@ -484,6 +507,27 @@ mkV2 : overload {
|
||||
regPN : (Johann : Str) -> Gender -> PN ;
|
||||
-- Johann, Johanns ; Johannes, Johannes
|
||||
|
||||
mkGN = overload {
|
||||
mkGN : Str -> Sex -> GN = \nom,g -> lin GN {s = (regPN nom (sex2gender g)).s; g = g} ; -- regular name with genitive in "s"
|
||||
mkGN : (nom,gen : Str) -> Sex -> GN = \nom,gen,g -> lin GN {s = (mk2PN nom gen (sex2gender g)).s; g = g} ; -- name with other genitive
|
||||
mkGN : (nom,acc,dat,gen : Str) -> Sex -> GN = \nom,acc,dat,gen,g ->
|
||||
{s = table {Nom => nom ; Acc => acc ; Dat => dat ; Gen => gen} ;
|
||||
g = g ; lock_GN = <>}
|
||||
} ;
|
||||
|
||||
mkSN = overload {
|
||||
mkSN : Str -> SN = \s -> lin SN {s = \\_ => (regPN s Masc).s} ; -- regular name with genitive in "s", masculine
|
||||
|
||||
-- If only the genitive differs, two strings are needed.
|
||||
|
||||
mkSN : (nom,gen : Str) -> SN = \nom,gen -> lin SN {s = \\_ => (mk2PN nom gen Masc).s} ; -- name with other genitive
|
||||
|
||||
-- In the worst case, all four forms are needed.
|
||||
|
||||
mkSN : (nom,acc,dat,gen : Str) -> SN = \nom,acc,dat,gen ->
|
||||
{s = \\_ => table {Nom => nom ; Acc => acc ; Dat => dat ; Gen => gen} ;
|
||||
lock_SN = <>}
|
||||
} ;
|
||||
|
||||
mk3A : (gut,besser,beste : Str) -> A = \a,b,c ->
|
||||
let aa : Str = case a of {
|
||||
|
||||
@@ -25,6 +25,7 @@ resource ResGer = ParamX ** open Prelude in {
|
||||
param
|
||||
Case = Nom | Acc | Dat | Gen ;
|
||||
Gender = Masc | Fem | Neutr ;
|
||||
Sex = Male | Female ;
|
||||
|
||||
-- Complex $CN$s, like adjectives, have strong and weak forms.
|
||||
|
||||
@@ -1009,4 +1010,10 @@ resource ResGer = ParamX ** open Prelude in {
|
||||
subj = appPrepNP prep np
|
||||
in <subj , agr> ;
|
||||
|
||||
sex2gender : Sex -> Gender = \g ->
|
||||
case g of {
|
||||
Male => Masc ;
|
||||
Female => Fem
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user