summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-08-15 12:41:04 +0000
committeraarne <aarne@cs.chalmers.se>2008-08-15 12:41:04 +0000
commitba78322409e2086a83c03b7b32e84940a24030b0 (patch)
tree87b13411a8d6db544461eef201f4e02207ac0ff1 /examples
parent0475ef3414cff410b826c9f06e6c7043625972fa (diff)
examples of morphological synthesis/analysis as top-level grammars
Diffstat (limited to 'examples')
-rw-r--r--examples/morpho/Eng.gf27
-rw-r--r--examples/morpho/EngDescr.gf23
-rw-r--r--examples/morpho/EngReal.gf31
-rw-r--r--examples/morpho/Fre.gf38
-rw-r--r--examples/morpho/FreDescr.gf44
-rw-r--r--examples/morpho/FreReal.gf71
-rw-r--r--examples/morpho/README.txt25
7 files changed, 259 insertions, 0 deletions
diff --git a/examples/morpho/Eng.gf b/examples/morpho/Eng.gf
new file mode 100644
index 000000000..e508f09e2
--- /dev/null
+++ b/examples/morpho/Eng.gf
@@ -0,0 +1,27 @@
+-- Abstract syntax for a top-level grammar for morphological analysis and synthesis
+-- AR 15/8/2008
+-- Use this as a template to port other morphologies to javascript, etc.
+
+-- First import a lexicon.
+
+abstract Eng = IrregEngAbs ** {
+
+cat
+ Display ; -- what is shown: word form, analysis, or full table
+ Word ; -- lexical unit
+ Form ; -- form description
+
+flags startcat = Display ;
+
+fun
+ DAll : Word -> Display ; -- to show full table
+ DForm : Word -> Form -> Display ; -- to show one form
+
+-- Here are the possible forms; this is really a copy of ResEng.VForm
+-- and should be generated automatically.
+
+ VInf, VPres, VPast, VPPart, VPresPart : Form ;
+
+ WVerb : V -> Word ; -- use category V from IrregEngAbs
+
+}
diff --git a/examples/morpho/EngDescr.gf b/examples/morpho/EngDescr.gf
new file mode 100644
index 000000000..3e5efec77
--- /dev/null
+++ b/examples/morpho/EngDescr.gf
@@ -0,0 +1,23 @@
+--# -path=.:alltenses
+
+concrete EngDescr of Eng = IrregEng ** open (R = ResEng) in {
+
+lincat
+ Display, Word, Form = Str ;
+
+lin
+ DAll w = w ++ ":" ++ "all forms" ;
+
+ DForm w f = w ++ ":" ++ f ;
+
+-- names of forms displayed
+
+ VInf = "Infinitive" ;
+ VPres = "Present" ;
+ VPast = "Past" ;
+ VPPart = "Past Participle" ;
+ VPresPart = "Present Participle" ;
+
+ WVerb v = v.s ! R.VInf ; -- the dictionary form shown in word description
+
+}
diff --git a/examples/morpho/EngReal.gf b/examples/morpho/EngReal.gf
new file mode 100644
index 000000000..b28f1e0eb
--- /dev/null
+++ b/examples/morpho/EngReal.gf
@@ -0,0 +1,31 @@
+--# -path=.:alltenses
+
+concrete EngReal of Eng = IrregEng ** open (R = ResEng) in {
+
+lincat
+ Display = Str ;
+ Word = R.VForm => Str ;
+ Form = {s : Str ; v : R.VForm} ;
+
+lin
+
+-- select the forms to display (here all forms)
+
+ DAll w = w ! R.VInf ++ w ! R.VPres ++ w ! R.VPast ++ w ! R.VPPart ++ w ! R.VPresPart ;
+
+-- this code should be generated automatically
+
+ DForm w f = w ! f.v ++ f.s ;
+
+ VInf = vf R.VInf ;
+ VPres = vf R.VPres ;
+ VPast = vf R.VPast ;
+ VPPart = vf R.VPPart ;
+ VPresPart = vf R.VPresPart ;
+
+ WVerb v = v.s ;
+
+oper
+ vf : R.VForm -> {s : Str ; v : R.VForm} = \f -> {s = [] ; v = f} ; ---
+
+}
diff --git a/examples/morpho/Fre.gf b/examples/morpho/Fre.gf
new file mode 100644
index 000000000..54ebaf4d0
--- /dev/null
+++ b/examples/morpho/Fre.gf
@@ -0,0 +1,38 @@
+-- French irregular verbs, built using Eng as template.
+
+abstract Fre = IrregFreAbs ** {
+
+flags startcat = Display ;
+
+cat
+ Display ; Word ; Form ;
+
+-- French verb forms have an internal structure.
+
+ TMood ; Number ; Person ; NumPersI ; Gender ; Mood ;
+
+fun
+ DAll : Word -> Display ;
+ DForm : Word -> Form -> Display ;
+
+ VInfin : Form ;
+ VFin : TMood -> Number -> Person -> Form ;
+ VImper : NumPersI -> Form ;
+ VPart : Gender -> Number -> Form ;
+ VGer : Form ;
+
+ VPres : Mood -> TMood ;
+ VImperf : Mood -> TMood ;
+ VPasse, VFut, VCondit : TMood ;
+
+ SgP2, PlP1, PlP2 : NumPersI ;
+
+ Sg, Pl : Number ;
+ P1, P2, P3 : Person ;
+ Masc, Fem : Gender ;
+ Indic, Conjunct : Mood ;
+
+ WVerb : V -> Word ;
+ WVerb2 : V2 -> Word ;
+
+}
diff --git a/examples/morpho/FreDescr.gf b/examples/morpho/FreDescr.gf
new file mode 100644
index 000000000..0007986b2
--- /dev/null
+++ b/examples/morpho/FreDescr.gf
@@ -0,0 +1,44 @@
+--# -path=.:alltenses
+
+concrete FreDescr of Fre = IrregFre - [S] ** open (R = CommonRomance), Prelude in {
+
+flags coding=utf8 ;
+
+lincat
+ Display, Word, Form = Str ;
+ TMood, Number, Person, NumPersI, Gender, Mood = Str ;
+
+lin
+ DAll w = w ++ ":" ++ "la conjugaison" ;
+
+ DForm w f = w ++ ":" ++ f ;
+
+ VInfin = "infinitif" ;
+ VFin m n p = m ++ n ++ p ;
+ VImper np = "imparfait" ++ np ;
+ VPart g n = "participe passé" ++ g ++ n ;
+ VGer = "participe présent" ;
+
+ VPres m = m ++ "présent" ;
+ VImperf m = m ++ "imparfait" ;
+ VPasse = "passé simple" ;
+ VFut = "futur" ;
+ VCondit = "conditionnel" ;
+
+ SgP2 = "singulier 2e" ;
+ PlP1 = "pluriel 1ère" ;
+ PlP2 = "pluriel 2e" ;
+ Sg = "singulier" ;
+ Pl = "pluriel" ;
+ P1 = "1ère" ;
+ P2 = "2e" ;
+ P3 = "3e" ;
+ Masc = "masculin" ;
+ Fem = "féminin" ;
+ Indic = "indicatif" ;
+ Conjunct = "subjonctif" ;
+
+ WVerb v = v.s ! R.VInfin True ;
+ WVerb2 v = v.s ! R.VInfin True ;
+
+}
diff --git a/examples/morpho/FreReal.gf b/examples/morpho/FreReal.gf
new file mode 100644
index 000000000..c9dfcc84d
--- /dev/null
+++ b/examples/morpho/FreReal.gf
@@ -0,0 +1,71 @@
+--# -path=.:alltenses
+
+concrete FreReal of Fre = IrregFre ** open (R = CommonRomance), Prelude in {
+
+lincat
+ Display = Str ;
+ Word = R.VF => Str ;
+ Form = {s : Str ; v : R.VF} ;
+ TMood = {s : Str ; v : R.TMood} ;
+ Number = {s : Str ; v : R.Number} ;
+ Person = {s : Str ; v : R.Person} ;
+ NumPersI = {s : Str ; v : R.NumPersI} ;
+ Gender = {s : Str ; v : R.Gender} ;
+ Mood = {s : Str ; v : R.Mood} ;
+
+lin
+ -- display the same subset of forms as Petit Robert
+
+ DAll w =
+ w ! R.VInfin True ++
+ w ! R.VFin (R.VPres R.Indic) R.Sg R.P1 ++
+ w ! R.VFin (R.VPres R.Indic) R.Sg R.P3 ++
+ w ! R.VFin (R.VPres R.Indic) R.Pl R.P1 ++
+ w ! R.VFin (R.VPres R.Indic) R.Pl R.P3 ++
+ w ! R.VFin (R.VImperf R.Indic) R.Sg R.P1 ++
+ w ! R.VFin (R.VImperf R.Indic) R.Pl R.P1 ++
+ w ! R.VFin R.VPasse R.Sg R.P1 ++
+ w ! R.VFin R.VPasse R.Pl R.P1 ++
+ w ! R.VFin R.VFut R.Sg R.P1 ++
+ w ! R.VFin R.VCondit R.Sg R.P1 ++
+ w ! R.VFin (R.VPres R.Conjunct) R.Sg R.P1 ++
+ w ! R.VImper R.SgP2 ++
+ w ! R.VImper R.PlP1 ++
+ w ! R.VGer ++
+ w ! R.VPart R.Masc R.Sg ;
+
+ DForm w f = w ! f.v ++ f.s ; ---
+
+ VInfin = {s = [] ; v = R.VInfin True} ;
+ VFin m n p = {s = m.s ++ n.s ++ p.s ; v = R.VFin m.v n.v p.v} ;
+
+ VImper np = {s = np.s ; v = R.VImper np.v} ;
+ VPart g n = {s = g.s ++ n.s ; v = R.VPart g.v n.v} ;
+ VGer = {s = [] ; v = R.VGer} ;
+
+ VPres m = {s = m.s ; v = R.VPres m.v} ;
+ VImperf m = {s = m.s ; v = R.VImperf m.v} ;
+ VPasse = {s = [] ; v = R.VPasse} ;
+ VFut = {s = [] ; v = R.VFut} ;
+ VCondit = {s = [] ; v = R.VCondit} ;
+
+ SgP2 = {s = [] ; v = R.SgP2} ;
+ PlP1 = {s = [] ; v = R.PlP1} ;
+ PlP2 = {s = [] ; v = R.PlP2} ;
+ Sg = {s = [] ; v = R.Sg} ;
+ Pl = {s = [] ; v = R.Pl} ;
+ P1 = {s = [] ; v = R.P1} ;
+ P2 = {s = [] ; v = R.P2} ;
+ P3 = {s = [] ; v = R.P3} ;
+ Masc = {s = [] ; v = R.Masc} ;
+ Fem = {s = [] ; v = R.Fem} ;
+ Indic = {s = [] ; v = R.Indic} ;
+ Conjunct = {s = [] ; v = R.Conjunct} ;
+
+ WVerb v = v.s ;
+ WVerb2 v = v.s ;
+
+oper
+ vf : R.VF -> {s : Str ; v : R.VF} = \f -> {s = [] ; v = f} ; ---
+
+}
diff --git a/examples/morpho/README.txt b/examples/morpho/README.txt
new file mode 100644
index 000000000..41bdd545b
--- /dev/null
+++ b/examples/morpho/README.txt
@@ -0,0 +1,25 @@
+AR 15/8/2008
+
+Here are some examples of morphological lexica turned into top-level GF grammars.
+
+Top level is useful because it supports analysis and synthesis by normal
+e.g. JavaScript tools.
+
+The simplest example is in the following three files:
+
+ Eng.gf -- abstract syntax (English irregular verbs)
+ EngDescr.gf -- concrete syntax showing form descriptions
+ EngReal.gf -- concrete syntax showing real forms
+
+Compile the result with
+
+ gfc --make -f js EngDescr.gf EngReal.gf
+
+Then use Eng.js in place of GF/lib/javascript/grammar.js
+
+Other examples:
+
+ Fre* -- French irregular verbs
+
+NB: there are issues on character encoding of abstract verb names in Fre.
+