1
0
forked from GitHub/gf-rgl
This commit is contained in:
Krasimir Angelov
2018-06-23 22:47:32 +02:00
12 changed files with 96 additions and 245 deletions

View File

@@ -55,6 +55,7 @@ langsCoding = [
(("norwegian","Nor"),"Scand"),
(("persian", "Pes"),""),
(("polish", "Pol"),""),
(("portuguese", "Por"), "Romance"),
(("punjabi", "Pnb"),""),
(("romanian", "Ron"),""),
(("russian", "Rus"),""),

View File

@@ -3,7 +3,7 @@ concrete NounEng of Noun = CatEng ** open MorphoEng, ResEng, Prelude in {
flags optimize=all_subs ;
lin
DetCN det cn = {
DetCN det cn = {
s = \\c => det.s ++ cn.s ! det.n ! npcase2case c ;
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 ;
-- passive form is highly predictable from singular masculine
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 ;
param
Prepos = P_de | P_a ;
Prepos = P_de | P_a | P_em | P_por ;
VType = VHabere | VRefl ;
@@ -79,8 +79,11 @@ instance DiffPor of DiffRomance - [partAgr,vpAgrSubj,vpAgrClits] = open CommonRo
estarCopula = True ;
oper
-- the other Cases are defined in ResRomance
dative : Case = CPrep P_a ;
genitive : Case = CPrep P_de ;
locative : Case = CPrep P_em ;
ablative : Case = CPrep P_por ;
oper
vRefl _ = VRefl ;
@@ -94,40 +97,32 @@ instance DiffPor of DiffRomance - [partAgr,vpAgrSubj,vpAgrClits] = open CommonRo
Nom => [] ;
Acc => [] ;
CPrep P_de => "de" ;
CPrep P_a => "a"
CPrep P_a => "a" ;
CPrep P_em => "em" ;
CPrep P_por => "por"
} ;
oper
partitive = \_,c -> prepCase c ;
oper
artDef : Bool -> Gender -> Number -> Case -> Str = \isNP,g,n,c ->
case isNP of {
True => case <g,n,c> of {
<Masc,Sg, _> => prepCase c ++ "o" ;
<Fem, Sg, _> => prepCase c ++ "a" ; ----- ??
<Masc,Pl, _> => prepCase c ++ "os" ;
<Fem ,Pl, _> => prepCase c ++ "as"
} ;
False => case <g,n,c> of {
<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"
}
} ;
artDef : Bool -> Gender -> Number -> Case -> Str ;
-- not sure if isNP is relevant
artDef _isNP g n c = case c of {
Nom | Acc => genNumForms "o" "a" "os" "as" ;
CPrep P_de => genNumForms "do" "da" "dos" "das" ;
CPrep P_a => genNumForms "ao" "à" "aos" "às" ;
CPrep P_em => genNumForms "no" "na" "nos" "nas" ;
CPrep P_por => genNumForms "pelo" "pela" "pelos" "pelas"
} ! g ! n ;
artIndef = \isNP,g,n,c -> case isNP 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
} ;
_ => case n of {
Sg => prepCase c ++ genForms "um" "uma" ! g ;
Sg => prepCase c ++ genForms "um" "uma" ! g ;
_ => prepCase c
}
} ;

View File

@@ -1,2 +1,11 @@
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 ++ (np.s ! c).ton ;
a = np.a ** {n = det.n} } ;
} ;

View File

@@ -75,10 +75,10 @@ oper
mkPrep = overload {
mkPrep : Str -> Prep = -- other preposition
\p -> {s = p ; c = Acc ; isDir = False ; lock_Prep = <>} ;
mkPrep : Str -> Prep -> Prep =
mkPrep : Str -> Case -> Prep =
-- compound prepositions, e.g. "antes de", made as mkPrep
-- "antes" genitive
\p,c -> {s = p ; c = c.c ; isDir = False ; lock_Prep = <>}
\p,c -> {s = p ; c = c ; isDir = False ; lock_Prep = <>}
} ;

