1
0
forked from GitHub/gf-rgl

- add gennumforms to common romance

- try to make preposition contraction
- try to add detcn
This commit is contained in:
odanoburu
2018-06-04 08:47:17 -03:00
parent b78bcd16ed
commit 67b526b4e7
7 changed files with 114 additions and 81 deletions

View File

@@ -3,7 +3,7 @@ concrete NounEng of Noun = CatEng ** open MorphoEng, ResEng, Prelude in {
flags optimize=all_subs ; flags optimize=all_subs ;
lin lin
DetCN det cn = { DetCN det cn = {
s = \\c => det.s ++ cn.s ! det.n ! npcase2case c ; s = \\c => det.s ++ cn.s ! det.n ! npcase2case c ;
a = agrgP3 det.n cn.g a = agrgP3 det.n cn.g
} ; } ;

View File

@@ -59,12 +59,6 @@ oper
} }
} ; } ;
genNumForms : Str -> Str -> Str -> Str -> Gender => Number => Str ;
genNumForms ms fs mp fp = table {
Masc => \\n => numForms ms mp ! n ;
Fem => \\n => numForms fs fp ! n
} ;
mkPass : Str -> Gender => Number => Str ; mkPass : Str -> Gender => Number => Str ;
-- passive form is highly predictable from singular masculine -- passive form is highly predictable from singular masculine
mkPass p' = let p = p' + [] in case p of { mkPass p' = let p = p' + [] in case p of {

View File

@@ -6,7 +6,7 @@ instance DiffPor of DiffRomance - [partAgr,vpAgrSubj,vpAgrClits] = open CommonRo
coding=utf8 ; coding=utf8 ;
param param
Prepos = P_de | P_a ; Prepos = P_de | P_a | P_em | P_por ;
VType = VHabere | VRefl ; VType = VHabere | VRefl ;
@@ -79,8 +79,11 @@ instance DiffPor of DiffRomance - [partAgr,vpAgrSubj,vpAgrClits] = open CommonRo
estarCopula = True ; estarCopula = True ;
oper oper
-- the other Cases are defined in ResRomance
dative : Case = CPrep P_a ; dative : Case = CPrep P_a ;
genitive : Case = CPrep P_de ; genitive : Case = CPrep P_de ;
locative : Case = CPrep P_em ;
ablative : Case = CPrep P_por ;
oper oper
vRefl _ = VRefl ; vRefl _ = VRefl ;
@@ -94,40 +97,32 @@ instance DiffPor of DiffRomance - [partAgr,vpAgrSubj,vpAgrClits] = open CommonRo
Nom => [] ; Nom => [] ;
Acc => [] ; Acc => [] ;
CPrep P_de => "de" ; CPrep P_de => "de" ;
CPrep P_a => "a" CPrep P_a => "a" ;
CPrep P_em => "em" ;
CPrep P_por => "por"
} ; } ;
oper oper
partitive = \_,c -> prepCase c ; partitive = \_,c -> prepCase c ;
oper oper
artDef : Bool -> Gender -> Number -> Case -> Str = \isNP,g,n,c -> artDef : Bool -> Gender -> Number -> Case -> Str ;
case isNP of { -- not sure if isNP is relevant
True => case <g,n,c> of { artDef _isNP g n c = case c of {
<Masc,Sg, _> => prepCase c ++ "o" ; Nom | Acc => genNumForms "o" "a" "os" "as" ;
<Fem, Sg, _> => prepCase c ++ "a" ; ----- ?? CPrep P_de => genNumForms "do" "da" "dos" "das" ;
<Masc,Pl, _> => prepCase c ++ "os" ; CPrep P_a => genNumForms "ao" "à" "aos" "às" ;
<Fem ,Pl, _> => prepCase c ++ "as" CPrep P_em => genNumForms "no" "na" "nos" "nas" ;
} ; CPrep P_por => genNumForms "pelo" "pela" "pelos" "pelas"
False => case <g,n,c> of { } ! g ! n ;
<Masc,Sg, CPrep P_de> => "do" ;
<Masc,Sg, CPrep P_a> => "ao" ;
<Masc,Sg, _> => prepCase c ++ "o" ;
<Fem ,Sg, CPrep P_de> => "da" ;
<Fem ,Sg, CPrep P_a> => "à" ;
<Fem, Sg, _> => prepCase c ++ "a" ;
<Masc,Pl, _> => prepCase c ++ "os" ;
<Fem ,Pl, _> => prepCase c ++ "as"
}
} ;
artIndef = \isNP,g,n,c -> case isNP of { artIndef = \isNP,g,n,c -> case isNP of {
True => case n of { True => case n of {
Sg => prepCase c ++ genForms "um" "uma" ! g ; Sg => prepCase c ++ genForms "um" "uma" ! g ;
_ => prepCase c ++ genForms "uns" "umas" ! g _ => prepCase c ++ genForms "uns" "umas" ! g
} ; } ;
_ => case n of { _ => case n of {
Sg => prepCase c ++ genForms "um" "uma" ! g ; Sg => prepCase c ++ genForms "um" "uma" ! g ;
_ => prepCase c _ => prepCase c
} }
} ; } ;

