summaryrefslogtreecommitdiff
path: root/doc/tutorial/resource
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2007-08-16 09:41:00 +0000
committeraarne <aarne@cs.chalmers.se>2007-08-16 09:41:00 +0000
commit1f342b2c25a5b3026de101028a56b3ff17e04e5b (patch)
tree02ab8398695564ed6e019a0c028e4e068c952cc2 /doc/tutorial/resource
parent69129be4b25c6d764df449dfdb2e15cf4b4ebd0a (diff)
prepared mini syntax example
Diffstat (limited to 'doc/tutorial/resource')
-rw-r--r--doc/tutorial/resource/MorphoEng.gf3
-rw-r--r--doc/tutorial/resource/Syntax.gf30
-rw-r--r--doc/tutorial/resource/SyntaxEng.gf88
-rw-r--r--doc/tutorial/resource/SyntaxIta.gf37
-rw-r--r--doc/tutorial/resource/Test.gf8
-rw-r--r--doc/tutorial/resource/TestEng.gf23
-rw-r--r--doc/tutorial/resource/TestIta.gf23
7 files changed, 176 insertions, 36 deletions
diff --git a/doc/tutorial/resource/MorphoEng.gf b/doc/tutorial/resource/MorphoEng.gf
index a6a25b08c..829688c01 100644
--- a/doc/tutorial/resource/MorphoEng.gf
+++ b/doc/tutorial/resource/MorphoEng.gf
@@ -8,6 +8,9 @@ resource MorphoEng = open Prelude in {
oper
Noun, Verb : Type = {s : Number => Str} ;
+ NP = {s : Str ; n : Number} ;
+ VP = {s : Bool => Bool => Number => Str * Str} ; -- decl, pol
+
mkNoun : Str -> Str -> Noun = \x,y -> {
s = table {
Sg => x ;
diff --git a/doc/tutorial/resource/Syntax.gf b/doc/tutorial/resource/Syntax.gf
index 4fef6b543..59ba7d770 100644
--- a/doc/tutorial/resource/Syntax.gf
+++ b/doc/tutorial/resource/Syntax.gf
@@ -3,22 +3,33 @@ abstract Syntax = {
flags startcat=Phr ;
cat
+ Phr ; -- any complete sentence e.g. "Is this pizza good?"
S ; -- declarative sentence e.g. "this pizza is good"
+ QS ; -- question sentence e.g. "is this pizza good"
NP ; -- noun phrase e.g. "this pizza"
- CN ; -- common noun e.g. "pizza"
+ IP ; -- interrogative phrase e.g "which pizza"
+ CN ; -- common noun phrase e.g. "very good pizza"
Det ; -- determiner e.g. "this"
AP ; -- adjectival phrase e.g. "very good"
AdA ; -- adadjective e.g. "very"
VP ; -- verb phrase e.g. "is good"
+ N ; -- noun e.g. "pizza"
+ A ; -- adjective e.g. "good"
V ; -- intransitive verb e.g. "boil"
V2 ; -- two-place verb e.g. "eat"
fun
+ PhrS : S -> Phr ;
+ PhrQS : QS -> Phr ;
+
PosVP, NegVP : NP -> VP -> S ;
+ QPosVP, QNegVP : NP -> VP -> QS ;
+
+ IPPosVP, IPNegVP : IP -> VP -> QS ;
+ IPPosV2, IPNegV2 : IP -> NP -> V2 -> QS ;
- PredAP : AP -> VP ;
- PredV : V -> VP ;
- PredV2 : V2 -> NP -> VP ;
+ ComplV2 : V2 -> NP -> VP ;
+ ComplAP : AP -> VP ;
DetCN : Det -> CN -> NP ;
@@ -26,6 +37,11 @@ abstract Syntax = {
AdAP : AdA -> AP -> AP ;
+ WhichCN : CN -> IP ;
+
+ UseN : N -> CN ;
+ UseA : A -> AP ;
+ UseV : V -> VP ;
-- entries of the closed lexicon
@@ -36,11 +52,9 @@ abstract Syntax = {
every_Det : Det ;
theSg_Det : Det ;
thePl_Det : Det ;
- a_Det : Det ;
+ indef_Det : Det ;
plur_Det : Det ;
two_Det : Det ;
very_AdA : AdA ;
- too_AdA : AdA ;
-
-} \ No newline at end of file
+}
diff --git a/doc/tutorial/resource/SyntaxEng.gf b/doc/tutorial/resource/SyntaxEng.gf
index e4787af47..4eac0058e 100644
--- a/doc/tutorial/resource/SyntaxEng.gf
+++ b/doc/tutorial/resource/SyntaxEng.gf
@@ -3,23 +3,53 @@
concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
lincat
+ Phr = {s : Str} ;
S = {s : Str} ;
- NP = {s : Str ; n : Number} ;
- CN = {s : Number => Str} ;
+ QS = {s : Str} ;
+ NP = MorphoEng.NP ;
+ IP = MorphoEng.NP ;
+ CN = Noun ;
Det = {s : Str ; n : Number} ;
AP = {s : Str} ;
AdA = {s : Str} ;
- VP = {s : Bool => Number => Str} ;
- V = {s : Number => Str} ;
- V2 = {s : Number => Str ; c : Str} ;
+ VP = MorphoEng.VP ;
+ N = Noun ;
+ A = {s : Str} ;
+ V = Verb ;
+ V2 = Verb ** {c : Str} ;
lin
- PosVP np vp = {s = np.s ++ vp.s ! True ! np.n} ;
- NegVP np vp = {s = np.s ++ vp.s ! False ! np.n} ;
+ PhrS = postfixSS "." ;
+ PhrQS = postfixSS "?" ;
- PredAP ap = {s = \\b,n => copula b n ++ ap.s} ;
- PredV v = {s = \\b,n => predVerb b n v} ;
- PredV2 v2 np = {s = \\b,n => predVerb b n v2 ++ v2.c ++ np.s} ;
+ PosVP = predVP True True ;
+ NegVP = predVP True False ;
+ QPosVP = predVP False True ;
+ QNegVP = predVP False False ;
+ IPPosVP = predVP True True ;
+ IPNegVP = predVP True False ;
+
+ IPPosV2 ip np v2 = {
+ s = let
+ vp : MorphoEng.VP = {s = \\q,b,n => predVerb v2 q b n} ;
+ in
+ bothWays (ip.s ++ (predVP False True np vp).s) v2.c
+ } ;
+ IPNegV2 ip np v2 = {
+ s = let
+ vp : MorphoEng.VP = {s = \\q,b,n => predVerb v2 q b n} ;
+ in
+ bothWays (ip.s ++ (predVP False False np vp).s) v2.c
+ } ;
+
+
+ ComplV2 v2 np = {
+ s = \\q,b,n =>
+ let vp = predVerb v2 q b n in
+ <vp.p1, vp.p2 ++ v2.c ++ np.s>
+ } ;
+
+ ComplAP ap = {s = \\_,b,n => <copula b n, ap.s>} ;
DetCN det cn = {s = det.s ++ cn.s ! det.n ; n = det.n} ;
@@ -27,6 +57,12 @@ concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
AdAP ada ap = {s = ada.s ++ ap.s} ;
+ WhichCN cn = {s = "which" ++ cn.s ! Sg ; n = Sg} ;
+
+ UseN n = n ;
+ UseA a = a ;
+ UseV v = {s = \\q,b,n => predVerb v q b n} ;
+
this_Det = {s = "this" ; n = Sg} ;
that_Det = {s = "that" ; n = Sg} ;
these_Det = {s = "these" ; n = Pl} ;
@@ -34,25 +70,39 @@ concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
every_Det = {s = "every" ; n = Sg} ;
theSg_Det = {s = "the" ; n = Sg} ;
thePl_Det = {s = "the" ; n = Pl} ;
- a_Det = {s = artIndef ; n = Sg} ;
+ indef_Det = {s = artIndef ; n = Sg} ;
plur_Det = {s = [] ; n = Pl} ;
two_Det = {s = "two" ; n = Pl} ;
very_AdA = {s = "very"} ;
- too_AdA = {s = "too"} ;
-
oper
+ predVP : Bool -> Bool -> MorphoEng.NP -> MorphoEng.VP -> SS =
+ \q,b,np,vp -> {
+ s = let vps = vp.s ! q ! b ! np.n
+ in case q of {
+ True => np.s ++ vps.p1 ++ vps.p2 ;
+ False => vps.p1 ++ np.s ++ vps.p2
+ }
+ } ;
+
copula : Bool -> Number -> Str = \b,n -> case n of {
Sg => posneg b "is" ;
Pl => posneg b "are"
} ;
- predVerb : Bool -> Number -> Verb -> Str = \b,n,verb ->
- let inf = verb.s ! Sg in
- case b of {
- True => verb.s ! n ;
- False => posneg b ((regVerb "do").s ! n) ++ inf
+ do : Bool -> Number -> Str = \b,n ->
+ posneg b ((regVerb "do").s ! n) ;
+
+ predVerb : Verb -> Bool -> Bool -> Number -> Str * Str = \verb,q,b,n ->
+ let
+ inf = verb.s ! Pl ;
+ fin = verb.s ! n ;
+ aux = do b n
+ in
+ case <q,b> of {
+ <True,True> => <[],fin> ;
+ _ => <aux,inf>
} ;
posneg : Bool -> Str -> Str = \b,do -> case b of {
@@ -62,6 +112,4 @@ concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
artIndef : Str =
pre {"a" ; "an" / strs {"a" ; "e" ; "i" ; "o"}} ;
-
-
}
diff --git a/doc/tutorial/resource/SyntaxIta.gf b/doc/tutorial/resource/SyntaxIta.gf
index 1633ac5f8..a0c2405e7 100644
--- a/doc/tutorial/resource/SyntaxIta.gf
+++ b/doc/tutorial/resource/SyntaxIta.gf
@@ -3,23 +3,38 @@
concrete SyntaxIta of Syntax = open Prelude, MorphoIta in {
lincat
+ Phr = {s : Str} ;
S = {s : Str} ;
+ QS = {s : Str} ;
NP = {s : Str ; g : Gender ; n : Number} ;
+ IP = {s : Str ; g : Gender ; n : Number} ;
CN = {s : Number => Str ; g : Gender} ;
Det = {s : Gender => Str ; n : Number} ;
AP = {s : Gender => Number => Str} ;
AdA = {s : Str} ;
VP = {s : Bool => Gender => Number => Str} ;
+
+ N = {s : Number => Str ; g : Gender} ;
+ A = {s : Gender => Number => Str} ;
V = {s : Number => Str} ;
V2 = {s : Number => Str ; c : Str} ;
lin
- PosVP np vp = {s = np.s ++ vp.s ! True ! np.g ! np.n} ;
- NegVP np vp = {s = np.s ++ vp.s ! False ! np.g ! np.n} ;
+ PhrS = postfixSS "." ;
+ PhrQS = postfixSS "?" ;
+
+ PosVP np vp = {s = np.s ++ vp.s ! True ! np.g ! np.n} ;
+ NegVP np vp = {s = np.s ++ vp.s ! False ! np.g ! np.n} ;
+ QPosVP np vp = {s = np.s ++ vp.s ! True ! np.g ! np.n} ;
+ QNegVP np vp = {s = np.s ++ vp.s ! False ! np.g ! np.n} ;
+ IPPosVP np vp = {s = np.s ++ vp.s ! True ! np.g ! np.n} ;
+ IPNegVP np vp = {s = np.s ++ vp.s ! False ! np.g ! np.n} ;
+
+ IPPosV2 ip np v2 = {s = v2.c ++ ip.s ++ v2.s ! np.n ++ np.s} ;
+ IPNegV2 ip np v2 = {s = v2.c ++ ip.s ++ "non" ++ v2.s ! np.n ++ np.s} ;
- PredAP ap = {s = \\b,g,n => posneg b ++ copula n ++ ap.s ! g ! n} ;
- PredV v = {s = \\b,_,n => posneg b ++ v.s ! n} ;
- PredV2 v2 np = {s = \\b,_,n => posneg b ++ v2.s ! n ++ v2.c ++ np.s} ;
+ ComplV2 v2 np = {s = \\b,_,n => posneg b ++ v2.s ! n ++ v2.c ++ np.s} ;
+ ComplAP ap = {s = \\b,g,n => posneg b ++ copula n ++ ap.s ! g ! n} ;
DetCN det cn = {s = det.s ! cn.g ++ cn.s ! det.n ; g = cn.g ; n = det.n} ;
@@ -27,6 +42,13 @@ concrete SyntaxIta of Syntax = open Prelude, MorphoIta in {
AdAP ada ap = {s = \\n,g => ada.s ++ ap.s ! n ! g} ;
+ WhichCN cn = {s = "quale" ++ cn.s ! Sg ; g = cn.g ; n = Sg} ;
+
+ UseN n = n ;
+ UseA a = a ;
+ UseV v = {s = \\b,_,n => posneg b ++ v.s ! n} ;
+
+
this_Det = mkDet Sg (regAdjective "questo") ;
that_Det = mkDet Sg (regAdjective "quello") ;
these_Det = mkDet Pl (regAdjective "questo") ;
@@ -34,17 +56,16 @@ concrete SyntaxIta of Syntax = open Prelude, MorphoIta in {
every_Det = {s = \\_ => "ogni" ; n = Sg} ;
theSg_Det = {s = artDef Sg ; n = Sg} ;
thePl_Det = {s = artDef Pl ; n = Pl} ;
- a_Det = {s = artIndef ; n = Pl} ;
+ indef_Det = {s = artIndef ; n = Sg} ;
plur_Det = {s = \\_ => [] ; n = Pl} ;
two_Det = {s = \\_ => "due" ; n = Pl} ;
very_AdA = {s = "molto"} ;
- too_AdA = {s = "troppo"} ;
oper
copula : Number -> Str = \n -> case n of {
- Sg => "รจ" ;
+ Sg => "่" ;
Pl => "sono"
} ;
diff --git a/doc/tutorial/resource/Test.gf b/doc/tutorial/resource/Test.gf
new file mode 100644
index 000000000..3ced1e55a
--- /dev/null
+++ b/doc/tutorial/resource/Test.gf
@@ -0,0 +1,8 @@
+abstract Test = Syntax ** {
+
+ fun
+ Wine, Cheese, Fish, Pizza, Waiter, Customer : N ;
+ Fresh, Warm, Italian, Expensive, Delicious, Boring : A ;
+ Stink : V ;
+ Eat, Love, Talk : V2 ;
+}
diff --git a/doc/tutorial/resource/TestEng.gf b/doc/tutorial/resource/TestEng.gf
new file mode 100644
index 000000000..3bfe52dfd
--- /dev/null
+++ b/doc/tutorial/resource/TestEng.gf
@@ -0,0 +1,23 @@
+--# -path=.:resource:prelude
+
+concrete TestEng of Test = SyntaxEng ** open Prelude, MorphoEng in {
+
+ lin
+ Wine = regNoun "wine" ;
+ Cheese = regNoun "cheese" ;
+ Fish = mkNoun "fish" "fish" ;
+ Pizza = regNoun "pizza" ;
+ Waiter = regNoun "waiter" ;
+ Customer = regNoun "customer" ;
+ Fresh = ss "fresh" ;
+ Warm = ss "warm" ;
+ Italian = ss "Italian" ;
+ Expensive = ss "expensive" ;
+ Delicious = ss "delicious" ;
+ Boring = ss "boring" ;
+ Stink = regVerb "stink" ;
+ Eat = regVerb "eat" ** {c = []} ;
+ Love = regVerb "love" ** {c = []} ;
+ Talk = regVerb "talk" ** {c = "about"} ;
+}
+
diff --git a/doc/tutorial/resource/TestIta.gf b/doc/tutorial/resource/TestIta.gf
new file mode 100644
index 000000000..d58b258cd
--- /dev/null
+++ b/doc/tutorial/resource/TestIta.gf
@@ -0,0 +1,23 @@
+--# -path=.:resource:prelude
+
+concrete TestIta of Test = SyntaxIta ** open Prelude, MorphoIta in {
+
+ lin
+ Wine = regNoun "vino" ;
+ Cheese = regNoun "formaggio" ;
+ Fish = regNoun "pesce" ;
+ Pizza = regNoun "pizza" ;
+ Waiter = regNoun "cameriere" ;
+ Customer = regNoun "cliente" ;
+ Fresh = regAdjective "fresco" ;
+ Warm = regAdjective "caldo" ;
+ Italian = regAdjective "italiano" ;
+ Expensive = regAdjective "caro" ;
+ Delicious = regAdjective "delizioso" ;
+ Boring = regAdjective "noioso" ;
+ Stink = regVerb "puzzare" ;
+ Eat = regVerb "mangiare" ** {c = []} ;
+ Love = regVerb "amare" ** {c = []} ;
+ Talk = regVerb "parlare" ** {c = "di"} ;
+}
+