View File

@@ -1,157 +0,0 @@
--# -path=alltenses
concrete ParsePor of ParseEngAbs =
TensePor,
-- CatPor,
NounPor - [PPartNP],
AdjectivePor,
NumeralPor,
SymbolPor [PN, Symb, String, CN, Card, NP, MkSymb, SymbPN, CNNumNP],
ConjunctionPor,
VerbPor - [SlashV2V, PassV2, UseCopula, ComplVV],
AdverbPor,
PhrasePor,
SentencePor,
QuestionPor,
RelativePor,
IdiomPor [NP, VP, Tense, Cl, ProgrVP, ExistNP],
ExtraPor [NP, Quant, VPSlash, VP, Tense, GenNP, PassVPSlash,
Temp, Pol, Conj, VPS, ListVPS, S, Num, CN, RP, MkVPS, BaseVPS, ConsVPS, ConjVPS, PredVPS, GenRP,
VPI, VPIForm, VPIInf, VPIPresPart, ListVPI, VV, MkVPI, BaseVPI, ConsVPI, ConjVPI, ComplVPIVV,
ClSlash, RCl, EmptyRelSlash],
DictEngPor **
open MorphoPor, ResPor, ParadigmsPor, SyntaxPor, Prelude in {
flags
literal=Symb ;
coding = utf8 ;
lin
-- missing from ExtraPor; should not really be there either
GenNP np =
let denp = (np.s ! ResPor.genitive).ton in {
s = \\_,_,_,_ => [] ;
sp = \\_,_,_ => denp ;
s2 = denp ;
isNeg = False ;
} ;
EmptyRelSlash slash = mkRCl which_RP (lin ClSlash slash) ;
that_RP = which_RP ;
UncNeg = negativePol ;
-- lexical entries
another_Quant = mkQuantifier "outro" "outra" "outros" "outras" ;
some_Quant = mkQuantifier "algum" "alguma" "alguns" "algumas" ;
anySg_Det = mkDeterminer "algum" "alguma" Sg False ; ---- also meaning "whichever" ?
each_Det = SyntaxPor.every_Det ;
but_Subj = {s = "mas" ; m = Indic} ; ---- strange to have this as Subj
{-
myself_NP = regNP "myself" singular ;
yourselfSg_NP = regNP "yourself" singular ;
himself_NP = regNP "himself" singular ;
herself_NP = regNP "herself" singular ;
itself_NP = regNP "itself" singular ;
ourself_NP = regNP "ourself" plural ;
yourselfPl_NP = regNP "yourself" plural ;
themself_NP = regNP "themself" plural ;
themselves_NP = regNP "themselves" plural ;
-}
CompoundCN num noun cn = {
s = \\n => cn.s ! n ++ "de" ++ noun.s ! num.n ;
g = cn.g
} ;
{-
DashCN noun1 noun2 = {
s = \\n,c => noun1.s ! Sg ! Nom ++ "-" ++ noun2.s ! n ! c ;
g = noun2.g
} ;
GerundN v = {
s = \\n,c => v.s ! VPresPart ;
g = Neutr
} ;
GerundAP v = {
s = \\agr => v.s ! VPresPart ;
isPre = True
} ;
-}
PastPartAP v = {
s = table {
AF g n => v.s ! VPart g n ;
_ => v.s ! VPart Masc Sg ---- the adverb form
} ;
isPre = True
} ;
{-
OrdCompar a = {s = \\c => a.s ! AAdj Compar c } ;
-}
PositAdVAdj a = {s = a.s ! Posit ! AA} ;
{-
UseQuantPN q pn = {s = \\c => q.s ! False ! Sg ++ pn.s ! npcase2case c ; a = agrgP3 Sg pn.g} ;
SlashV2V v ant p vp = insertObjc (\\a => v.c3 ++ ant.s ++ p.s ++
infVP v.typ vp ant.a p.p a)
(predVc v) ;
SlashVPIV2V v p vpi = insertObjc (\\a => p.s ++
v.c3 ++
vpi.s ! VVAux ! a)
(predVc v) ;
ComplVV v a p vp = insertObj (\\agr => a.s ++ p.s ++
infVP v.typ vp a.a p.p agr)
(predVV v) ;
-}
---- TODO: find proper expressions for OSV and OVS in Por
PredVPosv np vp = mkCl (lin NP np) (lin VP vp) ;
PredVPovs np vp = mkCl (lin NP np) (lin VP vp) ;
CompS s = {s = \\_ => "de" ++ "que" ++ s.s ! Indic} ; ---- de ?
{-
CompQS qs = {s = \\_ => qs.s ! QIndir} ;
CompVP ant p vp = {s = \\a => ant.s ++ p.s ++
infVP VVInf vp ant.a p.p a} ;
VPSlashVS vs vp =
insertObj (\\a => infVP VVInf vp Simul CPos a) (predV vs) **
{c2 = ""; gapInMiddle = False} ;
PastPartRS ant pol vps = {
s = \\agr => vps.ad ++ vps.ptp ++ vps.s2 ! agr ;
c = npNom
} ;
PresPartRS ant pol vp = {
s = \\agr => vp.ad ++ vp.prp ++ vp.s2 ! agr ;
c = npNom
} ;
ApposNP np1 np2 = {
s = \\c => np1.s ! c ++ "," ++ np2.s ! npNom ;
a = np1.a
} ;
AdAdV = cc2 ;
UttAdV adv = adv;
-}
}