View File

@@ -1,2 +1,30 @@
concrete NounPor of Noun = CatPor ** NounRomance with concrete NounPor of Noun = CatPor ** NounRomance with
(ResRomance = ResPor) ; (ResRomance = ResPor) ** open Prelude, PhonoPor in {
lin
-- not implemented for romance languages, maybe because it can't
-- be done elegantly?
CountNP det np = heavyNPpol np.isNeg
{s = \\c => det.s ! np.a.g ! c ++ elisDe ++ (np.s ! c).ton ;
a = np.a ** {n = det.n} } ;
} ;
{--
NounPhrase : Type = {
s : Case => {c1,c2,comp,ton : Str} ;
a : Agr ;
hasClit : Bool ;
isPol : Bool ; --- only needed for French complement agr
isNeg : Bool --- needed for negative NP's such as "personne"
} ;
Det = {
s : Gender => Case => Str ;
n : Number ;
s2 : Str ; -- -ci
sp : Gender => Case => Str ; -- substantival: mien, mienne
isNeg : Bool -- negative element, e.g. aucun
} ;
Bool -> {s : Case => Str ; a : Agr} -> NounPhrase
--}

View File

@@ -1,3 +1,12 @@
resource PhonoPor = open Prelude in { resource PhonoPor = open Prelude in {
} oper
arts : pattern Str = #("o" | "os" | "a" | "as") ;
elisDe : Str ;
elisDe = pre {
#arts => "d" ++ BIND ;
_ => "de"
} ;
} ;

View File

