summaryrefslogtreecommitdiff
path: root/examples/phrasebook/SentencesI.gf
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-03-30 15:39:11 +0000
committeraarne <aarne@chalmers.se>2010-03-30 15:39:11 +0000
commitde909a4e44419562ca4ba071e15cf9b8e00288be (patch)
treefdae4da7fbce3edb0276a93219495c019fdaca08 /examples/phrasebook/SentencesI.gf
parent4bae49c6341fc831f474f1fffc0f763892ef696d (diff)
disambiguation in Phrasebook grammars, PGF server, and the GUI
Diffstat (limited to 'examples/phrasebook/SentencesI.gf')
-rw-r--r--examples/phrasebook/SentencesI.gf55
1 files changed, 39 insertions, 16 deletions
diff --git a/examples/phrasebook/SentencesI.gf b/examples/phrasebook/SentencesI.gf
index 235509ec1..47029360f 100644
--- a/examples/phrasebook/SentencesI.gf
+++ b/examples/phrasebook/SentencesI.gf
@@ -1,12 +1,15 @@
incomplete concrete SentencesI of Sentences = Numeral **
open
DiffPhrasebook,
- Syntax
+ Syntax,
+ (R = Roles),
+ Prelude
in {
lincat
Phrase = Text ;
- Sentence = S ;
- Question = QS ;
+ Politeness = {s : Str ; p : R.Politeness} ;
+ Sentence = {s : R.Politeness => S} ;
+ Question = {s : R.Politeness => QS} ;
Item = NP ;
Kind = CN ;
Quality = AP ;
@@ -15,10 +18,16 @@ incomplete concrete SentencesI of Sentences = Numeral **
PlaceKind = CN ;
Currency = CN ;
Price = NP ;
- Action = Cl ;
- Person = NP ;
+ Action = {s : R.Politeness => Cl} ;
+ Person = {s : R.Politeness => NP} ;
Language = NP ;
lin
+--- todo: add speaker and hearer genders
+ PSentence p g = let s = g.s ! p.p in
+ mkText (mkText s | lin Text (mkUtt s)) (lin Text (ss p.s)) ; -- optional '.'
+ PQuestion p g = let s = g.s ! p.p in
+ mkText (mkText s | lin Text (mkUtt s)) (lin Text (ss p.s)) ; -- optional '?'
+
PObject x = mkPhrase (mkUtt x) ;
PKind x = mkPhrase (mkUtt x) ;
PQuality x = mkPhrase (mkUtt x) ;
@@ -29,17 +38,18 @@ incomplete concrete SentencesI of Sentences = Numeral **
PPrice x = mkPhrase (mkUtt x) ;
PLanguage x = mkPhrase (mkUtt x) ;
- Is item quality = mkS (mkCl item quality) ;
- IsNot item quality = mkS negativePol (mkCl item quality) ;
- WhetherIs item quality = mkQS (mkQCl (mkCl item quality)) ;
- WhereIs place = mkQS (mkQCl where_IAdv place) ;
+ Is item quality = neutralS (mkS (mkCl item quality)) ;
+ IsNot item quality = neutralS (mkS negativePol (mkCl item quality)) ;
+ WhetherIs item quality = neutralQS (mkQS (mkQCl (mkCl item quality))) ;
+ WhereIs place = neutralQS (mkQS (mkQCl where_IAdv place)) ;
- SAction = mkS ;
- SNotAction = mkS negativePol ;
- QAction a = mkQS (mkQCl a) ;
+ SAction a = {s = \\p => mkS (a.s ! p)} ;
+ SNotAction a = {s = \\p => mkS negativePol (a.s ! p)} ;
+ QAction a = {s = \\p => mkQS (mkQCl (a.s ! p))} ;
- HowMuchCost item = mkQS (mkQCl how8much_IAdv (mkCl item cost_V)) ;
- ItCost item price = mkS (mkCl item cost_V2 price) ;
+ HowMuchCost item = neutralQS (mkQS (mkQCl how8much_IAdv (mkCl item cost_V))) ;
+ ItCost item price = neutralS (mkS (mkCl item cost_V2 price)) ;
+
AmountCurrency num curr = mkNP <lin Numeral num : Numeral> curr ;
ObjItem i = i ;
@@ -57,10 +67,23 @@ incomplete concrete SentencesI of Sentences = Numeral **
Too quality = mkAP too_AdA quality ;
ThePlace kind = mkNP the_Quant kind ;
- I = mkNP i_Pron ;
- You = mkNP youPol_Pron ;
+ I = {s = \\_ => mkNP i_Pron} ;
+ You = {s = table {R.PPolite => mkNP youPol_Pron ; R.PFamiliar => mkNP youSg_Pron}} ;
+
+ Polite = {s = [] ; p = R.PPolite} ;
+ Familiar = {s = [] ; p = R.PFamiliar} ;
+-- Male = {s = [] ; g = R.Male} ;
+-- Female = {s = [] ; g = R.Female} ;
oper
mkPhrase : Utt -> Text = \u -> lin Text u ; -- no punctuation
+ politeS : S -> S -> {s : R.Politeness => S} = \pol,fam ->
+ {s = table {R.PPolite => pol ; R.PFamiliar => fam}} ;
+ neutralS : S -> {s : R.Politeness => S} = \pol -> politeS pol pol ;
+ politeQS : QS -> QS -> {s : R.Politeness => QS} = \pol,fam ->
+ {s = table {R.PPolite => pol ; R.PFamiliar => fam}} ;
+ neutralQS : QS -> {s : R.Politeness => QS} = \pol -> politeQS pol pol ;
+---- it would be greate to use overloading here
+
}