1
0
forked from GitHub/gf-core

working through translator/Extensions with some reorganization and generalizations

This commit is contained in:
aarne
2014-01-22 14:44:56 +00:00
parent fca176cbbf
commit 1ca7e33ea6
14 changed files with 179 additions and 131 deletions

View File

@@ -28,6 +28,7 @@ This will take a long time (ten minutes or more) and will probably require at le
```
with obviously the possibility to vary the source and the target language.
4. To modify the sources, work on the files in
```
GF/lib/src/translator/

View File

@@ -95,4 +95,9 @@ abstract Extra = Cat ** {
ComplBareVS : VS -> S -> VP ; -- say she runs
SlashBareV2S : V2S -> S -> VPSlash ; -- answer (to him) it is good
-- front the extraposed part
FrontExtPredVP : NP -> VP -> Cl ; -- I am here, she said
InvFrontExtPredVP : NP -> VP -> Cl ; -- I am here, said she
}

View File

@@ -89,8 +89,8 @@ concrete ExtraEng of ExtraEngAbs = CatEng **
IAdvAdv adv = {s = "how" ++ adv.s} ;
PartVP vp = {
s = \\a => vp.ad ! a ++ vp.prp ++ vp.s2 ! a ;
isPre = False ---- depends on whether there are complements
s = \\a => vp.ad ! a ++ vp.prp ++ vp.s2 ! a ++ vp.ext ;
isPre = vp.isSimple -- depends on whether there are complements
} ;
EmbedPresPart vp = {s = infVP VVPresPart vp Simul CPos (agrP3 Sg)} ; --- agr
@@ -162,6 +162,7 @@ lin
inf = be.inf ;
ad = \\_ => [] ;
s2 = \\a => vps.ad ! a ++ ppt ++ vps.p ++ ag ++ vps.s2 ! a ++ vps.c2 ; ---- place of agent
isSimple = False ;
ext = vps.ext
} ;
@@ -210,6 +211,36 @@ lin
CompoundCN a b = {s = \\n,c => a.s ! Sg ! Nom ++ b.s ! n ! c ; g = b.g} ;
FrontExtPredVP np vp = {
s = \\t,a,b,o =>
let
subj = np.s ! npNom ;
agr = np.a ;
verb = vp.s ! t ! a ! b ! o ! agr ;
compl = vp.s2 ! agr
in
case o of {
ODir _ => vp.ext ++ frontComma ++ subj ++ verb.aux ++ verb.adv ++ vp.ad ! agr ++ verb.fin ++ verb.inf ++ vp.p ++ compl ;
OQuest => verb.aux ++ subj ++ verb.adv ++ vp.ad ! agr ++ verb.fin ++ verb.inf ++ vp.p ++ compl ++ vp.ext
}
} ;
InvFrontExtPredVP np vp = {
s = \\t,a,b,o =>
let
subj = np.s ! npNom ;
agr = np.a ;
verb = vp.s ! t ! a ! b ! o ! agr ;
compl = vp.s2 ! agr
in
case o of {
ODir _ => vp.ext ++ verb.aux ++ verb.adv ++ vp.ad ! agr ++ verb.fin ++ subj ++ verb.inf ++ vp.p ++ compl ;
OQuest => verb.aux ++ subj ++ verb.adv ++ vp.ad ! agr ++ verb.fin ++ verb.inf ++ vp.p ++ compl ++ vp.ext
}
} ;
oper
unc : CPolarity -> CPolarity = \x -> case x of {
CNeg _ => CNeg False ;

View File

@@ -237,7 +237,8 @@ param
inf : Str ; -- the infinitive form ; VerbForms would be the logical place
ad : Agr => Str ; -- sentence adverb (can be Xself, hence Agr)
s2 : Agr => Str ; -- complement
ext : Str -- extreposed field such as S, QS, VP
ext : Str ; -- extreposed field such as S, QS, VP
isSimple : Bool -- regulates the place of participle used as adjective
} ;
@@ -293,6 +294,7 @@ param
inf = verb.s ! VInf ;
ad = \\_ => [] ;
ext = [] ;
isSimple = True ; ---- but really depends on whether p == []
s2 = \\a => if_then_Str verb.isRefl (reflPron ! a) []
} ;
@@ -351,6 +353,7 @@ param
inf = verb.inf ;
ad = \\_ => [] ;
ext = [] ;
isSimple = True ;
s2 = \\_ => []
} ;
@@ -374,6 +377,7 @@ param
inf = vp.inf ;
ad = vp.ad ;
s2 = \\a => vp.s2 ! a ++ obj ! a ;
isSimple = False ;
ext = vp.ext
} ;
@@ -385,6 +389,7 @@ param
inf = vp.inf ;
ad = vp.ad ;
s2 = \\a => obj ! a ++ vp.s2 ! a ;
isSimple = False ;
ext = vp.ext
} ;
@@ -402,6 +407,7 @@ param
inf = vp.inf ;
ad = vp.ad ;
s2 = \\a => obj ! a ++ vp.s2 ! a ++ vp.p ; -- and put it here ; corresponds to insertObjPre
isSimple = False ;
ext = vp.ext
} ;
@@ -417,6 +423,7 @@ param
inf = vp.inf ;
ad = \\a => vp.ad ! a ++ ad ! a ;
s2 = \\a => vp.s2 ! a ;
isSimple = False ;
ext = vp.ext
} ;
@@ -428,6 +435,7 @@ param
inf = vp.inf ;
ad = vp.ad ;
s2 = vp.s2 ;
isSimple = False ;
ext = vp.ext ++ e --- there should be at most one, one might think; but: I would say that it will be raining if I saw clouds
} ;