@@ -199,16 +199,22 @@ oper
--- ---
oper oper
genForms : Str -> Str -> Gender => Str = \bon,bonne -> genForms : Str -> Str -> Gender => Str ;
table { genForms bon bonne = table {
Masc => bon ; Masc => bon ;
Fem => bonne Fem => bonne
} ; } ;
numForms : (_,_ : Str) -> Number => Str ;
-- The following macro is useful for creating the forms of -- The following macro is useful for creating the forms of
-- number-dependent tables, such as common nouns. -- number-dependent tables, such as common nouns.
numForms : (_,_ : Str) -> Number => Str = \campus, campi -> numForms campus campi = table {Sg => campus ; Pl => campi} ;
table {Sg => campus ; Pl => campi} ;
genNumForms : (_,_,_,_ : Str) -> Gender => Number => Str ;
genNumForms ms fs mp fp = table {
Masc => \\n => numForms ms mp ! n ;
Fem => \\n => numForms fs fp ! n
} ;
aagrForms : (x1,_,_,x4 : Str) -> (AAgr => Str) = \tout,toute,tous,toutes -> aagrForms : (x1,_,_,x4 : Str) -> (AAgr => Str) = \tout,toute,tous,toutes ->
table { table {

View File

@@ -16,14 +16,15 @@ oper
NounPhrase : Type = { NounPhrase : Type = {
s : Case => {c1,c2,comp,ton : Str} ; s : Case => {c1,c2,comp,ton : Str} ;
a : Agr ; a : Agr ;
hasClit : Bool ; hasClit : Bool ;
isPol : Bool ; --- only needed for French complement agr isPol : Bool ; --- only needed for French complement agr
isNeg : Bool --- needed for negative NP's such as "personne" isNeg : Bool --- needed for negative NP's such as "personne"
} ; } ;
Pronoun : Type = { Pronoun : Type = {
s : Case => {c1,c2,comp,ton : Str} ; s : Case => {c1,c2,comp,ton : Str} ;
a : Agr ; a : Agr ;
hasClit : Bool ; hasClit : Bool ;
isPol : Bool ; --- only needed for French complement agr isPol : Bool ; --- only needed for French complement agr
poss : Number => Gender => Str ---- also: substantival poss : Number => Gender => Str ---- also: substantival
} ; } ;
@@ -48,7 +49,7 @@ oper
pn2npNeg : {s : Str ; g : Gender} -> NounPhrase = pn2npPol True ; pn2npNeg : {s : Str ; g : Gender} -> NounPhrase = pn2npPol True ;
pn2npPol : Bool -> {s : Str ; g : Gender} -> NounPhrase = \isNeg, pn -> heavyNPpol isNeg { pn2npPol : Bool -> {s : Str ; g : Gender} -> NounPhrase = \isNeg, pn -> heavyNPpol isNeg {
s = \\c => prepCase c ++ pn.s ; s = \\c => prepCase c ++ pn.s ;
a = agrP3 pn.g Sg a = agrP3 pn.g Sg
} ; } ;
@@ -77,7 +78,7 @@ oper
oper oper
predV : Verb -> VP = \verb -> predV : Verb -> VP = \verb ->
let let
typ = verb.vtyp ; typ = verb.vtyp ;
in { in {
@@ -87,12 +88,12 @@ oper
clit1 = [] ; clit1 = [] ;
clit2 = [] ; clit2 = [] ;
clit3 = {s,imp = [] ; hasClit = False} ; --- refl is treated elsewhere clit3 = {s,imp = [] ; hasClit = False} ; --- refl is treated elsewhere
isNeg = False ; isNeg = False ;
comp = \\a => [] ; comp = \\a => [] ;
ext = \\p => [] ext = \\p => []
} ; } ;
insertObject : Compl -> NounPhrase -> VP -> VP = \c,np,vp -> insertObject : Compl -> NounPhrase -> VP -> VP = \c,np,vp ->
let let
obj = np.s ! c.c ; obj = np.s ! c.c ;
in { in {
@@ -110,12 +111,12 @@ oper
ext = vp.ext ; ext = vp.ext ;
} ; } ;
insertComplement : (Agr => Str) -> VP -> VP = \co,vp -> { insertComplement : (Agr => Str) -> VP -> VP = \co,vp -> {
s = vp.s ; s = vp.s ;
agr = vp.agr ; agr = vp.agr ;
clit1 = vp.clit1 ; clit1 = vp.clit1 ;
clit2 = vp.clit2 ; clit2 = vp.clit2 ;
clit3 = vp.clit3 ; clit3 = vp.clit3 ;
isNeg = vp.isNeg ; --- can be in compl as well isNeg = vp.isNeg ; --- can be in compl as well
neg = vp.neg ; neg = vp.neg ;
comp = \\a => vp.comp ! a ++ co ! a ; comp = \\a => vp.comp ! a ++ co ! a ;
@@ -123,54 +124,54 @@ oper
} ; } ;
-- Agreement with preceding relative or interrogative: -- Agreement with preceding relative or interrogative:
-- "les femmes que j'ai aimées" -- "les femmes que j'ai aimées"
insertAgr : AAgr -> VP -> VP = \ag,vp -> vp ** { insertAgr : AAgr -> VP -> VP = \ag,vp -> vp ** {
agr = vpAgrClits vp.s ag ; agr = vpAgrClits vp.s ag ;
} ; } ;
insertRefl : VP -> VP = \vp -> vp ** { insertRefl : VP -> VP = \vp -> vp ** {
s = vp.s ** {vtyp = vRefl vp.s.vtyp} ; s = vp.s ** {vtyp = vRefl vp.s.vtyp} ;
agr = vpAgrSubj vp.s ; agr = vpAgrSubj vp.s ;
} ; } ;
insertAdv : Str -> VP -> VP = \co,vp -> vp ** { insertAdv : Str -> VP -> VP = \co,vp -> vp ** {
isNeg = vp.isNeg ; --- adv could be neg isNeg = vp.isNeg ; --- adv could be neg
comp = \\a => vp.comp ! a ++ co ; comp = \\a => vp.comp ! a ++ co ;
} ; } ;
insertAdV : Str -> VP -> VP = \co,vp -> { insertAdV : Str -> VP -> VP = \co,vp -> {
s = vp.s ; s = vp.s ;
agr = vp.agr ; agr = vp.agr ;
clit1 = vp.clit1 ; clit1 = vp.clit1 ;
clit2 = vp.clit2 ; clit2 = vp.clit2 ;
clit3 = vp.clit3 ; clit3 = vp.clit3 ;
isNeg = vp.isNeg ; isNeg = vp.isNeg ;
neg = \\b => let vpn = vp.neg ! b in {p1 = vpn.p1 ; p2 = vpn.p2 ++ co} ; neg = \\b => let vpn = vp.neg ! b in {p1 = vpn.p1 ; p2 = vpn.p2 ++ co} ;
comp = vp.comp ; comp = vp.comp ;
ext = vp.ext ; ext = vp.ext ;
} ; } ;
insertClit3 : Str -> VP -> VP = \co,vp -> { insertClit3 : Str -> VP -> VP = \co,vp -> {
s = vp.s ; s = vp.s ;
agr = vp.agr ; agr = vp.agr ;
clit1 = vp.clit1 ; clit1 = vp.clit1 ;
clit2 = vp.clit2 ; clit2 = vp.clit2 ;
clit3 = addClit3 True co vp.clit3.imp vp.clit3 ; clit3 = addClit3 True co vp.clit3.imp vp.clit3 ;
isNeg = vp.isNeg ; isNeg = vp.isNeg ;
neg = vp.neg ; neg = vp.neg ;
comp = vp.comp ; comp = vp.comp ;
ext = vp.ext ; ext = vp.ext ;
} ; } ;
insertExtrapos : (RPolarity => Str) -> VP -> VP = \co,vp -> { insertExtrapos : (RPolarity => Str) -> VP -> VP = \co,vp -> {
s = vp.s ; s = vp.s ;
agr = vp.agr ; agr = vp.agr ;
clit1 = vp.clit1 ; clit1 = vp.clit1 ;
clit2 = vp.clit2 ; clit2 = vp.clit2 ;
clit3 = vp.clit3 ; clit3 = vp.clit3 ;
isNeg = vp.isNeg ; isNeg = vp.isNeg ;
neg = vp.neg ; neg = vp.neg ;
comp = vp.comp ; comp = vp.comp ;
ext = \\p => vp.ext ! p ++ co ! p ; ext = \\p => vp.ext ! p ++ co ! p ;
@@ -179,7 +180,7 @@ oper
mkVPSlash : Compl -> VP -> VP ** {c2 : Compl} = \c,vp -> vp ** {c2 = c} ; mkVPSlash : Compl -> VP -> VP ** {c2 : Compl} = \c,vp -> vp ** {c2 = c} ;
Clause : Type = {s : Direct => RTense => Anteriority => RPolarity => Mood => Str} ; Clause : Type = {s : Direct => RTense => Anteriority => RPolarity => Mood => Str} ;
-- for pos/neg variation other than negation word, e.g. "il y a du vin" / "il n'y a pas de vin" -- for pos/neg variation other than negation word, e.g. "il y a du vin" / "il n'y a pas de vin"
posNegClause : Clause -> Clause -> RPolarity -> Clause = \pos,neg,pol -> { posNegClause : Clause -> Clause -> RPolarity -> Clause = \pos,neg,pol -> {
s = \\d,t,a,b,m => case b of { s = \\d,t,a,b,m => case b of {
@@ -188,20 +189,20 @@ oper
} }
} ; } ;
mkClause : Str -> Bool -> Bool -> Agr -> VP -> mkClause : Str -> Bool -> Bool -> Agr -> VP ->
{s : Direct => RTense => Anteriority => RPolarity => Mood => Str} = {s : Direct => RTense => Anteriority => RPolarity => Mood => Str} =
mkClausePol False ; mkClausePol False ;
-- isNeg = True if subject NP is a negative element, e.g. "personne" -- isNeg = True if subject NP is a negative element, e.g. "personne"
mkClausePol : Bool -> Str -> Bool -> Bool -> Agr -> VP -> mkClausePol : Bool -> Str -> Bool -> Bool -> Agr -> VP ->
{s : Direct => RTense => Anteriority => RPolarity => Mood => Str} = {s : Direct => RTense => Anteriority => RPolarity => Mood => Str} =
\isNeg, subj, hasClit, isPol, agr, vp -> { \isNeg, subj, hasClit, isPol, agr, vp -> {
s = \\d,te,a,b,m => s = \\d,te,a,b,m =>
let let
pol : RPolarity = case <isNeg, vp.isNeg, b, d> of { pol : RPolarity = case <isNeg, vp.isNeg, b, d> of {
<_,True,RPos,_> => RNeg True ; <_,True,RPos,_> => RNeg True ;
<True,_,RPos,DInv> => RNeg True ; <True,_,RPos,DInv> => RNeg True ;
<True,_,RPos,_> => polNegDirSubj ; <True,_,RPos,_> => polNegDirSubj ;
_ => b _ => b
} ; } ;
@@ -223,7 +224,7 @@ oper
vtyp = vp.s.vtyp ; vtyp = vp.s.vtyp ;
refl = case isVRefl vtyp of { refl = case isVRefl vtyp of {
True => reflPron num per Acc ; ---- case ? True => reflPron num per Acc ; ---- case ?
_ => [] _ => []
} ; } ;
clit = refl ++ vp.clit1 ++ vp.clit2 ++ vp.clit3.s ; ---- refl first? clit = refl ++ vp.clit1 ++ vp.clit2 ++ vp.clit3.s ; ---- refl first?
@@ -237,7 +238,7 @@ oper
} ; } ;
---- part = case vp.agr of { ---- part = case vp.agr of {
---- VPAgrSubj => verb ! VPart agr.g agr.n ; ---- VPAgrSubj => verb ! VPart agr.g agr.n ;
---- VPAgrClit g n => verb ! VPart g n ---- VPAgrClit g n => verb ! VPart g n
---- } ; ---- } ;
@@ -251,7 +252,7 @@ oper
<RPasse,Simul> => <verb ! VFin (VPasse) num per, []> ; --# notpresent <RPasse,Simul> => <verb ! VFin (VPasse) num per, []> ; --# notpresent
<RPasse,Anter> => <vaux ! VFin (VPasse) num per, part> ; --# notpresent <RPasse,Anter> => <vaux ! VFin (VPasse) num per, part> ; --# notpresent
<RPres,Anter> => <vaux ! VFin (VPres m) num per, part> ; --# notpresent <RPres,Anter> => <vaux ! VFin (VPres m) num per, part> ; --# notpresent
<RPres,Simul> => <verb ! VFin (VPres m) num per, []> <RPres,Simul> => <verb ! VFin (VPres m) num per, []>
} ; } ;
fin = vps.p1 ; fin = vps.p1 ;
@@ -261,14 +262,14 @@ oper
in in
case d of { case d of {
DDir => DDir =>
subj ++ neg.p1 ++ clit ++ fin ++ neg.p2 ++ inf ++ compl ++ ext ; subj ++ neg.p1 ++ clit ++ fin ++ neg.p2 ++ inf ++ compl ++ ext ;
DInv => DInv =>
invertedClause vp.s.vtyp <te, a, num, per> hasClit neg hypt clit fin inf compl subj ext invertedClause vp.s.vtyp <te, a, num, per> hasClit neg hypt clit fin inf compl subj ext
} }
} ; } ;
-- in French, pronouns -- in French, pronouns
-- have a "-" with possibly a special verb form with "t": -- have a "-" with possibly a special verb form with "t":
-- "comment fera-t-il" vs. "comment fera Pierre" -- "comment fera-t-il" vs. "comment fera Pierre"
@@ -285,20 +286,20 @@ oper
obj = vp.s.p ++ vp.comp ! agr ++ vp.ext ! RPos ; ---- pol obj = vp.s.p ++ vp.comp ! agr ++ vp.ext ! RPos ; ---- pol
refl = case isVRefl vp.s.vtyp of { refl = case isVRefl vp.s.vtyp of {
True => reflPron agr.n agr.p Acc ; ---- case ? True => reflPron agr.n agr.p Acc ; ---- case ?
_ => [] _ => []
} ; } ;
in in
neg.p1 ++ neg.p2 ++ clitInf iform (refl ++ vp.clit1 ++ vp.clit2 ++ vp.clit3.s) inf ++ obj ; -- ne pas dormant neg.p1 ++ neg.p2 ++ clitInf iform (refl ++ vp.clit1 ++ vp.clit2 ++ vp.clit3.s) inf ++ obj ; -- ne pas dormant
} }
-- insertObject: -- insertObject:
-- p -cat=Cl -tr "la femme te l' envoie" -- p -cat=Cl -tr "la femme te l' envoie"
-- PredVP (DetCN (DetSg DefSg NoOrd) (UseN woman_N)) -- PredVP (DetCN (DetSg DefSg NoOrd) (UseN woman_N))
-- (ComplV3 send_V3 (UsePron he_Pron) (UsePron thou_Pron)) -- (ComplV3 send_V3 (UsePron he_Pron) (UsePron thou_Pron))
-- la femme te l' a envoyé -- la femme te l' a envoyé
-- --
-- p -cat=Cl -tr "la femme te lui envoie" -- p -cat=Cl -tr "la femme te lui envoie"
-- PredVP (DetCN (DetSg DefSg NoOrd) (UseN woman_N)) -- PredVP (DetCN (DetSg DefSg NoOrd) (UseN woman_N))
-- (ComplV3 send_V3 (UsePron thou_Pron) (UsePron he_Pron)) -- (ComplV3 send_V3 (UsePron thou_Pron) (UsePron he_Pron))
-- la femme te lui a envoyée -- la femme te lui a envoyée