View File

@@ -1,3 +1,3 @@
resource PhonoPor = open Prelude in {
}
} ;

View File

@@ -1,5 +1,5 @@
concrete StructuralPor of Structural = CatPor **
open PhonoPor, MorphoPor, ParadigmsPor, BeschPor,
open PhonoPor, MorphoPor, ParadigmsPor, BeschPor, DiffPor,
MakeStructuralPor, (X = ConstructX), (B=IrregBeschPor)
, Prelude in {
@@ -62,8 +62,8 @@ concrete StructuralPor of Structural = CatPor **
between_Prep = mkPrep "entre" ;
both7and_DConj = {s1,s2 = etConj.s ; n = Pl} ;
but_PConj = ss "mas" ;
by8agent_Prep = mkPrep "por" ;
by8means_Prep = mkPrep "por" ;
by8agent_Prep = mkPrep [] ablative ; -- por
by8means_Prep = mkPrep [] ablative ; -- por
can8know_VV = mkVV B.saber_V ;
can_VV = mkVV B.poder_V ;
during_Prep = mkPrep "durante" ;
@@ -87,7 +87,7 @@ concrete StructuralPor of Structural = CatPor **
if_then_Conj = {s1 = "se" ; s2 = "então" ;
n = Sg ; lock_Conj = <>} ;
in8front_Prep = {s = "à frente" ; c = MorphoPor.genitive ; isDir = False} ;
in_Prep = mkPrep "em" ;
in_Prep = mkPrep [] locative ;
less_CAdv = X.mkCAdv "menos" conjThan ; ----
many_Det = mkDeterminer "muitos" "muitas" Pl False ;
@@ -134,7 +134,7 @@ concrete StructuralPor of Structural = CatPor **
therefore_PConj = ss ["por isso"] ;
this_Quant = mkQuantifier "este" "esta" "estes" "estas" ;
through_Prep = mkPrep "por" ;
through_Prep = mkPrep [] ablative ; -- por
too_AdA = ss "demasiado" ; -- o certo seria demais como postfix
to_Prep = complDat ;
under_Prep = mkPrep "embaixo" ;

View File

@@ -5,9 +5,11 @@ incomplete concrete AdverbRomance of Adverb =
PositAdvAdj a = {
s = a.s ! Posit ! AA
} ;
ComparAdvAdj cadv a np = {
s = cadv.s ++ a.s ! Posit ! AA ++ cadv.p ++ (np.s ! Nom).ton
} ;
ComparAdvAdjS cadv a s = {
s = cadv.s ++ a.s ! Posit ! AA ++ cadv.p ++ s.s ! Conjunct --- ne
} ;

View File

@@ -199,16 +199,22 @@ oper
---
oper
genForms : Str -> Str -> Gender => Str = \bon,bonne ->
table {
Masc => bon ;
Fem => bonne
genForms : Str -> Str -> Gender => Str ;
genForms bon bonne = table {
Masc => bon ;
Fem => bonne
} ;
numForms : (_,_ : Str) -> Number => Str ;
-- The following macro is useful for creating the forms of
-- number-dependent tables, such as common nouns.
numForms : (_,_ : Str) -> Number => Str = \campus, campi ->
table {Sg => campus ; Pl => campi} ;
numForms campus 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 ->
table {

View File

@@ -16,14 +16,15 @@ oper
NounPhrase : Type = {
s : Case => {c1,c2,comp,ton : Str} ;
a : Agr ;
hasClit : Bool ;
hasClit : Bool ;
isPol : Bool ; --- only needed for French complement agr
isNeg : Bool --- needed for negative NP's such as "personne"
} ;
Pronoun : Type = {
s : Case => {c1,c2,comp,ton : Str} ;
a : Agr ;
hasClit : Bool ;
hasClit : Bool ;
isPol : Bool ; --- only needed for French complement agr
poss : Number => Gender => Str ---- also: substantival
} ;
@@ -48,7 +49,7 @@ oper
pn2npNeg : {s : Str ; g : Gender} -> NounPhrase = pn2npPol True ;
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
} ;
@@ -77,7 +78,7 @@ oper
oper
predV : Verb -> VP = \verb ->
predV : Verb -> VP = \verb ->
let
typ = verb.vtyp ;
in {
@@ -87,12 +88,12 @@ oper
clit1 = [] ;
clit2 = [] ;
clit3 = {s,imp = [] ; hasClit = False} ; --- refl is treated elsewhere
isNeg = False ;
isNeg = False ;
comp = \\a => [] ;
ext = \\p => []
} ;
insertObject : Compl -> NounPhrase -> VP -> VP = \c,np,vp ->
insertObject : Compl -> NounPhrase -> VP -> VP = \c,np,vp ->
let
obj = np.s ! c.c ;
in {
@@ -110,12 +111,12 @@ oper
ext = vp.ext ;
} ;
insertComplement : (Agr => Str) -> VP -> VP = \co,vp -> {
insertComplement : (Agr => Str) -> VP -> VP = \co,vp -> {
s = vp.s ;
agr = vp.agr ;
clit1 = vp.clit1 ;
clit2 = vp.clit2 ;
clit3 = vp.clit3 ;
clit1 = vp.clit1 ;
clit2 = vp.clit2 ;
clit3 = vp.clit3 ;
isNeg = vp.isNeg ; --- can be in compl as well
neg = vp.neg ;
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"
insertAgr : AAgr -> VP -> VP = \ag,vp -> vp ** {
insertAgr : AAgr -> VP -> VP = \ag,vp -> vp ** {
agr = vpAgrClits vp.s ag ;
} ;
insertRefl : VP -> VP = \vp -> vp ** {
insertRefl : VP -> VP = \vp -> vp ** {
s = vp.s ** {vtyp = vRefl vp.s.vtyp} ;
agr = vpAgrSubj vp.s ;
} ;
insertAdv : Str -> VP -> VP = \co,vp -> vp ** {
isNeg = vp.isNeg ; --- adv could be neg
insertAdv : Str -> VP -> VP = \co,vp -> vp ** {
isNeg = vp.isNeg ; --- adv could be neg
comp = \\a => vp.comp ! a ++ co ;
} ;
insertAdV : Str -> VP -> VP = \co,vp -> {
insertAdV : Str -> VP -> VP = \co,vp -> {
s = vp.s ;
agr = vp.agr ;
clit1 = vp.clit1 ;
clit2 = vp.clit2 ;
clit1 = vp.clit1 ;
clit2 = vp.clit2 ;
clit3 = vp.clit3 ;
isNeg = vp.isNeg ;
isNeg = vp.isNeg ;
neg = \\b => let vpn = vp.neg ! b in {p1 = vpn.p1 ; p2 = vpn.p2 ++ co} ;
comp = vp.comp ;
ext = vp.ext ;
} ;
insertClit3 : Str -> VP -> VP = \co,vp -> {
insertClit3 : Str -> VP -> VP = \co,vp -> {
s = vp.s ;
agr = vp.agr ;
clit1 = vp.clit1 ;
clit2 = vp.clit2 ;
clit1 = vp.clit1 ;
clit2 = vp.clit2 ;
clit3 = addClit3 True co vp.clit3.imp vp.clit3 ;
isNeg = vp.isNeg ;
isNeg = vp.isNeg ;
neg = vp.neg ;
comp = vp.comp ;
ext = vp.ext ;
} ;
insertExtrapos : (RPolarity => Str) -> VP -> VP = \co,vp -> {
insertExtrapos : (RPolarity => Str) -> VP -> VP = \co,vp -> {
s = vp.s ;
agr = vp.agr ;
clit1 = vp.clit1 ;
clit2 = vp.clit2 ;
clit1 = vp.clit1 ;
clit2 = vp.clit2 ;
clit3 = vp.clit3 ;
isNeg = vp.isNeg ;
isNeg = vp.isNeg ;
neg = vp.neg ;
comp = vp.comp ;
ext = \\p => vp.ext ! p ++ co ! p ;
@@ -179,7 +180,7 @@ oper
mkVPSlash : Compl -> VP -> VP ** {c2 : Compl} = \c,vp -> vp ** {c2 = c} ;
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"
posNegClause : Clause -> Clause -> RPolarity -> Clause = \pos,neg,pol -> {
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} =
mkClausePol False ;
-- 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} =
\isNeg, subj, hasClit, isPol, agr, vp -> {
s = \\d,te,a,b,m =>
s = \\d,te,a,b,m =>
let
pol : RPolarity = case <isNeg, vp.isNeg, b, d> of {
<_,True,RPos,_> => RNeg True ;
<True,_,RPos,DInv> => RNeg True ;
<_,True,RPos,_> => RNeg True ;
<True,_,RPos,DInv> => RNeg True ;
<True,_,RPos,_> => polNegDirSubj ;
_ => b
} ;
@@ -223,7 +224,7 @@ oper
vtyp = vp.s.vtyp ;
refl = case isVRefl vtyp of {
True => reflPron num per Acc ; ---- case ?
_ => []
_ => []
} ;
clit = refl ++ vp.clit1 ++ vp.clit2 ++ vp.clit3.s ; ---- refl first?
@@ -237,7 +238,7 @@ oper
} ;
---- part = case vp.agr of {
---- 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,Anter> => <vaux ! VFin (VPasse) 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 ;
@@ -261,14 +262,14 @@ oper
in
case d of {
DDir =>
DDir =>
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
}
} ;
-- in French, pronouns
-- in French, pronouns
-- have a "-" with possibly a special verb form with "t":
-- "comment fera-t-il" vs. "comment fera Pierre"
@@ -285,20 +286,20 @@ oper
obj = vp.s.p ++ vp.comp ! agr ++ vp.ext ! RPos ; ---- pol
refl = case isVRefl vp.s.vtyp of {
True => reflPron agr.n agr.p Acc ; ---- case ?
_ => []
_ => []
} ;
in
neg.p1 ++ neg.p2 ++ clitInf iform (refl ++ vp.clit1 ++ vp.clit2 ++ vp.clit3.s) inf ++ obj ; -- ne pas dormant
}
-- insertObject:
-- 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))
-- la femme te l' a envoyé
--
-- 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))
-- la femme te lui a envoyée