forked from GitHub/gf-core
Translate grammar refactoring for Bul and Chi
This commit is contained in:
64935
lib/src/translator/DictionaryBul.gf
Normal file
64935
lib/src/translator/DictionaryBul.gf
Normal file
File diff suppressed because it is too large
Load Diff
17082
lib/src/translator/DictionaryChi.gf
Normal file
17082
lib/src/translator/DictionaryChi.gf
Normal file
File diff suppressed because it is too large
Load Diff
173
lib/src/translator/ExtensionsBul.gf
Normal file
173
lib/src/translator/ExtensionsBul.gf
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
--# -path=.:../abstract
|
||||||
|
|
||||||
|
concrete ExtensionsBul of Extensions =
|
||||||
|
CatBul ** open ResBul, (E = ExtraBul), Prelude in {
|
||||||
|
|
||||||
|
flags
|
||||||
|
coding = utf8 ;
|
||||||
|
|
||||||
|
lincat
|
||||||
|
VPI = E.VPI ;
|
||||||
|
ListVPI = E.ListVPI ;
|
||||||
|
VPS = E.VPS ;
|
||||||
|
ListVPS = E.ListVPS ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
MkVPI = E.MkVPI ;
|
||||||
|
ConjVPI = E.ConjVPI ;
|
||||||
|
ComplVPIVV = E.ComplVPIVV ;
|
||||||
|
|
||||||
|
MkVPS = E.MkVPS ;
|
||||||
|
ConjVPS = E.ConjVPS ;
|
||||||
|
PredVPS = E.PredVPS ;
|
||||||
|
|
||||||
|
BaseVPI = E.BaseVPI ;
|
||||||
|
ConsVPI = E.ConsVPI ;
|
||||||
|
BaseVPS = E.BaseVPS ;
|
||||||
|
ConsVPS = E.ConsVPS ;
|
||||||
|
|
||||||
|
---- GenNP = E.GenNP ;
|
||||||
|
---- GenIP = E.GenIP ;
|
||||||
|
---- GenRP = E.GenRP ;
|
||||||
|
|
||||||
|
---- PassVPSlash = E.PassVPSlash ;
|
||||||
|
---- PassAgentVPSlash = E.PassAgentVPSlash ;
|
||||||
|
|
||||||
|
EmptyRelSlash = E.EmptyRelSlash ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
CompoundCN num noun cn = {
|
||||||
|
s = \\nf => num.s ! CFNeut Indef ++ (noun.rel ! nform2aform nf cn.g) ++ (cn.s ! (indefNForm nf)) ;
|
||||||
|
g = cn.g
|
||||||
|
} ;
|
||||||
|
|
||||||
|
GerundN v = {
|
||||||
|
s = \\nform => v.s ! Imperf ! VNoun nform ;
|
||||||
|
rel = \\aform => v.s ! Imperf ! VPresPart aform ++
|
||||||
|
case v.vtype of {
|
||||||
|
VMedial c => reflClitics ! c;
|
||||||
|
_ => []
|
||||||
|
};
|
||||||
|
g = ANeut
|
||||||
|
} ;
|
||||||
|
|
||||||
|
GerundAP v = {
|
||||||
|
s = \\aform => v.s ! Imperf ! VPresPart aform ++
|
||||||
|
case v.vtype of {
|
||||||
|
VMedial c => reflClitics ! c;
|
||||||
|
_ => []
|
||||||
|
};
|
||||||
|
adv = v.s ! Imperf ! VPresPart (ASg Neut Indef);
|
||||||
|
isPre = True
|
||||||
|
} ;
|
||||||
|
|
||||||
|
PastPartAP v = {
|
||||||
|
s = \\aform => v.s ! Perf ! VPassive aform ;
|
||||||
|
adv = v.s ! Perf ! VPassive (ASg Neut Indef);
|
||||||
|
isPre = True
|
||||||
|
} ;
|
||||||
|
|
||||||
|
PositAdVAdj a = {s = a.adv} ;
|
||||||
|
|
||||||
|
that_RP = {
|
||||||
|
s = whichRP
|
||||||
|
} ;
|
||||||
|
|
||||||
|
UseQuantPN q pn = { s = table {
|
||||||
|
RObj Dat => "на" ++ pn.s;
|
||||||
|
_ => pn.s
|
||||||
|
} ;
|
||||||
|
a = {gn = GSg pn.g; p = P3};
|
||||||
|
p = q.p
|
||||||
|
} ;
|
||||||
|
|
||||||
|
PastPartRS ant pol vp = {
|
||||||
|
s = \\agr =>
|
||||||
|
ant.s ++ pol.s ++
|
||||||
|
vp.ad.s ++
|
||||||
|
case pol.p of {Pos => ""; Neg => "не"} ++
|
||||||
|
case ant.a of {Simul => ""; Anter => auxBe ! VPerfect (aform agr.gn Indef (RObj Acc))} ++
|
||||||
|
vp.s ! Perf ! VPassive (aform agr.gn Indef (RObj Acc)) ++
|
||||||
|
case vp.vtype of {
|
||||||
|
VMedial c => reflClitics ! c;
|
||||||
|
_ => []
|
||||||
|
} ++
|
||||||
|
vp.compl1 ! agr ++ vp.compl2 ! agr ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
PresPartRS ant pol vp = {
|
||||||
|
s = \\agr =>
|
||||||
|
ant.s ++ pol.s ++
|
||||||
|
vp.ad.s ++
|
||||||
|
case pol.p of {Pos => ""; Neg => "не"} ++
|
||||||
|
case ant.a of {Simul => ""; Anter => auxBe ! VPerfect (aform agr.gn Indef (RObj Acc))} ++
|
||||||
|
vp.s ! Imperf ! VPresPart (aform agr.gn Indef (RObj Acc)) ++
|
||||||
|
case vp.vtype of {
|
||||||
|
VMedial c => reflClitics ! c;
|
||||||
|
_ => []
|
||||||
|
} ++
|
||||||
|
vp.compl ! agr ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
SlashV2V vv ant p vp =
|
||||||
|
insertSlashObj2 (\\agr => ant.s ++ p.s ++ vv.c3.s ++
|
||||||
|
daComplex ant.a (orPol p.p vp.p) vp ! Perf ! agr)
|
||||||
|
Pos
|
||||||
|
(slashV vv vv.c2) ;
|
||||||
|
|
||||||
|
ComplVV vv ant p vp =
|
||||||
|
insertObj (\\agr => ant.s ++ p.s ++
|
||||||
|
case vv.typ of {
|
||||||
|
VVInf => daComplex ant.a p.p vp ! Perf ! agr;
|
||||||
|
VVGerund => gerund vp ! Imperf ! agr
|
||||||
|
}) vp.p
|
||||||
|
(predV vv) ;
|
||||||
|
|
||||||
|
PredVPosv np vp = {
|
||||||
|
s = \\t,a,p,o =>
|
||||||
|
let
|
||||||
|
subj = np.s ! (case vp.vtype of {
|
||||||
|
VNormal => RSubj ;
|
||||||
|
VMedial _ => RSubj ;
|
||||||
|
VPhrasal c => RObj c}) ;
|
||||||
|
verb : Bool => Str
|
||||||
|
= \\q => vpTenses vp ! t ! a ! p ! np.a ! q ! Perf ;
|
||||||
|
compl = vp.compl ! np.a
|
||||||
|
in case o of {
|
||||||
|
Main => compl ++ subj ++ verb ! False ;
|
||||||
|
Inv => verb ! False ++ compl ++ subj ;
|
||||||
|
Quest => compl ++ subj ++ verb ! True
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
CompS s = {s = \\_ => "че" ++ s.s; p = Pos} ;
|
||||||
|
CompQS qs = {s = \\_ => qs.s ! QIndir; p = Pos} ;
|
||||||
|
CompVP ant p vp = {s = let p' = case vp.p of {
|
||||||
|
Neg => Neg;
|
||||||
|
Pos => p.p
|
||||||
|
}
|
||||||
|
in \\agr => ant.s ++ p.s ++
|
||||||
|
daComplex ant.a p' vp ! Perf ! agr;
|
||||||
|
p = Pos
|
||||||
|
} ;
|
||||||
|
|
||||||
|
VPSlashVS vs vp =
|
||||||
|
let vp = insertObj (daComplex Simul Pos vp ! Perf) vp.p (predV vs)
|
||||||
|
in { s = vp.s;
|
||||||
|
ad = vp.ad;
|
||||||
|
compl1 = \\_ => "";
|
||||||
|
compl2 = vp.compl;
|
||||||
|
vtype = vp.vtype;
|
||||||
|
p = vp.p;
|
||||||
|
c2 = {s=""; c=Acc}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
ApposNP np1 np2 = {
|
||||||
|
s = \\role => np1.s ! role ++ comma ++ np2.s ! RSubj ;
|
||||||
|
a = np1.a ;
|
||||||
|
p = np1.p
|
||||||
|
} ;
|
||||||
|
|
||||||
|
UttAdV adv = adv;
|
||||||
|
|
||||||
|
}
|
||||||
131
lib/src/translator/ExtensionsChi.gf
Normal file
131
lib/src/translator/ExtensionsChi.gf
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
--# -path=.:../abstract
|
||||||
|
|
||||||
|
concrete ExtensionsChi of Extensions =
|
||||||
|
CatChi ** open ResChi, ParadigmsChi, SyntaxChi, (G = GrammarChi), (E = ExtraChi), Prelude in {
|
||||||
|
|
||||||
|
lincat
|
||||||
|
VPI = E.VPI ;
|
||||||
|
ListVPI = E.ListVPI ;
|
||||||
|
VPS = E.VPS ;
|
||||||
|
ListVPS = E.ListVPS ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
MkVPI = E.MkVPI ;
|
||||||
|
ConjVPI = E.ConjVPI ;
|
||||||
|
---- ComplVPIVV = E.ComplVPIVV ;
|
||||||
|
|
||||||
|
MkVPS = E.MkVPS ;
|
||||||
|
ConjVPS = E.ConjVPS ;
|
||||||
|
PredVPS = E.PredVPS ;
|
||||||
|
|
||||||
|
BaseVPI = E.BaseVPI ;
|
||||||
|
ConsVPI = E.ConsVPI ;
|
||||||
|
BaseVPS = E.BaseVPS ;
|
||||||
|
ConsVPS = E.ConsVPS ;
|
||||||
|
|
||||||
|
GenNP = E.GenNP ;
|
||||||
|
---- GenIP = E.GenIP ;
|
||||||
|
GenRP = E.GenRP ;
|
||||||
|
|
||||||
|
PassVPSlash = E.PassVPSlash ;
|
||||||
|
PassAgentVPSlash = E.PassAgentVPSlash ;
|
||||||
|
|
||||||
|
---- EmptyRelSlash = E.EmptyRelSlash ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
that_RP = which_RP ;
|
||||||
|
|
||||||
|
-- lexical entries
|
||||||
|
|
||||||
|
-- another_Quant = mkQuantifier "otro" "otra" "otros" "otras" ;
|
||||||
|
-- some_Quant = mkQuantifier "algún" "alguna" "algunos" "algunas" ;
|
||||||
|
-- anySg_Det = mkDeterminer "algún" "alguna" Sg False ; ---- also meaning "whichever" ?
|
||||||
|
-- each_Det = SyntaxChi.every_Det ;
|
||||||
|
|
||||||
|
-- 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} ; ----
|
||||||
|
|
||||||
|
GerundN v = {
|
||||||
|
s = v.s ;
|
||||||
|
c = ge_s ---- ge
|
||||||
|
} ;
|
||||||
|
|
||||||
|
GerundAP v = {
|
||||||
|
s = v.s ++ de_s ; ----
|
||||||
|
monoSyl = False ;
|
||||||
|
hasAdA = True ; ---
|
||||||
|
} ;
|
||||||
|
|
||||||
|
PastPartAP v = {
|
||||||
|
s = v.s ++ de_s ;
|
||||||
|
monoSyl = False ;
|
||||||
|
hasAdA = True ; ---
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
---- PastPartAP v = v ; ----
|
||||||
|
|
||||||
|
{-
|
||||||
|
OrdCompar a = {s = \\c => a.s ! AAdj Compar c } ;
|
||||||
|
-}
|
||||||
|
|
||||||
|
PositAdVAdj a = {s = a.s} ;
|
||||||
|
|
||||||
|
|
||||||
|
UseQuantPN q pn = {s = q.s ++ ge_s ++ pn.s} ; ---- ge
|
||||||
|
|
||||||
|
SlashV2V v a p vp =
|
||||||
|
insertObj (ResChi.mkNP (a.s ++ p.s ++ useVerb vp.verb ! p.p ! APlain ++ vp.compl))
|
||||||
|
(predV v v.part) ** {c2 = v.c2 ; isPre = v.hasPrep} ; ---- aspect
|
||||||
|
|
||||||
|
{-
|
||||||
|
SlashVPIV2V v p vpi = insertObjc (\\a => p.s ++
|
||||||
|
v.c3 ++
|
||||||
|
vpi.s ! VVAux ! a)
|
||||||
|
(predVc v) ;
|
||||||
|
-}
|
||||||
|
|
||||||
|
---- TODO: find proper expressions for OSV and OVS in Chi
|
||||||
|
PredVPosv np vp = G.PredVP np vp ; ---- (lin NP np) (lin VP vp) ; ----
|
||||||
|
PredVPovs np vp = G.PredVP np vp ; ---- (lin NP np) (lin VP vp) ; ----
|
||||||
|
|
||||||
|
|
||||||
|
CompS s = insertObj s (predV copula []) ; ----
|
||||||
|
|
||||||
|
|
||||||
|
CompQS qs = insertObj qs (predV copula []) ; ----
|
||||||
|
CompVP ant p vp = insertObj (ss (infVP vp)) (predV copula []) ; ----
|
||||||
|
|
||||||
|
{-
|
||||||
|
VPSlashVS vs vp =
|
||||||
|
insertObj (\\a => infVP VVInf vp Simul CPos a) (predV vs []) **
|
||||||
|
{c2 = ""; gapInMiddle = False} ;
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
|
PastPartRS ant pol vp = { ---- copied from PresPartRS
|
||||||
|
s = ant.s ++ pol.s ++ vp.prePart ++ useVerb vp.verb ! pol.p ! APlain ++ vp.compl ++ which_RP.s ---- aspect
|
||||||
|
} ; ---- ??
|
||||||
|
|
||||||
|
|
||||||
|
PresPartRS ant pol vp = { ---- copied from RelVP
|
||||||
|
s = ant.s ++ pol.s ++ vp.prePart ++ useVerb vp.verb ! pol.p ! APlain ++ vp.compl ++ which_RP.s ---- aspect
|
||||||
|
} ; ---- ??
|
||||||
|
|
||||||
|
ComplVV v a p vp = {
|
||||||
|
verb = v ;
|
||||||
|
compl = a.s ++ p.s ++ vp.topic ++ vp.prePart ++ useVerb vp.verb ! p.p ! APlain ++ vp.compl ; ---- aspect
|
||||||
|
prePart, topic = []
|
||||||
|
} ;
|
||||||
|
|
||||||
|
ApposNP np1 np2 = {
|
||||||
|
s = np1.s ++ chcomma ++ np2.s
|
||||||
|
} ;
|
||||||
|
|
||||||
|
AdAdV = cc2 ;
|
||||||
|
|
||||||
|
UttAdV adv = adv;
|
||||||
|
|
||||||
|
}
|
||||||
25
lib/src/translator/TranslateBul.gf
Normal file
25
lib/src/translator/TranslateBul.gf
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
--# -path=alltenses:../bulgarian:../english:../abstract
|
||||||
|
concrete TranslateBul of Translate =
|
||||||
|
TenseX - [IAdv, CAdv],
|
||||||
|
CatBul,
|
||||||
|
NounBul - [PPartNP],
|
||||||
|
AdjectiveBul,
|
||||||
|
NumeralBul,
|
||||||
|
SymbolBul [PN, Symb, String, CN, Card, NP, MkSymb, SymbPN, CNNumNP],
|
||||||
|
ConjunctionBul,
|
||||||
|
VerbBul - [SlashV2V, PassV2, UseCopula, ComplVV],
|
||||||
|
AdverbBul,
|
||||||
|
PhraseBul,
|
||||||
|
SentenceBul,
|
||||||
|
QuestionBul,
|
||||||
|
RelativeBul,
|
||||||
|
IdiomBul [NP, VP, Tense, Cl, ProgrVP, ExistNP],
|
||||||
|
ExtensionsBul,
|
||||||
|
DictionaryBul **
|
||||||
|
open ResBul, Prelude in {
|
||||||
|
|
||||||
|
flags
|
||||||
|
literal=Symb ;
|
||||||
|
coding = utf8 ;
|
||||||
|
|
||||||
|
}
|
||||||
42
lib/src/translator/TranslateChi.gf
Normal file
42
lib/src/translator/TranslateChi.gf
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
--# -path=.:../chinese:../english:../abstract
|
||||||
|
|
||||||
|
concrete TranslateChi of Translate =
|
||||||
|
TenseChi,
|
||||||
|
NounChi - [PPartNP],
|
||||||
|
AdjectiveChi,
|
||||||
|
NumeralChi,
|
||||||
|
SymbolChi [PN, Symb, String, CN, Card, NP, MkSymb, SymbPN, CNNumNP],
|
||||||
|
ConjunctionChi,
|
||||||
|
VerbChi - [
|
||||||
|
SlashV2V, PassV2, UseCopula, ComplVV,
|
||||||
|
CompAP, AdvVP -- Chi exceptions
|
||||||
|
],
|
||||||
|
AdverbChi,
|
||||||
|
PhraseChi,
|
||||||
|
SentenceChi,
|
||||||
|
QuestionChi - [
|
||||||
|
QuestCl -- Chi exception
|
||||||
|
],
|
||||||
|
RelativeChi,
|
||||||
|
IdiomChi [NP, VP, Tense, Cl, ProgrVP, ExistNP, SelfAdvVP, SelfAdVVP, SelfNP],
|
||||||
|
ConstructionChi,
|
||||||
|
ExtensionsChi,
|
||||||
|
DictionaryChi
|
||||||
|
**
|
||||||
|
open ResChi, ParadigmsChi, SyntaxChi, Prelude, (G = GrammarChi), (E = ExtraChi) in {
|
||||||
|
|
||||||
|
flags
|
||||||
|
literal = Symb ;
|
||||||
|
coding = utf8 ;
|
||||||
|
|
||||||
|
|
||||||
|
-- Chinese-specific overrides
|
||||||
|
|
||||||
|
lin
|
||||||
|
CompAP = G.CompAP | E.CompBareAP ; -- he is good | he good
|
||||||
|
|
||||||
|
AdvVP vp adv = E.TopicAdvVP vp adv | G.AdvVP vp adv ; -- he *today* here sleeps | *today* he here sleeps
|
||||||
|
|
||||||
|
QuestCl cl = G.QuestCl cl | E.QuestRepV cl ; -- he comes 'ma' | he come not come
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user