diff --git a/examples/tram/README b/examples/tram/README new file mode 100644 index 000000000..552b160f3 --- /dev/null +++ b/examples/tram/README @@ -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. diff --git a/examples/tram/Tram.gf b/examples/tram/Tram.gf new file mode 100644 index 000000000..bcd9f7b7c --- /dev/null +++ b/examples/tram/Tram.gf @@ -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 + +} diff --git a/examples/tram/TramEng.gf b/examples/tram/TramEng.gf new file mode 100644 index 000000000..58a7bd8de --- /dev/null +++ b/examples/tram/TramEng.gf @@ -0,0 +1,5 @@ +--# -path=.:resource/abstract:resource/english:prelude + +concrete TramEng of Tram = TramI with + (Multimodal = MultimodalEng), + (Math = MathEng) ; diff --git a/examples/tram/TramFre.gf b/examples/tram/TramFre.gf new file mode 100644 index 000000000..4d6909640 --- /dev/null +++ b/examples/tram/TramFre.gf @@ -0,0 +1,5 @@ +--# -path=.:resource/abstract:resource/french:resource/romance:prelude + +concrete TramFre of Tram = TramI with + (Multimodal = MultimodalFre), + (Math = MathFre) ; diff --git a/examples/tram/TramI.gf b/examples/tram/TramI.gf new file mode 100644 index 000000000..384cdbf3b --- /dev/null +++ b/examples/tram/TramI.gf @@ -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)) ; + +} diff --git a/examples/tram/TramSwe.gf b/examples/tram/TramSwe.gf new file mode 100644 index 000000000..6875fafa2 --- /dev/null +++ b/examples/tram/TramSwe.gf @@ -0,0 +1,5 @@ +--# -path=.:resource/abstract:resource/swedish:resource/scandinavian:prelude + +concrete TramSwe of Tram = TramI with + (Multimodal = MultimodalSwe), + (Math = MathSwe) ; diff --git a/lib/resource/abstract/DemRes.gf b/lib/resource/abstract/DemRes.gf index add595ea6..7de00e17d 100644 --- a/lib/resource/abstract/DemRes.gf +++ b/lib/resource/abstract/DemRes.gf @@ -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 ; diff --git a/lib/resource/abstract/Demonstrative.gf b/lib/resource/abstract/Demonstrative.gf index 18c7d7893..157469ffa 100644 --- a/lib/resource/abstract/Demonstrative.gf +++ b/lib/resource/abstract/Demonstrative.gf @@ -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 ; } diff --git a/lib/resource/abstract/DemonstrativeI.gf b/lib/resource/abstract/DemonstrativeI.gf index 4dd6eff75..751d52346 100644 --- a/lib/resource/abstract/DemonstrativeI.gf +++ b/lib/resource/abstract/DemonstrativeI.gf @@ -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"} ; } diff --git a/lib/resource/abstract/Multimodal.gf b/lib/resource/abstract/Multimodal.gf index de25a4598..5fba52b67 100644 --- a/lib/resource/abstract/Multimodal.gf +++ b/lib/resource/abstract/Multimodal.gf @@ -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))) --} diff --git a/lib/resource/abstract/MultimodalI.gf b/lib/resource/abstract/MultimodalI.gf index fd10e01e2..1188e9012 100644 --- a/lib/resource/abstract/MultimodalI.gf +++ b/lib/resource/abstract/MultimodalI.gf @@ -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} ; diff --git a/lib/resource/french/DemResFre.gf b/lib/resource/french/DemResFre.gf new file mode 100644 index 000000000..b852fd6f1 --- /dev/null +++ b/lib/resource/french/DemResFre.gf @@ -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 ; + + +} ; diff --git a/lib/resource/french/DemonstrativeFre.gf b/lib/resource/french/DemonstrativeFre.gf new file mode 100644 index 000000000..18b066cf8 --- /dev/null +++ b/lib/resource/french/DemonstrativeFre.gf @@ -0,0 +1,7 @@ +--# -path=.:../abstract:../romance:../../prelude + +concrete DemonstrativeFre of Demonstrative = + CategoriesFre ** DemonstrativeI with + (Resource = ResourceFre), + (Basic = BasicFre), + (DemRes = DemResFre) ; diff --git a/lib/resource/french/MultimodalFre.gf b/lib/resource/french/MultimodalFre.gf new file mode 100644 index 000000000..cd07cbbfb --- /dev/null +++ b/lib/resource/french/MultimodalFre.gf @@ -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) ;