forked from GitHub/gf-rgl
the names API in more languages
This commit is contained in:
@@ -106,9 +106,11 @@ concrete CatEng of Cat = CommonX - [Pol,CAdv] ** open ResEng, Prelude in {
|
||||
N = {s : Number => Case => Str ; g : Gender} ;
|
||||
N2 = {s : Number => Case => Str ; g : Gender} ** {c2 : Str} ;
|
||||
N3 = {s : Number => Case => Str ; g : Gender} ** {c2,c3 : Str} ;
|
||||
GN, SN, PN = {s : Case => Str ; g : Gender} ;
|
||||
PN = {s : Case => Str ; g : Gender} ;
|
||||
GN = {s : Case => Str ; g : Sex} ;
|
||||
SN = {s : Sex => Case => Str; p : Case => Str} ;
|
||||
LN = {s : Case => Str;
|
||||
p : Str; -- preposition "in Scandinavia", "on the Balkans"
|
||||
prep : LNPrep; -- preposition "in Scandinavia", "on the Balkans", "at the South Pole"
|
||||
art : Bool; -- plain name "United States" vs "the United States"
|
||||
n : Number;
|
||||
} ;
|
||||
|
||||
@@ -50,36 +50,36 @@ lin
|
||||
tr (td (n.s ! Nom) ++ td (n.s ! Gen))
|
||||
) ++
|
||||
heading1 ("Adverb") ++
|
||||
paragraph (n.p ++ case n.art of {
|
||||
True => "the" ++ n.s ! Nom ;
|
||||
False => n.s ! Nom}) ;
|
||||
paragraph (case n.prep of {
|
||||
InPrep => "in" ;
|
||||
OnPrep => "on" ;
|
||||
AtPrep => "at"
|
||||
} ++
|
||||
case n.art of {
|
||||
True => "the" ++ n.s ! Nom ;
|
||||
False => n.s ! Nom
|
||||
}) ;
|
||||
} ;
|
||||
|
||||
InflectionGN = \pn -> {
|
||||
InflectionGN = \gn -> {
|
||||
t = "gn" ;
|
||||
s1 = heading1 ("Given Name" ++
|
||||
case pn.g of {
|
||||
Neutr => "";
|
||||
Masc => "(masc)";
|
||||
Fem => "(fem)"
|
||||
case gn.g of {
|
||||
Male => "(male)";
|
||||
Female => "(female)"
|
||||
}) ;
|
||||
s2 = frameTable (
|
||||
tr (th "nom" ++ th "gen") ++
|
||||
tr (td (pn.s ! Nom) ++ td (pn.s ! Gen))
|
||||
tr (td (gn.s ! Nom) ++ td (gn.s ! Gen))
|
||||
)
|
||||
} ;
|
||||
|
||||
InflectionSN = \pn -> {
|
||||
t = "sn" ;
|
||||
s1 = heading1 ("Secondary Name" ++
|
||||
case pn.g of {
|
||||
Neutr => "";
|
||||
Masc => "(masc)";
|
||||
Fem => "(fem)"
|
||||
}) ;
|
||||
s1 = heading1 "Secondary Name" ;
|
||||
s2 = frameTable (
|
||||
tr (th "nom" ++ th "gen") ++
|
||||
tr (td (pn.s ! Nom) ++ td (pn.s ! Gen))
|
||||
tr (td (pn.s ! Male ! Nom) ++ td (pn.s ! Male ! Gen))
|
||||
)
|
||||
} ;
|
||||
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
concrete NamesEng of Names = CatEng ** open Prelude, ResEng in {
|
||||
|
||||
lin GivenName gn = {s = \\c => gn.s ! npcase2case c ; a = agrgP3 Sg gn.g} ;
|
||||
lin MaleSurname, FemaleSurname = \sn -> {s = \\c => sn.s ! npcase2case c ; a = agrgP3 Sg sn.g} ;
|
||||
lin FullName gn sn = {s = \\c => gn.s ! Nom ++ sn.s ! npcase2case c ; a = agrgP3 Sg gn.g} ;
|
||||
lin GivenName gn = {
|
||||
s = \\c => gn.s ! npcase2case c ;
|
||||
a = case gn.g of {
|
||||
Male => agrgP3 Sg Masc ;
|
||||
Female => agrgP3 Sg Fem
|
||||
}
|
||||
} ;
|
||||
lin MaleSurname = \sn -> {s = \\c => sn.s ! Male ! npcase2case c ; a = agrgP3 Sg Masc} ;
|
||||
lin FemaleSurname = \sn -> {s = \\c => sn.s ! Female ! npcase2case c ; a = agrgP3 Sg Fem} ;
|
||||
lin PlSurname = \sn -> {s = \\c => sn.p ! npcase2case c ; a = agrgP3 Pl Masc} ;
|
||||
lin FullName gn sn = {
|
||||
s = \\c => gn.s ! Nom ++ sn.s ! gn.g ! npcase2case c ;
|
||||
a = case gn.g of {
|
||||
Male => agrgP3 Sg Masc ;
|
||||
Female => agrgP3 Sg Fem
|
||||
}
|
||||
} ;
|
||||
|
||||
lin UseLN n = {
|
||||
s = \\c => case n.art of {
|
||||
@@ -18,10 +32,15 @@ lin PlainLN n = {
|
||||
} ;
|
||||
|
||||
lin InLN n = {
|
||||
s = n.p ++ case n.art of {
|
||||
True => "the" ++ n.s ! Nom ;
|
||||
False => n.s ! Nom
|
||||
} ;
|
||||
s = case n.prep of {
|
||||
InPrep => "in" ;
|
||||
OnPrep => "on" ;
|
||||
AtPrep => "at"
|
||||
} ++
|
||||
case n.art of {
|
||||
True => "the" ++ n.s ! Nom ;
|
||||
False => n.s ! Nom
|
||||
} ;
|
||||
} ;
|
||||
|
||||
lin AdjLN ap n = n ** {
|
||||
|
||||
@@ -130,23 +130,6 @@ oper
|
||||
-- Proper names, with a regular genitive, are formed from strings.
|
||||
|
||||
oper
|
||||
mkLN = overload {
|
||||
mkLN : Str -> LN = \s ->
|
||||
lin LN {s = table {Gen => s + "'s" ; _ => s} ;
|
||||
p = "in" ;
|
||||
art = False ;
|
||||
n = Sg} ;
|
||||
|
||||
mkLN : Str -> Number -> LN = \s,n ->
|
||||
lin LN {s = table {Gen => s + "'s" ; _ => s} ;
|
||||
p = "in" ;
|
||||
art = False ;
|
||||
n = n} ;
|
||||
} ;
|
||||
|
||||
defLN : LN -> LN = \n -> n ** {art = True} ;
|
||||
prepLN : LN -> Str -> LN = \n,s -> n ** {p = s} ;
|
||||
|
||||
mkPN : overload {
|
||||
|
||||
mkPN : Str -> PN ;
|
||||
@@ -157,6 +140,47 @@ oper
|
||||
mkPN : N -> PN --%
|
||||
} ;
|
||||
|
||||
mkLN = overload {
|
||||
mkLN : Str -> LN = \s ->
|
||||
lin LN {s = table {Gen => s + "'s" ; _ => s} ;
|
||||
prep = InPrep ;
|
||||
art = False ;
|
||||
n = Sg} ;
|
||||
|
||||
mkLN : Str -> Number -> LN = \s,n ->
|
||||
lin LN {s = table {Gen => s + "'s" ; _ => s} ;
|
||||
prep = InPrep ;
|
||||
art = False ;
|
||||
n = n} ;
|
||||
} ;
|
||||
|
||||
defLN : LN -> LN = \n -> n ** {art = True} ;
|
||||
onLN : LN -> LN = \n -> n ** {prep = OnPrep} ;
|
||||
atLN : LN -> LN = \n -> n ** {prep = AtPrep} ;
|
||||
|
||||
mkGN = overload {
|
||||
mkGN : Str -> GN = \s ->
|
||||
lin GN {s = table {Gen => s + "'s" ; _ => s} ;
|
||||
g = Male} ;
|
||||
|
||||
mkGN : Str -> Sex -> GN = \s,g ->
|
||||
lin GN {s = table {Gen => s + "'s" ; _ => s} ;
|
||||
g = g} ;
|
||||
} ;
|
||||
|
||||
mkSN = overload {
|
||||
mkSN : Str -> SN = \s ->
|
||||
lin SN {s = \\_ => table {Gen => s + "'s" ; _ => s} ;
|
||||
p = table {Gen => s + "'s" ; _ => s}} ;
|
||||
mkSN : Str -> Str -> Str -> SN = \male,female,pl ->
|
||||
lin SN {s = table {
|
||||
Male => table {Gen => male + "'s" ; _ => male} ;
|
||||
Female => table {Gen => female + "'s" ; _ => female}
|
||||
} ;
|
||||
p = table {Gen => pl + "'s" ; _ => pl}
|
||||
} ;
|
||||
} ;
|
||||
|
||||
-- To extract the number of a noun phrase
|
||||
|
||||
ifPluralNP : NP -> Bool
|
||||
@@ -397,6 +421,8 @@ mkVoc s = lin Voc (ss s) ;
|
||||
nonhuman = Neutr ;
|
||||
masculine = Masc ;
|
||||
feminine = Fem ;
|
||||
male = Male ;
|
||||
female = Female ;
|
||||
singular = Sg ;
|
||||
plural = Pl ;
|
||||
nominative = npNom ;
|
||||
|
||||
@@ -690,4 +690,7 @@ param
|
||||
finalComma : Str = pre {"," | "." => []; "" => SOFT_BIND ++ ","; _ => []} ;
|
||||
frontComma : Str = SOFT_BIND ++ "," ;
|
||||
|
||||
param
|
||||
LNPrep = InPrep | OnPrep | AtPrep ;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user