completed Translate grammars for all 8 languages; a Makefile entry for them; updated doc/translation.html. What remains to do is to make the new documentation facilities (GF-driven, in the Documentation modules) available in the Android app, so that the Parse* modules can be retired from translation tasks.

This commit is contained in:
aarne
2014-01-21 08:20:46 +00:00
parent 370296c0ba
commit 9b986255bf
9 changed files with 63552 additions and 14 deletions

View File

@@ -11,6 +11,51 @@
</CENTER>
<H2>How to use it</H2>
<P>
This is a document about a wide-coverage translation system in GF. If you just want to try it before reading more,
here are the main modes of getting started:
</P>
<P>
1. <B>Run on our server.</B> Forthcoming.
</P>
<P>
2. <B>Get an Android app.</B> Forthcoming.
</P>
<P>
3. <B>Compile and run in the shell.</B> Get the latest GF sources (with darcs or github) and then
</P>
<UL>
<LI>compile and install the GF compiler and library and the C runtime (<CODE>pgf-translate</CODE>).
<P></P>
<LI>compile the translator:
<PRE>
cd GF/lib/src
make Translate8.pgf
</PRE>
This will take a long time (ten minutes or more) and will probably require at least 8GB of RAM.
<P></P>
<LI>run the translator
<PRE>
pgf-translate Translate8.pgf Phr TranslateEng TranslateSwe
</PRE>
with obviously the possibility to vary the source and the target language.
<P></P>
4. To modify the sources, work on the files in
<PRE>
GF/lib/src/translator/
</PRE>
It is these files that will be explained below.
</UL>
<H2>GF and the RGL</H2>
<P>
@@ -214,13 +259,6 @@ The following picture shows the principal module structure of the translation gr
<IMG ALIGN="middle" SRC="translation.png" BORDER="0" ALT="">
</P>
<P>
<I>Notice: the current module structure and naming do not yet quite correspond to the description here.</I>
<I>Thus currently the top module is "Parse" and contains both "Translate" and "Extensions".</I>
<I>The Dictionary module is "Dict", and coincides in the case of English with the monolingual</I>
<I>morphological dictionary. However, the more sense distinctions are introduced for the needs</I>
<I>of translation, the less adequate it becomes to keep these two together.</I>
</P>
<P>
Here is a description of each of the modules:
</P>

View File