View File

@@ -21,6 +21,11 @@ fun
ConjVPS : Conj -> [VPS] -> VPS ;
PredVPS : NP -> VPS -> S ;
---- merge VPS and VPI
---- MkVPS, BaseVPS, ConsVPS, ConjVPS, PredVPS,
---- VPIForm, VPIInf, VPIPresPart, MkVPI, BaseVPI, ConsVPI, ConjVPI, ComplVPIVV,
-- generalizing Grammar
PassVPSlash : VPSlash -> VP ; -- be forced to sleep
@@ -28,6 +33,9 @@ fun
ComplVV : VV -> Ant -> Pol -> VP -> VP ; -- want not to have slept
PredFrontVS : Temp -> NP -> VS -> S -> S ; -- I am here, she said -- no negation
PredFrontVQ : Temp -> NP -> VQ -> QS -> S ; -- are you here, she asked -- no negation; direct order
---- merge?
SlashV2V : V2V -> Ant -> Pol -> VP -> VPSlash ; -- force (her) not to have slept
SlashVPIV2V : V2V -> Pol -> VPI -> VPSlash ; -- force (her) not to sleep and dream
@@ -39,40 +47,18 @@ fun
GenIP : IP -> IQuant ; -- whose
GenRP : Num -> CN -> RP ; -- whose car(s)
---- should be covered by variants
---- ComplBareVS : VS -> S -> VP ; -- know you go
---- SlashBareV2S : V2S -> S -> VPSlash ; -- answer (to him) it is good
---- ComplSlashPartLast : VPSlash -> NP -> VP ;
CompoundCN : N -> CN -> CN ; -- control system / controls system / control-system
---- merge VPS and VPI
---- MkVPS, BaseVPS, ConsVPS, ConjVPS, PredVPS,
---- VPIForm, VPIInf, VPIPresPart, MkVPI, BaseVPI, ConsVPI, ConjVPI, ComplVPIVV,
GerundCN : VP -> CN ; -- publishing of the document (can get a determiner)
GerundNP : VP -> NP ; -- publishing the document (by nature definite)
GerundAdv : VP -> Adv ; -- publishing the document (prepositionless adverb)
PresPartAP : VP -> AP ; -- sleeping (man), (man) sleeping in the car
---- merge these two? --- Sg/Pl CN CN CN --- four wheel drive, random number generator
CompoundCN : Num -> N -> CN -> CN ;
DashCN : N -> N -> N ;
PastPartAP : VPSlash -> AP ; -- lost (opportunity) ; (opportunity) lost in space
PastPartAgentAP : VPSlash -> NP -> AP ; -- (opportunity) lost by the company
---- merge ?
---- NominalizeVPSlashNP : VPSlash -> NP -> NP ; -- publishing of the document
---- EmbedPresPart : VP -> SC ; -- looking at Mary (is fun)
GerundN : V -> N ; -- sleeping
---- merge ?
---- PartVP : VP -> AP ; -- (man) looking at Mary
GerundAP : V -> AP ; -- sleeping (man)
PastPartAP : V2 -> AP ; -- lost (opportunity) --- gen to VPSLash
---- why is this needed?
OrdCompar : A -> Ord ; -- (my) better (side)
UseQuantPN : Quant -> PN -> NP; -- this John
SlashSlashV2V : V2V -> Ant -> Pol -> VPSlash -> VPSlash ; ---- what is this?
---- eliminate as topicalizations
PredVPosv,PredVPovs : NP -> VP -> Cl ;
UseQuantPN : Quant -> PN -> NP; -- this John
---- merge with IdRP?
that_RP : RP ;
@@ -95,5 +81,35 @@ fun
CompS : S -> Comp ; -- (the fact is) that she sleeps
CompQS : QS -> Comp ; -- (the question is) who sleeps
CompVP : Ant -> Pol -> VP -> Comp ; -- (she is) to go
SlashSlashV2V : V2V -> Ant -> Pol -> VPSlash -> VPSlash ; -- induce them to sell (it) -- analogous to Verb.SlashVV
}
{-
-- changes from ParseEngAbs
ComplBareVS -> ComplVS -- as variant
SlashBareV2S -> SlashV2S -- as variant
ComplSlashPartLast -> ComplSlash -- as variant
CompoundCN Sg/Pl -> CompoundCN -- as variants
DashCN -> CompoundCN -- as variant
GerundN -> GerundCN -- special case: now CN
-> GerundNP -- an NP version without determiner
-> GerundAdv -- an Adv version without determiner or preposition
GerundAP -> PresPartAP -- special case: now with a VP argument
PastPartAP -> PastPartAP -- now with VPSlash argument
-> PastPartAgentAP -- VPSlash + by NP
OrdCompar -> UseComparA -- the only use in PTB reduces to this standard RGL function
PredVPosv -> PredFrontVS, PredFrontVQ -- restricted to the special case actually occurring in PTB
PredVPovs -> -- inversion treated as variant: I am here, said she
-}

