mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
trams with mm library
This commit is contained in:
15
examples/tram/README
Normal file
15
examples/tram/README
Normal file
@@ -0,0 +1,15 @@
|
||||
Björn Bringert's tram grammars (user side, without place names)
|
||||
implemented as an example of lib/resource/abstract/Multimodal.
|
||||
|
||||
For documentation of the original system, see
|
||||
|
||||
http://www.cs.chalmers.se/~bringert/gf/tramdemo.html
|
||||
|
||||
To try, do in gf
|
||||
|
||||
i -src TramEng.gf
|
||||
gr | l -tr | p
|
||||
|
||||
Clicks appear as coordinates on the right of the semicolon.
|
||||
|
||||
AR 7/11/2005.
|
||||
33
examples/tram/Tram.gf
Normal file
33
examples/tram/Tram.gf
Normal file
@@ -0,0 +1,33 @@
|
||||
abstract Tram = {
|
||||
|
||||
cat
|
||||
Dep ; -- from here, from Angered
|
||||
Dest ; -- to here, to Angered
|
||||
Query ; -- message sent to the dialogue manager: sequentialized
|
||||
Input ; -- user input: parallel text and clicks
|
||||
Click ; -- map clicks
|
||||
|
||||
fun
|
||||
QInput : Input -> Query ; -- sequentialize user input
|
||||
|
||||
fun
|
||||
GoFromTo : Dep -> Dest -> Input ; -- user input "want to go from a to b"
|
||||
GoToFrom : Dest -> Dep -> Input ; -- user input "want to go to a from b"
|
||||
ComeFrom : Dep -> Input ; -- user input "want to come from x (to where I am now)
|
||||
GoTo : Dest -> Input ; -- user input "want to go to x (from where I am now)
|
||||
|
||||
DepClick : Click -> Dep ; -- "from here" with click
|
||||
DestClick : Click -> Dest ; -- "to here" with click
|
||||
DepHere : Dep ; -- "from here" indexical
|
||||
DestHere : Dest ; -- "to here" indexical
|
||||
DepNamed : String -> Dep ; -- from a place name
|
||||
DestNamed : String -> Dest ; -- to a place name
|
||||
|
||||
CCoord : Int -> Int -> Click ;
|
||||
|
||||
--- the syntax of here (prep + adverb, not prep + np) prevent these
|
||||
-- Place ; -- any way to identify a place: name, click, or indexical "here"
|
||||
-- PClick : Click -> Place ; -- click associated with a "here"
|
||||
-- PHere : Place ; -- indexical "here", without a click
|
||||
|
||||
}
|
||||
5
examples/tram/TramEng.gf
Normal file
5
examples/tram/TramEng.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
--# -path=.:resource/abstract:resource/english:prelude
|
||||
|
||||
concrete TramEng of Tram = TramI with
|
||||
(Multimodal = MultimodalEng),
|
||||
(Math = MathEng) ;
|
||||
5
examples/tram/TramFre.gf
Normal file
5
examples/tram/TramFre.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
--# -path=.:resource/abstract:resource/french:resource/romance:prelude
|
||||
|
||||
concrete TramFre of Tram = TramI with
|
||||
(Multimodal = MultimodalFre),
|
||||
(Math = MathFre) ;
|
||||
44
examples/tram/TramI.gf
Normal file
44
examples/tram/TramI.gf
Normal file
@@ -0,0 +1,44 @@
|
||||
incomplete concrete TramI of Tram = open Multimodal, Math in {
|
||||
|
||||
flags startcat=Query ; lexer=textlit ;
|
||||
|
||||
lincat
|
||||
Dep, Dest = DAdv ;
|
||||
Query = Phr ; -- top level, plain string
|
||||
Input = MS ; -- two parallel sequences (text and clicks)
|
||||
Click = Point ;
|
||||
|
||||
lin
|
||||
QInput i = SentMS PPos i ;
|
||||
|
||||
GoFromTo x y =
|
||||
ModDemV want_VV go_V (DemNP i_NP)
|
||||
(ConsDAdv x (ConsDAdv y BaseDAdv)) ;
|
||||
|
||||
GoToFrom x y =
|
||||
ModDemV want_VV go_V (DemNP i_NP)
|
||||
(ConsDAdv x (ConsDAdv y BaseDAdv)) ;
|
||||
|
||||
ComeFrom x =
|
||||
ModDemV want_VV come_V (DemNP i_NP)
|
||||
(ConsDAdv x BaseDAdv) ;
|
||||
|
||||
GoTo x =
|
||||
ModDemV want_VV go_V (DemNP i_NP)
|
||||
(ConsDAdv x BaseDAdv) ;
|
||||
|
||||
DepClick c = here7from_DAdv c ;
|
||||
DestClick c = here7to_DAdv c ;
|
||||
DepHere = DemAdv here7from_Adv ;
|
||||
DestHere = DemAdv here7to_Adv ;
|
||||
DepNamed s = PrepDNP from_Prep (DemNP (UsePN (SymbPN s))) ;
|
||||
DestNamed s = PrepDNP to_Prep (DemNP (UsePN (SymbPN s))) ;
|
||||
|
||||
CCoord x y = {s5 = "(" ++ x.s ++ "," ++ y.s ++ ")" ; lock_Point = <>} ;
|
||||
|
||||
-- Place = DNP ; -- name + click - not possible for "here"
|
||||
-- PClick c = this_DNP c ;
|
||||
-- PHere = DemNP this_NP ;
|
||||
-- PNamed s = DemNP (UsePN (SymbPN s)) ;
|
||||
|
||||
}
|
||||
5
examples/tram/TramSwe.gf
Normal file
5
examples/tram/TramSwe.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
--# -path=.:resource/abstract:resource/swedish:resource/scandinavian:prelude
|
||||
|
||||
concrete TramSwe of Tram = TramI with
|
||||
(Multimodal = MultimodalSwe),
|
||||
(Math = MathSwe) ;
|
||||
@@ -47,8 +47,8 @@ interface DemRes = open Prelude, Resource in {
|
||||
Demonstrative : Type = mkDemType NP ;
|
||||
DemAdverb : Type = mkDemType Adv ;
|
||||
|
||||
addDAdv : Adv -> Pointing -> DemAdverb -> DemAdverb = \a,p,d ->
|
||||
{s = a.s ++ d.s ; s5 = p.s5 ++ d.s5 ; lock_Adv = a.lock_Adv} ;
|
||||
mkDAdv : Adv -> Pointing -> DemAdverb = \a,p ->
|
||||
a ** p ** {lock_Adv = a.lock_Adv} ;
|
||||
|
||||
param
|
||||
MSForm = MInd Bool | MQuest Bool ;
|
||||
|
||||
@@ -1,39 +1,44 @@
|
||||
abstract Demonstrative = Categories ** {
|
||||
|
||||
cat
|
||||
MS ; -- multimodal sentence or question
|
||||
MQS ; -- multimodal wh question
|
||||
MImp ; -- multimodal imperative
|
||||
DNP ; -- demonstrative noun phrase
|
||||
DAdv ; -- demonstrative adverbial
|
||||
Point ; -- pointing gesture
|
||||
MS ; -- multimodal sentence or question
|
||||
MQS ; -- multimodal wh question
|
||||
MImp ; -- multimodal imperative
|
||||
DNP ; -- demonstrative noun phrase
|
||||
DAdv ; -- demonstrative adverbial
|
||||
[DAdv] ; -- list of demonstrative adverbials
|
||||
Point ; -- pointing gesture
|
||||
|
||||
fun
|
||||
MkPoint : String -> Point ;
|
||||
|
||||
DemV : V -> DNP -> DAdv -> MS ; -- this flies (here)
|
||||
DemV2 : V2 -> DNP -> DNP -> DAdv -> MS ; -- this takes that
|
||||
ModDemV : VV -> V -> DNP -> DAdv -> MS ; -- this wants to fly
|
||||
ModDemV2 : VV -> V2 -> DNP -> DNP -> DAdv -> MS ; -- this wants to take that
|
||||
DemV : V -> DNP -> [DAdv] -> MS ; -- this flies (here)
|
||||
DemV2 : V2 -> DNP -> DNP -> [DAdv] -> MS ; -- this takes that
|
||||
ModDemV : VV -> V -> DNP -> [DAdv] -> MS ; -- this wants to fly
|
||||
ModDemV2 : VV -> V2 -> DNP -> DNP -> [DAdv] -> MS ; -- this wants to take that
|
||||
|
||||
ImpDemV : V -> DAdv -> MImp ; -- fly (here)
|
||||
ImpDemV2 : V2 -> DNP -> DAdv -> MImp ; -- take that
|
||||
ImpDemV : V -> [DAdv] -> MImp ; -- fly (here)
|
||||
ImpDemV2 : V2 -> DNP -> [DAdv] -> MImp ; -- take that
|
||||
|
||||
QDemV : V -> IP -> DAdv -> MQS ; -- who flies (here)
|
||||
QDemV2 : V2 -> IP -> DNP -> DAdv -> MQS ; -- who takes that
|
||||
QDemSlashV2 : V2 -> DNP -> IP -> DAdv -> MQS ; -- whom does that take
|
||||
QModDemV : VV -> V -> IP -> DAdv -> MQS ; -- who wants to fly (here)
|
||||
QModDemV2 : VV -> V2 -> IP -> DNP -> DAdv -> MQS ; -- who wants to take that
|
||||
QModDemSlashV2 : VV -> V2 -> DNP -> IP -> DAdv -> MQS ; -- whom does that want to take
|
||||
QDemV : V -> IP -> [DAdv] -> MQS ; -- who flies (here)
|
||||
QDemV2 : V2 -> IP -> DNP -> [DAdv] -> MQS ; -- who takes that
|
||||
QDemSlashV2 : V2 -> DNP -> IP -> [DAdv] -> MQS ; -- whom does that take
|
||||
QModDemV : VV -> V -> IP -> [DAdv] -> MQS ; -- who wants to fly (here)
|
||||
QModDemV2 : VV -> V2 -> IP -> DNP -> [DAdv] -> MQS ; -- who wants to take that
|
||||
QModDemSlashV2 : VV -> V2 -> DNP -> IP -> [DAdv] -> MQS ; -- whom does that want to take
|
||||
|
||||
this_DNP : Point -> DNP ; -- this
|
||||
that_DNP : Point -> DNP ; -- that
|
||||
thisDet_DNP : Point -> CN -> DNP ; -- this car
|
||||
thatDet_DNP : Point -> CN -> DNP ; -- that car
|
||||
|
||||
here_DAdv : Point -> DAdv -> DAdv ; -- here
|
||||
here7from_DAdv : Point -> DAdv -> DAdv ; -- from here
|
||||
here7to_DAdv : Point -> DAdv -> DAdv ; -- to here
|
||||
NoDAdv : DAdv ;
|
||||
here_DAdv : Point -> DAdv ; -- here
|
||||
here7from_DAdv : Point -> DAdv ; -- from here
|
||||
here7to_DAdv : Point -> DAdv ; -- to here
|
||||
|
||||
PrepDNP : Prep -> DNP -> DAdv ;
|
||||
|
||||
-- to test
|
||||
|
||||
point1, point2 : Point ;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@ incomplete concrete DemonstrativeI of Demonstrative =
|
||||
open Prelude, Resource, Basic, DemRes in {
|
||||
|
||||
lincat
|
||||
MS = MultiSentence ;
|
||||
MQS = MultiQuestion ;
|
||||
MImp = MultiImperative ;
|
||||
DNP = Demonstrative ;
|
||||
DAdv = DemAdverb ;
|
||||
Point = Pointing ;
|
||||
MS = MultiSentence ;
|
||||
MQS = MultiQuestion ;
|
||||
MImp = MultiImperative ;
|
||||
DNP = Demonstrative ;
|
||||
DAdv = DemAdverb ;
|
||||
[DAdv] = DemAdverb ;
|
||||
Point = Pointing ;
|
||||
|
||||
lin
|
||||
MkPoint s = {s5 = s.s} ;
|
||||
@@ -46,10 +47,16 @@ incomplete concrete DemonstrativeI of Demonstrative =
|
||||
thisDet_DNP p cn = DetNP this_Det cn ** p ;
|
||||
thatDet_DNP p cn = DetNP that_Det cn ** p ;
|
||||
|
||||
here_DAdv p = addDAdv here_Adv p ;
|
||||
here7from_DAdv p = addDAdv here7from_Adv p ;
|
||||
here7to_DAdv p = addDAdv here7to_Adv p ;
|
||||
here_DAdv p = mkDAdv here_Adv p ;
|
||||
here7from_DAdv p = mkDAdv here7from_Adv p ;
|
||||
here7to_DAdv p = mkDAdv here7to_Adv p ;
|
||||
|
||||
NoDAdv = {s,s5 = [] ; lock_Adv = <>} ;
|
||||
BaseDAdv = {s,s5 = [] ; lock_Adv = <>} ;
|
||||
ConsDAdv a as = {s = a.s ++ as.s ; s5 = a.s5 ++ as.s5 ; lock_Adv = <>} ;
|
||||
|
||||
PrepDNP p np = mkDAdv (AdvPP (PrepNP p np)) np ;
|
||||
|
||||
point1 = {s5 = "p1"} ;
|
||||
point2 = {s5 = "p2"} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ abstract Multimodal =
|
||||
-- Interface to $Demonstrative$.
|
||||
|
||||
DemNP : NP -> DNP ;
|
||||
DemAdv : Adv -> DAdv -> DAdv ;
|
||||
DemAdv : Adv -> DAdv ;
|
||||
SentMS : Pol -> MS -> Phr ;
|
||||
QuestMS : Pol -> MS -> Phr ;
|
||||
QuestMQS : Pol -> MQS -> Phr ;
|
||||
@@ -28,13 +28,3 @@ abstract Multimodal =
|
||||
AdvTime : Time -> Adv ;
|
||||
|
||||
}
|
||||
|
||||
{-
|
||||
> p -cat=Phr "I go from here to here ; foo bar"
|
||||
SentMS (DemV go_V (DemNP i_NP)
|
||||
(here7from_DAdv (MkPoint "foo") (here7to_DAdv (MkPoint "bar") NoDAdv)))
|
||||
|
||||
> p -cat=Phr "which cars go from here to here ; foo bar"
|
||||
QuestMQ (QDemV go_V (IDetCN which8many_IDet (UseN car_N))
|
||||
(here7from_DAdv (MkPoint "foo") (here7to_DAdv (MkPoint "bar") NoDAdv)))
|
||||
-}
|
||||
|
||||
@@ -3,7 +3,7 @@ incomplete concrete MultimodalI of Multimodal =
|
||||
|
||||
lin
|
||||
DemNP np = np ** {s5 = [] ; lock_NP = <>} ;
|
||||
DemAdv adv = addDAdv (adv ** {lock_Adv = <>}) {s5 = []} ;
|
||||
DemAdv adv = mkDAdv (adv ** {lock_Adv = <>}) {s5 = []} ;
|
||||
SentMS p ms = {s = p.s ++ ms.s ! MInd (p.p) ++ ";" ++ ms.s5} ;
|
||||
QuestMS p ms = {s = p.s ++ ms.s ! MQuest (p.p) ++ ";" ++ ms.s5} ;
|
||||
QuestMQS p ms = {s = p.s ++ ms.s ! p.p ++ ";" ++ ms.s5} ;
|
||||
|
||||
9
lib/resource/french/DemResFre.gf
Normal file
9
lib/resource/french/DemResFre.gf
Normal file
@@ -0,0 +1,9 @@
|
||||
instance DemResFre of DemRes = open Prelude, ResourceFre, SyntaxFre in {
|
||||
|
||||
oper
|
||||
msS : S -> Str = \x -> x.s ! Ind ;
|
||||
msQS : QS -> Str = \x -> x.s ! DirQ ;
|
||||
msImp : Imp -> Str = \x -> x.s ! Masc ! Sg ;
|
||||
|
||||
|
||||
} ;
|
||||
7
lib/resource/french/DemonstrativeFre.gf
Normal file
7
lib/resource/french/DemonstrativeFre.gf
Normal file
@@ -0,0 +1,7 @@
|
||||
--# -path=.:../abstract:../romance:../../prelude
|
||||
|
||||
concrete DemonstrativeFre of Demonstrative =
|
||||
CategoriesFre ** DemonstrativeI with
|
||||
(Resource = ResourceFre),
|
||||
(Basic = BasicFre),
|
||||
(DemRes = DemResFre) ;
|
||||
8
lib/resource/french/MultimodalFre.gf
Normal file
8
lib/resource/french/MultimodalFre.gf
Normal file
@@ -0,0 +1,8 @@
|
||||
--# -path=.:../abstract:../romance:../../prelude
|
||||
|
||||
concrete MultimodalFre of Multimodal =
|
||||
RulesFre, StructuralFre, BasicFre, TimeFre, DemonstrativeFre ** MultimodalI with
|
||||
(Resource = ResourceFre),
|
||||
(Basic = BasicFre),
|
||||
(Lang = LangFre),
|
||||
(DemRes = DemResFre) ;
|
||||
Reference in New Issue
Block a user