the names API in more languages

This commit is contained in:
Krasimir Angelov
2023-08-16 19:39:22 +02:00
parent d25d648134
commit 6bc965f6c2
69 changed files with 1584 additions and 270 deletions

View File

@@ -40,6 +40,52 @@ lin
)
} ;
InflectionPN = \pn -> {
t = "pn" ;
s1 = heading1 ("Nom Propre" ++
case pn.g of {
Masc => "("+heading masculine_Parameter+")" ;
Fem => "("+heading feminine_Parameter+")"
}) ;
s2 = pn.s
} ;
InflectionGN = \gn -> {
t = "pn" ;
s1 = heading1 ("Prénom" ++
case gn.g of {
Masc => "("+heading masculine_Parameter+")" ;
Fem => "("+heading feminine_Parameter+")"
}) ;
s2 = gn.s
} ;
InflectionSN = \gn -> {
t = "pn" ;
s1 = heading1 "Nom de Famille" ;
s2 = gn.s ! Masc
} ;
InflectionLN = \ln -> {
t = "nl" ;
s1 = heading1 ("Nom de la Localisation" ++
case ln.g of {
Masc => "("+heading masculine_Parameter+")" ;
Fem => "("+heading feminine_Parameter+")"
}) ;
s2 = paragraph ln.s ++
heading2 "Adverbe" ++
paragraph (let p : {s : Str; c:Prepos} =
case ln.onPrep of {
True => {s="en"; c=PNul} ;
False => {s=""; c=P_a}
}
in p.s ++ case ln.art of {
AlwaysArt => artDef True ln.g ln.num (CPrep p.c) ++ ln.s;
_ => prepCase (CPrep p.c) ++ ln.s
})
} ;
InflectionA, InflectionA2 = \adj -> {
t = "a" ;
s1 = heading1 (nounHeading adjective_Category).s ;

View File

@@ -1,8 +1,14 @@
concrete NamesFre of Names = CatFre ** open Prelude, ResFre, CommonRomance, PhonoFre in {
lin GivenName, MaleSurname, FemaleSurname = \n -> pn2np n ;
lin GivenName = \n -> pn2np n ;
lin MaleSurname = \n -> pn2np {s = n.s ! Masc; g = Masc} ;
lin FemaleSurname = \n -> pn2np {s = n.s ! Fem; g = Fem} ;
lin PlSurname = \n -> heavyNPpol False {
s = \\c => prepCase c ++ n.pl ;
a = agrP3 Masc Pl
} ;
lin FullName gn sn = pn2np {
s = gn.s ++ sn.s ;
s = gn.s ++ sn.s ! gn.g ;
g = gn.g
} ;
@@ -21,10 +27,15 @@ lin UseLN n = heavyNP {
lin InLN n = {
s = n.p.s ++ case n.art of {
AlwaysArt => artDef True n.g n.num n.p.c ++ n.s;
_ => prepCase n.p.c ++ n.s
} ;
s = let p : {s : Str; c:Prepos} =
case n.onPrep of {
True => {s="en"; c=PNul} ;
False => {s=""; c=P_a}
}
in p.s ++ case n.art of {
AlwaysArt => artDef True n.g n.num (CPrep p.c) ++ n.s;
_ => prepCase (CPrep p.c) ++ n.s
} ;
} ;

View File

@@ -132,17 +132,38 @@ oper
-- Proper names need a string and a gender. If no gender is given, the
-- feminine is used for strings ending with "e", the masculine for other strings.
mkPN : overload {
mkPN : Str -> PN ; -- feminine if ends with "e", otherwise masculine
mkPN : Str -> Gender -> PN ; -- gender deviant from the simple rule
mkPN : N -> PN ; -- gender inherited from noun
} ;
mkGN = overload {
mkGN : (Anna : Str) -> GN = \s -> lin GN (regPN s) ; -- feminine for "-a", otherwise masculine
mkGN : (Pilar : Str) -> Gender -> GN = \s,g -> lin GN (mk2PN s g) ; -- force gender
} ;
mkSN = overload {
mkSN : Str -> SN = \s -> lin SN {s = \\_ => s; pl = s} ;
mkSN : Str -> Str -> Str -> SN = \male,female,pl -> lin SN {s = table {Masc=>male; Fem=>female}; pl = pl} ;
} ;
mkLN = overload {
mkLN : Str -> LN = \s ->
lin LN {s = s ;
onPrep=False ;
art = NoArt ;
g = Masc ;
num = Sg} ;
mkLN : Str -> Gender -> LN = \s,g ->
lin LN {s = s ;
p = {s=""; c=CPrep P_a; isDir=True} ;
onPrep=False ;
art = NoArt ;
g = g ;
num = Sg} ;
mkLN : Str -> Gender -> Number -> LN = \s,g,num ->
lin LN {s = s ;
p = {s=""; c=CPrep P_a; isDir=True} ;
onPrep=False ;
art = NoArt ;
g = g ;
num = num} ;
@@ -151,14 +172,7 @@ oper
defLN : LN -> LN = \n -> n ** {art = AlwaysArt} ;
useDefLN : LN -> LN = \n -> n ** {art = UseArt} ;
prepLN : LN -> Prep -> LN = \n,p -> n ** {p = p} ;
mkPN : overload {
mkPN : Str -> PN ; -- feminine if ends with "e", otherwise masculine
mkPN : Str -> Gender -> PN ; -- gender deviant from the simple rule
mkPN : N -> PN ; -- gender inherited from noun
} ;
enLN : LN -> LN = \n -> n ** {onPrep = True} ;
--2 Adjectives
@@ -355,8 +369,10 @@ oper
Gender = MorphoFre.Gender ;
Number = MorphoFre.Number ;
masculine = Masc ;
feminine = Fem ;
masculine, male = Masc ;
feminine, female = Fem ;
male = Masc ;
female = Fem ;
singular = Sg ;
plural = Pl ;