@@ -3,6 +3,38 @@ Aarne Ranta et al.
Work in progress, January 2014
==How to use it==
This is a document about a wide-coverage translation system in GF. If you just want to try it before reading more,
here are the main modes of getting started:
1. **Run on our server.** Forthcoming.
2. **Get an Android app.** Forthcoming.
3. **Compile and run in the shell.** Get the latest GF sources (with darcs or github) and then
- compile and install the GF compiler and library and the C runtime (``pgf-translate``).
- compile the translator:
```
cd GF/lib/src
make Translate8.pgf
```
This will take a long time (ten minutes or more) and will probably require at least 8GB of RAM.
- run the translator
```
pgf-translate Translate8.pgf Phr TranslateEng TranslateSwe
```
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/
```
It is these files that will be explained below.
==GF and the RGL==
GF, Grammatical Framework, was originally designed for the purpose of **multilingual controlled language systems**,
@@ -183,13 +215,6 @@ The following picture shows the principal module structure of the translation gr
[translation.png]
//Notice: the current module structure and naming do not yet quite correspond to the description here.//
//Thus currently the top module is "Parse" and contains both "Translate" and "Extensions".//
//The Dictionary module is "Dict", and coincides in the case of English with the monolingual//
//morphological dictionary. However, the more sense distinctions are introduced for the needs//
//of translation, the less adequate it becomes to keep these two together.//
Here is a description of each of the modules:
- **Translate** is the top module, which combines the RGL syntax with syntax extensions and a dictionary.

View File

@@ -166,3 +166,52 @@ ParseEngSpa: ; $(GFMKP) -name=ParseEngSpa ParseEng.pgf ParseSpa.pgf
ParseEngFre: ; $(GFMKP) -name=ParseEngFre ParseEng.pgf ParseFre.pgf
ParseEngSwe: ; $(GFMKP) -name=ParseEngSwe ParseEng.pgf ParseSwe.pgf
ParseEngChi: ; $(GFMKP) -name=ParseEngChi ParseEng.pgf ParseChi.pgf
# the former for Parse to be replaced by Translate:
# Dummy targets, just for convenience
Translate: TranslateEng TranslateBul TranslateChi TranslateGer TranslateSwe TranslateHin TranslateFin TranslateFre Translate8
TranslateEng: TranslateEng.pgf
TranslateBul: TranslateBul.pgf
TranslateChi: TranslateChi.pgf
TranslateGer: TranslateGer.pgf
TranslateSwe: TranslateSwe.pgf
TranslateHin: TranslateHin.pgf
TranslateFin: TranslateFin.pgf
TranslateFre: TranslateFre.pgf
S=-s
GFMKT=mkdir -p ../translator && gf $S -make -literal=Symb -probs=$(PROBSFILE) -gfo-dir ../translator
TRANSLATE8=TranslateEng.pgf TranslateBul.pgf TranslateChi.pgf TranslateGer.pgf TranslateSwe.pgf TranslateHin.pgf TranslateFin.pgf TranslateFre.pgf
# Without dependencies:
Translate8:
$(GFMKT) -name=Translate8 $(TRANSLATE8) +RTS -K32M
# With dependencies:
Translate8.pgf: $(TRANSLATE8)
$(GFMKT) -name=Translate8 $(TRANSLATE8) +RTS -K32M
# Translate grammars for individual languages
TranslateEng.pgf:: ; $(GFMKT) -name=TranslateEng translator/TranslateEng.gf
TranslateBul.pgf:: ; $(GFMKT) -name=TranslateBul translator/TranslateBul.gf
TranslateChi.pgf:: ; $(GFMKT) -name=TranslateChi translator/TranslateChi.gf
TranslateFin.pgf:: ; $(GFMKT) -name=TranslateFin translator/TranslateFin.gf +RTS -K32M
TranslateGer.pgf:: ; $(GFMKT) -name=TranslateGer translator/TranslateGer.gf
TranslateHin.pgf:: ; $(GFMKT) -name=TranslateHin translator/TranslateHin.gf
TranslateFre.pgf:: ; $(GFMKT) -name=TranslateFre translator/TranslateFre.gf
TranslateSwe.pgf:: ; $(GFMKT) -name=TranslateSwe translator/TranslateSwe.gf
# Selected language pairs:
TranslateEngFin: ; $(GFMKT) -name=TranslateEngFin TranslateEng.pgf TranslateFin.pgf
TranslateEngGer: ; $(GFMKT) -name=TranslateEngGer TranslateEng.pgf TranslateGer.pgf
TranslateEngHin: ; $(GFMKT) -name=TranslateEngHin TranslateEng.pgf TranslateHin.pgf
TranslateEngBul: ; $(GFMKT) -name=TranslateEngBul TranslateEng.pgf TranslateBul.pgf
TranslateEngSpa: ; $(GFMKT) -name=TranslateEngSpa TranslateEng.pgf TranslateSpa.pgf
TranslateEngFre: ; $(GFMKT) -name=TranslateEngFre TranslateEng.pgf TranslateFre.pgf
TranslateEngSwe: ; $(GFMKT) -name=TranslateEngSwe TranslateEng.pgf TranslateSwe.pgf
TranslateEngChi: ; $(GFMKT) -name=TranslateEngChi TranslateEng.pgf TranslateChi.pgf

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,139 @@
concrete ExtensionsFre of Extensions =
CatFre **
open
PhonoFre, MorphoFre, ResFre, CommonRomance, ParadigmsFre, SyntaxFre, Prelude, (G = GrammarFre) 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 ;
---- GenIP = E.GenIP ;
---- GenRP = E.GenRP ;
---- PassVPSlash = E.PassVPSlash ;
---- PassAgentVPSlash = E.PassAgentVPSlash ;
lin
GenNP np =
let denp = (np.s ! ResFre.genitive).ton in {
s = \\_,_,_,_ => [] ;
sp = \\_,_,_ => denp ;
s2 = denp ;
isNeg = False ;
} ;
EmptyRelSlash slash = mkRCl which_RP (lin ClSlash slash) ;
that_RP = which_RP ;
but_Subj = {s = "mais" ; m = Indic} ; ---- strange to have this as Subj
lin
CompoundCN num noun cn = {
s = \\n => cn.s ! n ++ elisDe ++ 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 =
insertComplement (\\a => prepCase v.c2.c ++ infVP vp a) (predV v) ; ---- a,p
---- TODO: find proper expressions for OSV and OVS in Fre
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

@@ -0,0 +1,125 @@
--# -path=.:../abstract
concrete ExtensionsGer of Extensions =
CatGer ** open MorphoGer, ResGer, ParadigmsGer, SyntaxGer, (E = ExtraGer), (G = GrammarGer), Prelude in {
flags literal=Symb ; 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
ComplVV v ant p vp =
let
vpi = infVP v.isAux vp
in
insertExtrapos vpi.p4 (
insertInfExt vpi.p3 (
insertInf vpi.p2 (
insertObj vpi.p1 (
predVGen v.isAux v)))) ;
PastPartRS ant pol sl = { -- guessed by KA, some fields in sl are ignored!!
s = \\gn => let agr = agrgP3 Masc (numGenNum gn)
in sl.s.s ! VPastPart APred ++
(sl.nn ! agr).p1 ++ (sl.nn ! agr).p2 ++ sl.a2;
c = Nom
} ;
PresPartRS ant pol vp = { -- guessed by KA!!
s = \\gn => let agr = agrgP3 Masc (numGenNum gn)
in vp.s.s ! VPresPart APred ++
(vp.nn ! agr).p1 ++ (vp.nn ! agr).p2;
c = Nom
} ;
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) ;
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
} ;
{-
GerundAP v = { -- beckoning
s = \\agr => v.s ! VPresPart ;
isPre = True
} ;
PastPartAP v = { -- broken
s = \\agr => v.s ! VPPart ;
isPre = True
} ;
OrdCompar a = {s = \\c => a.s ! AAdj Compar c } ; -- higher
PositAdVAdj a = {s = a.s ! AAdv} ; -- really
UseQuantPN q pn = {s = \\c => q.s ! False ! Sg ++ pn.s ! npcase2case c ; a = agrgP3 Sg pn.g} ; -- this London
SlashV2V v p vp = insertObjc (\\a => p.s ++ case p.p of {CPos => ""; _ => "not"} ++ -- force not to sleep
v.c3 ++
infVP v.typ vp a)
(predVc v) ;
ComplPredVP 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 ++ "," ++ np.s ! npNom ++ verb.aux ++ verb.adv ++ vp.ad ++ verb.fin ++ verb.inf ;
OQuest => verb.aux ++ compl ++ "," ++ np.s ! npNom ++ verb.adv ++ vp.ad ++ verb.fin ++ verb.inf
}
} ;
-}
CompS s = {s = \\_ => "that" ++ s.s ! Main} ; -- S -> Comp
CompVP ant p vp = {s = \\_ => useInfVP True vp} ; -- VP -> Comp
lin
that_RP = which_RP ;
UttAdV adv = adv;
}

View File

@@ -0,0 +1,59 @@
--# -path=.:../French:../abstract:../romance:alltenses
concrete TranslateFre of Translate =
TenseFre,
NounFre - [PPartNP],
AdjectiveFre,
NumeralFre,
SymbolFre [PN, Symb, String, CN, Card, NP, MkSymb, SymbPN, CNNumNP],
ConjunctionFre,
VerbFre - [SlashV2V, PassV2, UseCopula, ComplVV],
AdverbFre,
PhraseFre,
SentenceFre,
QuestionFre - [QuestCl, QuestIAdv], -- more variants here
RelativeFre,
IdiomFre [NP, VP, Tense, Cl, ProgrVP, ExistNP, SelfAdvVP, SelfAdVVP, SelfNP],
ConstructionFre,
DocumentationFre,
ExtensionsFre,
DictionaryFre **
open PhonoFre, MorphoFre, ResFre, CommonRomance, ParadigmsFre, SyntaxFre, Prelude, (G = GrammarFre) in {
flags
literal=Symb ;
coding = utf8 ;
-- overrides from Lang
lin
QuestCl cl =
{s = \\t,a,p => -- est-ce qu'il dort ?
let cls = cl.s ! DDir ! t ! a ! p
in table {
QDir => "est-ce" ++ elisQue ++ cls ! Indic ;
QIndir => subjIf ++ cls ! Indic
}
}
| {s = \\t,a,p => -- dort-il ?
let cls = cl.s ! DInv ! t ! a ! p
in table {
QDir => cls ! Indic ;
QIndir => subjIf ++ cls ! Indic
}
}
| G.QuestCl cl -- il dort ?
;
QuestIAdv iadv cl =
G.QuestIAdv iadv cl -- où dort-il
| {s = \\t,a,p,q => -- où est-ce qu'il dort
let
ord = DDir ;
cls = cl.s ! ord ! t ! a ! p ! Indic ;
why = iadv.s
in why ++ "est-ce" ++ elisQue ++ cls
} ;
}

View File

@@ -0,0 +1,26 @@
--# -path=alltenses:.:../german:../abstract
concrete TranslateGer of Translate =
TenseGer,
NounGer - [PPartNP],
AdjectiveGer,
NumeralGer,
SymbolGer [PN, Symb, String, CN, Card, NP, MkSymb, SymbPN, CNNumNP],
ConjunctionGer,
VerbGer - [SlashV2V, PassV2, UseCopula, ComplVV],
AdverbGer,
PhraseGer,
SentenceGer,
QuestionGer,
RelativeGer,
IdiomGer [NP, VP, Tense, Cl, ProgrVP, ExistNP, SelfAdvVP, SelfAdVVP, SelfNP, geben],
ConstructionGer,
DocumentationGer,
ExtensionsGer,
DictionaryGer **
open MorphoGer, ResGer, ParadigmsGer, SyntaxGer, Prelude in {
flags
literal=Symb ;
coding = utf8 ;
}