View File

@@ -36,8 +36,8 @@ lin
EmptyRelSlash = E.EmptyRelSlash ;
lin
CompoundCN num noun cn = {
s = \\nf => num.s ! CFNeut Indef ++ (noun.rel ! nform2aform nf cn.g) ++ (cn.s ! (indefNForm nf)) ;
CompoundCN noun cn = {
s = \\nf => (noun.rel ! nform2aform nf cn.g) ++ (cn.s ! (indefNForm nf)) ;
g = cn.g
} ;

View File

@@ -44,8 +44,7 @@ lin
-- but_Subj = {s = "pero" ; m = Indic} ; ---- strange to have this as Subj
CompoundCN num noun cn = {s = num.s ++ noun.s ++ cn.s ; c = cn.c} ; ----
DashCN noun cn = {s = noun.s ++ cn.s ; c = cn.c} ; ----
CompoundCN noun cn = {s = noun.s ++ cn.s ; c = cn.c} ; ----
GerundN v = {
s = v.s ;
@@ -59,7 +58,7 @@ DashCN noun cn = {s = noun.s ++ cn.s ; c = cn.c} ; ----
} ;
PastPartAP v = {
s = v.s ++ de_s ;
s = v.verb.s ++ de_s ; ----
monoSyl = False ;
hasAdA = True ; ---
} ;

View File

@@ -33,32 +33,48 @@ lin
EmptyRelSlash = E.EmptyRelSlash ;
lin
CompoundCN num noun cn = {
s = \\n,c => num.s ! Nom ++ noun.s ! num.n ! Nom ++ cn.s ! n ! c ;
CompoundCN noun cn = {
s = (\\n,c => noun.s ! Sg ! Nom ++ cn.s ! n ! c)
| (\\n,c => noun.s ! Pl ! Nom ++ cn.s ! n ! c)
| (\\n,c => noun.s ! Sg ! Nom ++ Predef.BIND ++ "-" ++ Predef.BIND ++ cn.s ! n ! c)
| (\\n,c => noun.s ! Pl ! Nom ++ Predef.BIND ++ "-" ++ Predef.BIND ++ cn.s ! n ! c)
;
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
} ;
GerundCN vp = {
s = \\n,c => vp.ad ! AgP3Sg Neutr ++ vp.prp ++
case <n,c> of {
<Sg,Nom> => "" ;
<Sg,Gen> => Predef.BIND ++ "'s" ;
<Pl,Nom> => Predef.BIND ++ "s" ;
<Pl,Gen> => Predef.BIND ++ "s'"
} ++
vp.s2 ! AgP3Sg Neutr ++ vp.ext ;
g = Neutr
} ;
PastPartAP v = {
s = \\agr => v.s ! VPPart ;
isPre = True
} ;
GerundNP vp =
let a = AgP3Sg Neutr
in
{s = \\_ => vp.ad ! a ++ vp.prp ++ vp.s2 ! a ++ vp.ext ; a = a} ;
OrdCompar a = {s = \\c => a.s ! AAdj Compar c } ;
GerundAdv vp =
let a = AgP3Sg Neutr
in
{s = vp.ad ! a ++ vp.prp ++ vp.s2 ! a ++ vp.ext} ;
PresPartAP = E.PartVP ;
PastPartAP vp = {
s = \\a => vp.ad ! a ++ vp.ptp ++ vp.c2 ++ vp.s2 ! a ++ vp.ext ;
isPre = vp.isSimple -- depends on whether there are complements
} ;
PastPartAgentAP vp np = {
s = \\a => vp.ad ! a ++ vp.ptp ++ vp.c2 ++ vp.s2 ! a ++ "by" ++ np.s ! NPAcc ++ vp.ext ;
isPre = vp.isSimple -- depends on whether there are complements
} ;
PositAdVAdj a = {s = a.s ! AAdv} ;
@@ -80,28 +96,18 @@ lin
infVP v.typ vp a.a p.p agr)
(predVV v) ;
PredVPosv np vp = {
s = \\t,a,b,o =>
let
verb = vp.s ! t ! a ! b ! o ! np.a ;
compl = vp.s2 ! np.a
in
case o of {
ODir _ => compl ++ frontComma ++ np.s ! npNom ++ verb.aux ++ vp.ad ! np.a ++ verb.fin ++ verb.adv ++ verb.inf ;
OQuest => verb.aux ++ compl ++ frontComma ++ np.s ! npNom ++ verb.adv ++ vp.ad ! np.a ++ verb.fin ++ verb.inf
}
PredFrontVS t np vs s =
let
cl = mkClause (np.s ! npNom) np.a (predV vs) | E.InvFrontExtPredVP np (predV vs)
in {
s = s.s ++ frontComma ++ t.s ++ t.s ++ cl.s ! t.t ! t.a ! CPos ! oDir
} ;
PredVPovs np vp = {
s = \\t,a,b,o =>
let
verb = vp.s ! t ! a ! b ! o ! np.a ;
compl = vp.s2 ! np.a
in
case o of {
ODir _ => compl ++ frontComma ++ verb.aux ++ verb.adv ++ vp.ad ! np.a ++ verb.fin ++ verb.inf ++ np.s ! npNom ;
OQuest => verb.aux ++ compl ++ verb.adv ++ vp.ad ! np.a ++ verb.fin ++ verb.inf ++ np.s ! npNom
}
PredFrontVQ t np vs s =
let
cl = mkClause (np.s ! npNom) np.a (predV vs) | E.InvFrontExtPredVP np (predV vs)
in {
s = s.s ! QDir ++ frontComma ++ t.s ++ cl.s ! t.t ! t.a ! CPos ! oDir
} ;
that_RP = {

View File

@@ -47,17 +47,12 @@ lin
}
) ;
CompoundCN num noun cn = {
s = \\nf => num.s ! Sg ! Nom ++ noun.s ! 10 ++ BIND ++ cn.s ! nf ;
CompoundCN noun cn = {
s = \\nf => noun.s ! 10 ++ BIND ++ cn.s ! nf ;
h = cn.h
} ;
DashCN noun1 noun2 = {
s = \\nf => noun1.s ! 10 ++ BIND ++ noun2.s ! nf ;
h = noun2.h
} ;
PastPartAP v = {s = \\_,nf => (sverb2verbSep v).s ! PastPartPass (AN nf)} ;
---- PastPartAP vp = {s = \\_,nf => (sverb2verbSep v).s ! PastPartPass (AN nf)} ;
PredVPosv np vp = mkCl np vp ; ----

View File

@@ -48,17 +48,12 @@ lin
lin
CompoundCN num noun cn = {
s = \\n => cn.s ! n ++ elisDe ++ noun.s ! num.n ;
CompoundCN noun cn = {
s = \\n => cn.s ! n ++ elisDe ++ noun.s ! Sg ;
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
@@ -68,7 +63,7 @@ lin
s = \\agr => v.s ! VPresPart ;
isPre = True
} ;
-}
-- }
PastPartAP v = {
s = table {
@@ -78,7 +73,7 @@ lin
isPre = True
} ;
{-
--{-
OrdCompar a = {s = \\c => a.s ! AAdj Compar c } ;
-}

View File

@@ -63,17 +63,11 @@ lin
PredVPosv = G.PredVP;
PredVPovs = G.PredVP;
CompoundCN num noun cn = {
s = \\a,n,c => num.s ! noun.g ! Nom ++ glue (noun.s ! num.n ! Nom) (cn.s ! a ! n ! c) ;
CompoundCN noun cn = {
s = \\a,n,c => glue (noun.s ! Sg ! Nom) (cn.s ! a ! n ! c) ;
g = cn.g
} ;
DashCN noun1 noun2 = { -- type-checking
s = \\n,c => glue (noun1.s ! Sg ! Nom) (noun2.s ! n ! c) ;
g = noun2.g
} ;
GerundN v = { -- parsing
s = \\n,c => v.s ! VInf False ; --- formalisieren, not formalisierung
g = Neutr

View File

@@ -37,16 +37,11 @@ lin
lin
CompoundCN num noun cn = {
s = \\n,c => num.s ++ cn.s ! n ! c ++ noun.s ! num.n ! Dir;
CompoundCN noun cn = {
s = \\n,c => cn.s ! Sg ! Dir ++ noun.s ! n ! c;
g = cn.g
} ;
DashCN noun1 noun2 = {
s = \\n,c => noun1.s ! n ! Dir ++ "-" ++ noun2.s ! n ! c ;
g = noun2.g
} ;
GerundN v = {
s = \\n,c => v.cvp ++ v.s ! Inf ; -- v.s ! VF Imperf Pers2_Casual n Masc ++ hwa (Ag Masc n Pers2_Casual) ; --the main verb of compound verbs
g = Masc
@@ -56,9 +51,9 @@ lin
s = \\n,g,_,_ => v.cvp ++ v.s ! VF Imperf Pers2_Casual n g ++ hwa (Ag g n Pers2_Casual) ;
} ;
PastPartAP v = {
s = \\n,g,_,_ => v.cvp ++ v.s ! VF Imperf Pers2_Casual n g ; -- the main verb of compound versb needs to be attached here
} ;
---- PastPartAP v = {
---- s = \\n,g,_,_ => v.cvp ++ v.s ! VF Imperf Pers2_Casual n g ; -- the main verb of compound versb needs to be attached here
---- } ;
OrdCompar a = {s = a.s ! Sg ! Masc ! Dir ! Compar ; n = Sg } ;

View File

@@ -35,18 +35,12 @@ lin
lin
CompoundCN num noun cn = {
s = \\n,d,c => num.s ! cn.g ++ noun.co ++ BIND ++ cn.s ! n ! d ! c ;
CompoundCN noun cn = {
s = \\n,d,c => noun.co ++ BIND ++ cn.s ! n ! d ! c ;
g = cn.g ;
isMod = False
} ;
DashCN noun1 noun2 = {
s = \\n,d,c => noun1.co ++ BIND ++ noun2.s ! n ! d ! c ;
g = noun2.g ;
co = noun1.co ++ BIND ++ noun2.co ---- add s if not already there
} ;
GerundN v = {
s = \\n,d,c => v.s ! VI (VPtPres n d c) ;
g = Neutr ;
@@ -58,11 +52,7 @@ lin
isPre = True
} ;
PastPartAP v = {
s = \\afpos => v.s ! VI (VPtPret afpos Nom) ;
isPre = True
} ;
---- PastPartAP vp
OrdCompar a = {
s = case a.isComp of {

View File

@@ -11,10 +11,16 @@ concrete TranslateEng of Translate =
addGenitiveS
],
ConjunctionEng,
VerbEng - [SlashV2V, PassV2, UseCopula, ComplVV],
VerbEng - [
SlashV2V, PassV2, UseCopula, ComplVV, -- generalized in Extensions
ComplVS, SlashV2S, ComplSlash -- have variants in Eng
],
AdverbEng,
PhraseEng,
SentenceEng - [UseCl], -- replaced by UseCl | ContractedUseCl
SentenceEng - [
---- PredVP, -- to be replaced by PredVPS, QuestVPS, QuestIAdvVPS in Extensions
UseCl -- replaced by UseCl | ContractedUseCl
],
QuestionEng,
RelativeEng,
IdiomEng [NP, VP, Tense, Cl, ProgrVP, ExistNP, SelfAdvVP, SelfAdVVP, SelfNP],
@@ -23,14 +29,21 @@ concrete TranslateEng of Translate =
ExtensionsEng,
DictionaryEng **
open MorphoEng, ResEng, ParadigmsEng, (S = SentenceEng), (E = ExtraEng), Prelude in {
open MorphoEng, ResEng, ParadigmsEng, (G = GrammarEng), (E = ExtraEng), Prelude in {
flags
literal=Symb ;
-- exceptional linearizations
lin
UseCl t p cl = S.UseCl t p cl | E.ContractedUseCl t p cl ;
UseCl t p cl =
G.UseCl t p cl -- I am here
| E.ContractedUseCl t p cl -- I'm here
;
ComplVS vs s = G.ComplVS vs s | E.ComplBareVS vs s ;
SlashV2S vs s = G.SlashV2S vs s | E.SlashBareV2S vs s ;
ComplSlash vps np = G.ComplSlash vps np | E.ComplSlashPartLast vps np ;
PPos = {s = [] ; p = CPos} ;
PNeg = {s = [] ; p = CNeg True} | {s = [] ; p = CNeg False} ;