grammar for messages started

This commit is contained in:
aarne
2010-06-21 16:50:40 +00:00
parent e94a1c7408
commit 3714a7e3b4
3 changed files with 173 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
abstract Messages =
Words - [IMale, IFemale, YouFamMale, YouFamFemale, YouPolMale, YouPolFemale],
Greetings ** {
flags startcat = Message ;
cat
Message ;
Heading ;
Body ;
Ending ;
Statement ;
Recipient ;
Sender ;
Title ;
Role ;
fun
Msg : Heading -> Body -> Ending -> Message ;
HHello : Recipient -> Heading ;
HDear : Recipient -> Heading ;
BOne : Statement -> Body ;
BMore : Statement -> Body -> Body ;
ERegards : Sender -> Ending ;
SSentence : Sentence -> Statement ;
SQuestion : Question -> Statement ;
SGreeting : Greeting -> Statement ;
RName : Name -> Recipient ;
RTitle : Title -> Name -> Recipient ;
SName : Name -> Sender ;
TMr : Title ;
TMs : Title ;
RI : Role ; -- generic: Gender and Politeness from context
RYou : Role ;
PRole : Role -> Person ;
}

View File

@@ -0,0 +1,54 @@
--# -path=.:../phrasebook:present
concrete MessagesEng of Messages =
WordsEng -
[IMale, IFemale, YouFamMale, YouFamFemale, YouPolMale, YouPolFemale],
GreetingsEng ** open
SyntaxEng,
ParadigmsEng,
(Phr = PhrasebookEng)
in {
lincat
Message = Text ;
Heading = Text ;
Body = Text ;
Ending = Text ;
Statement = Text ;
Recipient = NP ;
Sender = NP ;
Title = CN ;
Role = Phr.NPPerson ;
lin
Msg h b e = mkText h (mkText b e) ;
HHello n =
mkText (strText "hello") (mkText (mkPhrase (mkUtt n)) (strText ",")) ;
HDear n =
mkText (strText "dear") (mkText (mkPhrase (mkUtt n)) (strText ",")) ;
BOne p = p ;
BMore p b = mkText p b ;
ERegards n = mkText (strText "regards") (mkPhrase (mkUtt n)) ;
SSentence s = mkText s ;
SQuestion s = mkText s ;
SGreeting s = mkText s exclMarkPunct ;
RName n = n ;
RTitle t n = mkNP (mkCN t n) ;
SName n = n ;
TMr = mkCN (mkN "Mr") ;
TMs = mkCN (mkN "Ms") ;
RI = Phr.IMale ; -- gender and politeness don't matter in English
RYou = Phr.YouFamMale ;
PRole r = r ;
oper
strText : Str -> Text = \s -> lin Text {s = s} ;
}

View File

@@ -0,0 +1,74 @@
--# -path=.:../phrasebook:present
concrete MessagesFre of Messages =
WordsFre -
[IMale, IFemale, YouFamMale, YouFamFemale, YouPolMale, YouPolFemale],
GreetingsFre **
open
SyntaxFre,
ParadigmsFre,
Prelude,
(Phr = PhrasebookFre)
in {
lincat
Message = Text ;
Heading = {s : Text ; g : Gender ; isPol : Bool} ;
Body = {s : Gender => Gender => Bool => Text} ;
Ending = {s : Text ; g : Gender} ;
Statement = {s : Gender => Gender => Bool => Text} ;
Recipient = NP ;
Sender = NP ;
Title = CN ;
Role = Phr.NPPerson ;
lin
Msg h b e = mkText h.s (mkText (b.s ! h.g ! e.g ! h.isPol) e.s) ;
HHello n = {
s = mkText (strText "bonjour") (mkText (mkPhrase (mkUtt n)) (strText ",")) ;
g = n.a.g ; ----Res
isPol = n.isPol ----Res
} ;
HDear r = {
s = mkText
(mkPhrase (mkUtt (mkCN (prefixA (mkA "cher")) (nameCN r))))
(strText ",") ;
g = r.a.g ; ----Res
isPol = r.isPol ----Res
} ;
BOne p = p ;
BMore s b = {s = \\i,y,p => mkText (s.s ! i ! y ! p) (b.s ! i ! y ! p)} ;
ERegards n = {
s = mkText (strText "avec salutations") (mkPhrase (mkUtt n)) ;
g = n.a.g ----Res
} ;
SSentence s = {s = \\i,y,p => mkText s} ;
SQuestion s = {s = \\i,y,p => mkText s} ;
SGreeting s = {s = \\i,y,p => mkText s exclMarkPunct} ;
RName n = n ;
RTitle t n = cnNP (mkCN t n) ;
SName n = n ;
TMr = mkCN (mkN "monsieur" "messieurs" masculine) ;
TMs = mkCN (mkN "madame" "mesdames" feminine) ;
RI = Phr.IMale ;
RYou = Phr.YouFamMale ;
PRole r = r ;
oper
strText : Str -> Text = \s -> lin Text {s = s} ;
---- TODO in RG and its API
nameCN : NP -> CN = \n -> mkCN (mkN "") n ;
cnNP : CN -> NP = \cn -> mkNP (mkPN (cn.s ! singular) cn.g) ;
}