diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-06-25 16:54:35 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-06-25 16:54:35 +0000 |
| commit | e9e80fc389365e24d4300d7d5390c7d833a96c50 (patch) | |
| tree | f0b58473adaa670bd8fc52ada419d8cad470ee03 /old-examples/dialogue | |
| parent | b96b36f43de3e2f8b58d5f539daa6f6d47f25870 (diff) | |
changed names of resource-1.3; added a note on homepage on release
Diffstat (limited to 'old-examples/dialogue')
34 files changed, 748 insertions, 0 deletions
diff --git a/old-examples/dialogue/Agenda.gf b/old-examples/dialogue/Agenda.gf new file mode 100644 index 000000000..970f7bc55 --- /dev/null +++ b/old-examples/dialogue/Agenda.gf @@ -0,0 +1,12 @@ +abstract Agenda = Dialogue, Weekday ** { + + fun + Day : Kind ; + Meeting : Kind ; + Add : Oper2 Meeting Day ; + Remove : Oper1 Meeting ; + Interrupt : Oper0 ; + + day : WDay -> Object Day ; + +} diff --git a/old-examples/dialogue/AgendaEng.gf b/old-examples/dialogue/AgendaEng.gf new file mode 100644 index 000000000..658853004 --- /dev/null +++ b/old-examples/dialogue/AgendaEng.gf @@ -0,0 +1,15 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete AgendaEng of Agenda = + DialogueEng, WeekdayEng ** open MultiEng, ParadigmsEng in { + + lin + Day = UseN (regN "day") ; + Meeting = UseN (regN "meeting") ; + Add = dirV3 (regV "add") (mkPrep "on") ; + Remove = dirV2 (regV "remove") ; + Interrupt = regV "interrupt" ; + + day = UsePN ; + +} diff --git a/old-examples/dialogue/AgendaFin.gf b/old-examples/dialogue/AgendaFin.gf new file mode 100644 index 000000000..67074acad --- /dev/null +++ b/old-examples/dialogue/AgendaFin.gf @@ -0,0 +1,15 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete AgendaFin of Agenda = + DialogueFin, WeekdayFin ** open MultiFin, ParadigmsFin in { + + lin + Day = UseN (regN "päivä") ; + Meeting = UseN (regN "kokous") ; + Add = dirV3 (regV "lisätä") translative ; + Remove = dirV2 (regV "poistaa") ; + Interrupt = regV "keskeyttää" ; + + day = UsePN ; + +} diff --git a/old-examples/dialogue/AgendaFre.gf b/old-examples/dialogue/AgendaFre.gf new file mode 100644 index 000000000..e435e0428 --- /dev/null +++ b/old-examples/dialogue/AgendaFre.gf @@ -0,0 +1,16 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete AgendaFre of Agenda = + DialogueFre, WeekdayFre ** open MultiFre, ParadigmsFre, IrregFre in { + + lin + Day = UseN (regN "jour") ; + Meeting = UseN (regN "réunion") ; + Add = dirdirV3 (regV "ajouter") ; + Remove = dirV2 (regV "ōter") ; + Interrupt = interrompre_V2 ; + + day = UsePN ; + +} + diff --git a/old-examples/dialogue/AgendaProlog.gf b/old-examples/dialogue/AgendaProlog.gf new file mode 100644 index 000000000..0bdc4aebf --- /dev/null +++ b/old-examples/dialogue/AgendaProlog.gf @@ -0,0 +1,15 @@ +--# -path=.:prelude + +concrete AgendaProlog of Agenda = + DialogueProlog, WeekdayProlog ** open ResProlog, Prelude in { + + lin + Day = ss "day" ; + Meeting = ss "meeting" ; + Add = op2 "add_event" "event_to_store" "date_to_store" ; + Remove = op1 "remove_event" "event_to_remove" ; + Interrupt = ss "interrupt" ; + + day = apps "weekday" ; + +} diff --git a/old-examples/dialogue/AgendaSwe.gf b/old-examples/dialogue/AgendaSwe.gf new file mode 100644 index 000000000..a9331e9a0 --- /dev/null +++ b/old-examples/dialogue/AgendaSwe.gf @@ -0,0 +1,16 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete AgendaSwe of Agenda = + DialogueSwe, WeekdaySwe ** open MultiSwe, ParadigmsSwe, IrregSwe in { + + lin + Day = UseN (regN "dag") ; + Meeting = UseN (regGenN "möte" neutrum) ; + Add = dirV3 (partV lägga_V "till") (mkPrep "på") ; + Remove = dirV2 (partV taga_V "bort") ; + Interrupt = avbryta_V ; + + day = UsePN ; + +} + diff --git a/old-examples/dialogue/AuxDialogue.gf b/old-examples/dialogue/AuxDialogue.gf new file mode 100644 index 000000000..ee1313d9b --- /dev/null +++ b/old-examples/dialogue/AuxDialogue.gf @@ -0,0 +1,13 @@ +interface AuxDialogue = open Multi in { + oper + defN : N -> NP = \n -> + DetCN (DetSg (SgQuant DefArt) NoOrd) (UseN n) ; + + mkMove : Str -> Phr = \s -> {s = variants { + s ; + s ++ please_Voc.s + } ; + lock_Phr = <> + } ; + +}
\ No newline at end of file diff --git a/old-examples/dialogue/AuxEng.gf b/old-examples/dialogue/AuxEng.gf new file mode 100644 index 000000000..89f2ec57e --- /dev/null +++ b/old-examples/dialogue/AuxEng.gf @@ -0,0 +1,2 @@ +instance AuxEng of AuxDialogue = open MultiEng in { +} diff --git a/old-examples/dialogue/AuxFin.gf b/old-examples/dialogue/AuxFin.gf new file mode 100644 index 000000000..cb72b447c --- /dev/null +++ b/old-examples/dialogue/AuxFin.gf @@ -0,0 +1,2 @@ +instance AuxFin of AuxDialogue = open MultiFin in { +}
\ No newline at end of file diff --git a/old-examples/dialogue/AuxFre.gf b/old-examples/dialogue/AuxFre.gf new file mode 100644 index 000000000..b663e3650 --- /dev/null +++ b/old-examples/dialogue/AuxFre.gf @@ -0,0 +1,2 @@ +instance AuxFre of AuxDialogue = open MultiFre in { +}
\ No newline at end of file diff --git a/old-examples/dialogue/AuxSwe.gf b/old-examples/dialogue/AuxSwe.gf new file mode 100644 index 000000000..acd7907b0 --- /dev/null +++ b/old-examples/dialogue/AuxSwe.gf @@ -0,0 +1,2 @@ +instance AuxSwe of AuxDialogue = open MultiSwe in { +} diff --git a/old-examples/dialogue/Dialogue.gf b/old-examples/dialogue/Dialogue.gf new file mode 100644 index 000000000..41f805c93 --- /dev/null +++ b/old-examples/dialogue/Dialogue.gf @@ -0,0 +1,52 @@ +abstract Dialogue = { + + flags startcat=Move ; + + cat + Move ; + Action ; + Proposition ; + Question ; + Kind ; + Object Kind ; + Oper0 ; + Oper1 Kind ; + Oper2 Kind Kind ; + + fun + IRequest : Action -> Input ; + IConfirm : Action -> Input ; + IAnswer : Proposition -> Input ; + IIssue : Question -> Input ; + + IYes : Input ; + INo : Input ; + IObject : (k : Kind) -> Object k -> Input ; + + PAction : Action -> Proposition ; + + QKind : Kind -> Question ; + + AOper0 : Oper0 -> Action ; + AOper1 : (k : Kind) -> Oper1 k -> Object k -> Action ; + AOper2 : (k,m : Kind) -> Oper2 k m -> Object k -> Object m -> Action ; + + OAll : (k : Kind) -> Object k ; + OIndef : (k : Kind) -> Object k ; + ODef : (k : Kind) -> Object k ; + +-- multimodality + + cat + Click ; + Input ; -- multimodal asynchronous input + Speech ; -- speech only + fun + OThis : (k : Kind) -> Click -> Object k ; + OThisKind : (k : Kind) -> Click -> Object k ; + + MInput : Input -> Move ; + SInput : Input -> Speech ; + + MkClick : String -> Click ; +} diff --git a/old-examples/dialogue/DialogueEng.gf b/old-examples/dialogue/DialogueEng.gf new file mode 100644 index 000000000..9f75525fe --- /dev/null +++ b/old-examples/dialogue/DialogueEng.gf @@ -0,0 +1,4 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete DialogueEng of Dialogue = DialogueI with + (Multi = MultiEng) ; diff --git a/old-examples/dialogue/DialogueFin.gf b/old-examples/dialogue/DialogueFin.gf new file mode 100644 index 000000000..9ef44d02c --- /dev/null +++ b/old-examples/dialogue/DialogueFin.gf @@ -0,0 +1,4 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete DialogueFin of Dialogue = DialogueI with + (Multi = MultiFin) ; diff --git a/old-examples/dialogue/DialogueFre.gf b/old-examples/dialogue/DialogueFre.gf new file mode 100644 index 000000000..9fc908dee --- /dev/null +++ b/old-examples/dialogue/DialogueFre.gf @@ -0,0 +1,4 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete DialogueFre of Dialogue = DialogueI with + (Multi = MultiFre) ; diff --git a/old-examples/dialogue/DialogueI.gf b/old-examples/dialogue/DialogueI.gf new file mode 100644 index 000000000..7dc30a74a --- /dev/null +++ b/old-examples/dialogue/DialogueI.gf @@ -0,0 +1,98 @@ +incomplete concrete DialogueI of Dialogue = open Multi, Prelude in { + + flags optimize = all_subs ; + + lincat + Move = Phr ; + Action = {s : ActType => Str ; point : Str} ; + Proposition = Utt ; ---- + Question = Utt ; + Kind = CN ; + Object = NP ; + Oper0 = V ; + Oper1 = V2 ; + Oper2 = V3 ; + + lin + IRequest a = {s = a.s ! ARequest ; point = a.point ; lock_Utt = <>} ; + IConfirm a = {s = a.s ! AConfirm ; point = a.point ; lock_Utt = <>} ; + IAnswer a = a ; + IIssue a = a ; + + IYes = yes_Phr ** noPoint ; + INo = no_Phr ** noPoint ; + IObject _ ob = UttNP ob ; + + PAction a = {s = a.s ! AConfirm ; point = a.point ; lock_Utt = <>} ; + + QKind k = + UttQS (UseQCl TPres ASimul PPos + (ExistIP (IDetCN whichPl_IDet NoNum NoOrd k))) ; + + AOper0 op = mkAction (UseV op) ; + AOper1 _ op x = mkAction (ComplV2 op x) ; + AOper2 _ _ op x y = mkAction (ComplV3 op x y) ; + + OAll k = PredetNP all_Predet (DetCN (DetPl (PlQuant IndefArt) NoNum NoOrd) k) ; + OIndef k = DetCN (DetSg (SgQuant IndefArt) NoOrd) k ; + ODef k = DetCN (DetSg (SgQuant DefArt) NoOrd) k ; + + param + ActType = ARequest | AConfirm ; -- and some others + + oper + + -- this should perhaps be language dependent - but at least these + -- variants seem to make sense in all languages + + mkAction : VP -> {s : ActType => Str ; point : Str} = \vp -> { + s = table { + ARequest => (variants { + aImp vp ; + aWant vp ; + aCanYou vp + }).s ; + AConfirm => (variants { + aInf vp + }).s + } ; + point = vp.point + } ; + + optPlease : Voc = variants {NoVoc ; please_Voc} ; + + aImp : VP -> Utt = \vp -> + UttImpSg PPos (ImpVP vp) ; + + aWant : VP -> Utt = \vp -> + UttS (UseCl TPres ASimul PPos + (PredVP (UsePron i_Pron) (ComplVV want_VV vp))) ; + + aCanYou : VP -> Utt = \vp -> + UttQS (UseQCl TPres ASimul PPos (QuestCl + (PredVP (UsePron youSg_Pron) (ComplVV can_VV vp)))) ; + + aInf : VP -> Utt = \vp -> + UttVP vp ; + +-- multimodality + + lincat + Click = Point ; + Input = Utt ; + Speech = Multi.Speech ; + + lin + OThis k c = this8point_NP c ; + OThisKind k c = DetCN (DetSg (SgQuant (this8point_Quant c)) NoOrd) k ; + + MInput i = PhrUtt NoPConj i optPlease ; + SInput i = SpeechUtt NoPConj i optPlease ; + + MkClick = MkPoint ; + + oper + noPoint = {point = []} ; + +} + diff --git a/old-examples/dialogue/DialogueProlog.gf b/old-examples/dialogue/DialogueProlog.gf new file mode 100644 index 000000000..6398ee6f3 --- /dev/null +++ b/old-examples/dialogue/DialogueProlog.gf @@ -0,0 +1,42 @@ +--# -path=.:prelude + +concrete DialogueProlog of Dialogue = open ResProlog, Prelude in { + + flags lexer=codelit ; unlexer=code ; + + lincat + Move = SS ; + Action = SS ; + Proposition = SS ; + Question = SS ; + Kind = SS ; + Object = SS ; + Oper0 = SS ; + Oper1 = {s, x : Str} ; + Oper2 = {s, x, y : Str} ; + + lin + MRequest a = a ; + MConfirm a = a ; --- ?? + MAnswer a = a ; --- ?? + MIssue a = ss (bracket (app1 "ask" a.s)) ; --- ?? + + MYes = ss (bracket (app1 "answer" "yes")) ; + MNo = ss (bracket (app1 "answer" "no")) ; + MObject _ ob = ss (bracket (apps "answer" ob).s) ; + + QKind k = ss (app2 "q" "X" (app1 k.s "X")) ; + + AOper0 op = ss (bracket (request op.s)) ; + AOper1 _ op x = ss (req_ans op.s op.x x.s) ; + AOper2 _ _ op x y = + ss (bracket (request op.s ++ "," ++ + answer (app1 op.x x.s) ++ "," ++ answer (app1 op.y y.s))) ; + + OAll = apps "all" ; + OIndef = apps "indef" ; + ODef = apps "def" ; + + +} + diff --git a/old-examples/dialogue/DialogueSwe.gf b/old-examples/dialogue/DialogueSwe.gf new file mode 100644 index 000000000..b23d761bc --- /dev/null +++ b/old-examples/dialogue/DialogueSwe.gf @@ -0,0 +1,4 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete DialogueSwe of Dialogue = DialogueI with + (Multi = MultiSwe) ; diff --git a/old-examples/dialogue/Lights.gf b/old-examples/dialogue/Lights.gf new file mode 100644 index 000000000..ef0f48449 --- /dev/null +++ b/old-examples/dialogue/Lights.gf @@ -0,0 +1,16 @@ +abstract Lights = Dialogue ** { + + fun + Light : Kind ; + Room : Kind ; + SwitchOnIn : Oper2 Light Room ; + SwitchOffIn : Oper2 Light Room ; + SwitchOn : Oper1 Light ; + SwitchOff : Oper1 Light ; + + LivingRoom : Object Room ; + Kitchen : Object Room ; + + MorningMode : Move ; + +} diff --git a/old-examples/dialogue/LightsEng.gf b/old-examples/dialogue/LightsEng.gf new file mode 100644 index 000000000..dfed6de85 --- /dev/null +++ b/old-examples/dialogue/LightsEng.gf @@ -0,0 +1,19 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete LightsEng of Lights = + DialogueEng ** open MultiEng, ParadigmsEng, AuxEng, Prelude in { + + lin + Light = UseN (regN "light") ; + Room = UseN (regN "room") ; + SwitchOnIn = dirV3 (partV (regV "switch") "on") (mkPrep "in") ; + SwitchOffIn = dirV3 (partV (regV "switch") "off") (mkPrep "in") ; + SwitchOn = dirV2 (partV (regV "switch") "on") ; + SwitchOff = dirV2 (partV (regV "switch") "off") ; + + LivingRoom = defN (regN ["living-room"]) ; + Kitchen = defN (regN ["kitchen"]) ; + + MorningMode = mkMove (optStr "the" ++ ["morning mode"]) ; + +} diff --git a/old-examples/dialogue/LightsFin.gf b/old-examples/dialogue/LightsFin.gf new file mode 100644 index 000000000..75c46ff49 --- /dev/null +++ b/old-examples/dialogue/LightsFin.gf @@ -0,0 +1,19 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete LightsFin of Lights = + DialogueFin ** open MultiFin, ParadigmsFin, AuxFin in { + + lin + Light = UseN (regN "valo") ; + Room = UseN (regN "huone") ; + SwitchOnIn = dirV3 (regV "sytyttää") inessive ; + SwitchOffIn = dirV3 (regV "sammuttaa") inessive ; + SwitchOn = dirV2 (regV "sytyttää") ; + SwitchOff = dirV2 (regV "sammuttaa") ; + + LivingRoom = defN (regN "olohuone") ; + Kitchen = defN (regN "keittiö") ; + + MorningMode = mkMove ["aamuvalaistus"] ; + +} diff --git a/old-examples/dialogue/LightsFre.gf b/old-examples/dialogue/LightsFre.gf new file mode 100644 index 000000000..77316e5a1 --- /dev/null +++ b/old-examples/dialogue/LightsFre.gf @@ -0,0 +1,19 @@ +--# -path=.:multimodal:alltenses:prelude + +concrete LightsFre of Lights = + DialogueFre ** open MultiFre, ParadigmsFre, IrregFre, AuxFre in { + + lin + Light = UseN (regN "lampe") ; + Room = UseN (regN "chambre") ; + SwitchOnIn = dirV3 (regV "allumer") (mkPrep "dans") ; + SwitchOffIn = dirV3 éteindre_V2 (mkPrep "dans") ; + SwitchOn = dirV2 (regV "allumer") ; + SwitchOff = dirV2 éteindre_V2 ; + + LivingRoom = defN (regN "salon") ; + Kitchen = defN (regN "cuisine") ; + + MorningMode = mkMove ["le mode matinal"] ; + +} diff --git a/old-examples/dialogue/LightsProlog.gf b/old-examples/dialogue/LightsProlog.gf new file mode 100644 index 000000000..42b4b3e2b --- /dev/null +++ b/old-examples/dialogue/LightsProlog.gf @@ -0,0 +1,20 @@ +--# -path=.:prelude + +concrete LightsProlog of Lights = + DialogueProlog ** open ResProlog, Prelude in { + + lin + Light = ss "light" ; + Room = ss "room" ; + SwitchOnIn = op2 "switch_on" "switch_what" "switch_where" ; + SwitchOffIn = op2 "switch_off" "switch_what" "switch_where" ; + SwitchOn = op1 "switch_on" "switch_what" ; + SwitchOff = op1 "switch_off" "switch_what" ; + + LivingRoom = ss "living_room" ; + Kitchen = ss "kitchen" ; + + MorningMode = ss (bracket (app1 "answer" "morning_mode")) ; + +} + diff --git a/old-examples/dialogue/LightsSwe.gf b/old-examples/dialogue/LightsSwe.gf new file mode 100644 index 000000000..19f0d8964 --- /dev/null +++ b/old-examples/dialogue/LightsSwe.gf @@ -0,0 +1,20 @@ +--# -path=.:multimodal:alltenses:prelude + + +concrete LightsSwe of Lights = + DialogueSwe ** open MultiSwe, ParadigmsSwe, AuxSwe in { + + lin + Light = UseN (regN "lampa") ; + Room = UseN (mkN "rum" "rummet" "rum" "rummen") ; + SwitchOnIn = dirV3 (regV "tänder") (mkPrep "i") ; + SwitchOffIn = dirV3 (regV "släcker") (mkPrep "i") ; + SwitchOn = dirV2 (regV "tänder") ; + SwitchOff = dirV2 (regV "släcker") ; + + LivingRoom = defN (mkN "vardagsrum" "vardagsrummet" "vardagsrum" "vardagsrummen") ; + Kitchen = defN (mk2N "kök" "kök") ; + + MorningMode = mkMove ["morgonläget"] ; + +} diff --git a/old-examples/dialogue/Makefile b/old-examples/dialogue/Makefile new file mode 100644 index 000000000..475736740 --- /dev/null +++ b/old-examples/dialogue/Makefile @@ -0,0 +1,14 @@ +lights: + echo "s ;; pm | wf lights.gfcm" | gf Lights*.gf + +agenda: + echo "s ;; pm | wf agenda.gfcm" | gf Agenda*.gf + +engcorpus: + echo "gt -depth=4 | pt -transform=typecheck | l -all" | gf LightsEng.gf + +swecorpus: + echo "gt -depth=4 | pt -transform=typecheck | l -all" | gf LightsSwe.gf + +doc: + txt2tags -thtml -ogf-dialogue.html README.txt diff --git a/old-examples/dialogue/README.txt b/old-examples/dialogue/README.txt new file mode 100644 index 000000000..db14dad96 --- /dev/null +++ b/old-examples/dialogue/README.txt @@ -0,0 +1,99 @@ +Dialogue system grammars using GF resource. + +AR 16/5/2006 + + +24/5 Added multimodality. + +==Functionality and purpose== + +Dialogue system abstract syntax + concrete syntaxes for +different languages. One of them is Prolog (with some resemblance to +dialogue moves in GoDiS). + +The purpose is to show how new systems can be built for new domains just +by specifying just two things: +- a domain ontology in abstract syntax +- a domain terminologies in concrete syntaxes + + +This is based on two library elements +- base dialogue grammars +- resource grammar libraries + + +In general, the only kind of elements that need to be added are +constants (0-place fun's) of the following categories from Dialogue.gf. +``` + Kind ; -- e.g. Room + Object Kind ; -- e.g. Kitchen + Oper0 ; -- e.g. Stop + Oper1 Kind ; -- e.g. Play + Oper2 Kind Kind ; -- e.g. Add + Move ; -- e.g. MorningMode +``` + + +==Files in this directory== + +Files (for X = Eng, Fin, Fre, Prolog, Swe): + +Files provided as library to build on: +``` + Dialogue.gf -- base dialogue grammar + DialogueX.gf -- implementation instance + DialogueI.gf -- implementation functor + + ResProlog.gf -- help constructs for Prolog terms + + Weekday.gf -- untility grammar with weekdays + WeekdayX.gf + + AuxDialogue.gf-- interface of auxiliary resource-defined opers + AuxX.gf -- instances for different languages +``` +Files implementing two examples. +``` + Agenda.gf -- application grammar for agenda + AgendaX.gf + + Lights.gf -- application grammar for lights + Lights.gf +``` + +==Files needed to build a new application== + +To build a new application for domain Dom, you thus need +``` + Dom.gf -- introduce fun's in Kind, Object, Oper0, Oper1, Oper2 + DomX.gf -- concrete syntax of the new fun's for language X +``` + +==Some tests== + +You first need to do, with the latest resource grammar version, +- ``make present`` in ``lib/resource-1.0`` + +To test an application in GF, do e.g. +- ``make lights`` to make a package with all the Lights grammars +- ``make engcorpus`` to generate an English corpus +- ``make swecorpus`` to generate a Swedish corpus + + + +Here are some other commands: +- ``i LightsEng.gf`` in current dir, to load a grammar +- ``gr | l -all`` to random-generate +- ``gt -depth=4 | pt -transform=typecheck | l -all`` to generate a corpus +- ``p "switch off all lights in the kitchen"`` to parse +- ``i LightsProlog.gf`` to load the Prolog version +- ``pg -printer=gsl -startcat=Move`` to print a Nuance grammar +- ``p -lang=LightsEng "switch off all lights" | pt -transform=solve | l -lang=LightsProlog`` +to translate from English to Prolog +- ``si -tr -lang=LightsEng | p -cat=Move -lang=LightsEng | pt -transform=solve | l -lang=LightsProlog`` +to translate English speech into Prolog + + +The last one is the coolest - but you may need to enable the ``speech_input`` command by installing ATK +and recompiling GF. + diff --git a/old-examples/dialogue/ResProlog.gf b/old-examples/dialogue/ResProlog.gf new file mode 100644 index 000000000..ce3bbce4b --- /dev/null +++ b/old-examples/dialogue/ResProlog.gf @@ -0,0 +1,22 @@ +resource ResProlog = open Prelude in { + + oper + bracket : Str -> Str = \s -> "[" ++ s ++ "]" ; + + app1 : Str -> Str -> Str = \f,x -> f ++ paren x ; + app2 : Str -> Str -> Str -> Str = \f,x,y -> f ++ paren (x ++ "," ++ y) ; + + apps : Str -> SS -> SS = \f,x -> ss (app1 f x.s) ; + + op1 : (s,x : Str) -> {s,x : Str} = \s,x -> {s = s ; x = x} ; + op2 : (s,x,y : Str) -> {s,x,y : Str} = \s,x,y -> {s = s ; x = x ; y = y} ; + + request : Str -> Str = app1 "request" ; + answer : Str -> Str = app1 "answer" ; + + req_ans : Str -> Str -> Str -> Str = \f,t,k -> + bracket (request f ++ "," ++ answer (app1 t k)) ; + +} + +-- [request(add_event), answer(event_to_store(meeting))] diff --git a/old-examples/dialogue/Weekday.gf b/old-examples/dialogue/Weekday.gf new file mode 100644 index 000000000..8ef2e8c99 --- /dev/null +++ b/old-examples/dialogue/Weekday.gf @@ -0,0 +1,8 @@ +abstract Weekday = { + cat + WDay ; + + fun + Mon, Tue : WDay ; + +} diff --git a/old-examples/dialogue/WeekdayEng.gf b/old-examples/dialogue/WeekdayEng.gf new file mode 100644 index 000000000..7d296af9a --- /dev/null +++ b/old-examples/dialogue/WeekdayEng.gf @@ -0,0 +1,10 @@ +concrete WeekdayEng of Weekday = open LangEng, ParadigmsEng in { + + lincat + WDay = PN ; + + lin + Mon = regGenPN "Monday" nonhuman ; + Tue = regGenPN "Tuesday" nonhuman ; + +} diff --git a/old-examples/dialogue/WeekdayFin.gf b/old-examples/dialogue/WeekdayFin.gf new file mode 100644 index 000000000..b150c2872 --- /dev/null +++ b/old-examples/dialogue/WeekdayFin.gf @@ -0,0 +1,10 @@ +concrete WeekdayFin of Weekday = open LangFin, ParadigmsFin in { + + lincat + WDay = PN ; + + lin + Mon = mkPN (regN "maanantai") ; + Tue = mkPN (regN "tiistai") ; + +} diff --git a/old-examples/dialogue/WeekdayFre.gf b/old-examples/dialogue/WeekdayFre.gf new file mode 100644 index 000000000..d0c6e141a --- /dev/null +++ b/old-examples/dialogue/WeekdayFre.gf @@ -0,0 +1,10 @@ +concrete WeekdayFre of Weekday = open LangFre, ParadigmsFre in { + + lincat + WDay = PN ; + + lin + Mon = mkPN "lundi" masculine ; + Tue = mkPN "mardi" masculine ; + +} diff --git a/old-examples/dialogue/WeekdayProlog.gf b/old-examples/dialogue/WeekdayProlog.gf new file mode 100644 index 000000000..384484cce --- /dev/null +++ b/old-examples/dialogue/WeekdayProlog.gf @@ -0,0 +1,10 @@ +concrete WeekdayProlog of Weekday = open ResProlog, Prelude in { + + lincat + WDay = SS ; + + lin + Mon = ss "monday" ; + Tue = ss "tuesday" ; + +} diff --git a/old-examples/dialogue/WeekdaySwe.gf b/old-examples/dialogue/WeekdaySwe.gf new file mode 100644 index 000000000..2cd55c522 --- /dev/null +++ b/old-examples/dialogue/WeekdaySwe.gf @@ -0,0 +1,10 @@ +concrete WeekdaySwe of Weekday = open LangSwe, ParadigmsSwe in { + + lincat + WDay = PN ; + + lin + Mon = regGenPN "mĆ„ndag" utrum ; + Tue = regGenPN "tisdag" utrum ; + +} diff --git a/old-examples/dialogue/gf-dialogue.html b/old-examples/dialogue/gf-dialogue.html new file mode 100644 index 000000000..19b5317a0 --- /dev/null +++ b/old-examples/dialogue/gf-dialogue.html @@ -0,0 +1,124 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> +<META NAME="generator" CONTENT="http://txt2tags.sf.net"> +<TITLE>Dialogue system grammars using GF resource.</TITLE> +</HEAD><BODY BGCOLOR="white" TEXT="black"> +<P ALIGN="center"><CENTER><H1>Dialogue system grammars using GF resource.</H1> +<FONT SIZE="4"> +AR 16/5/2006 +</FONT></CENTER> + +<H2>Functionality and purpose</H2> +<P> +Dialogue system abstract syntax + concrete syntaxes for +different languages. One of them is Prolog (with some resemblance to +dialogue moves in GoDiS). +</P> +<P> +The purpose is to show how new systems can be built for new domains just +by specifying just two things: +</P> +<UL> +<LI>a domain ontology in abstract syntax +<LI>a domain terminologies in concrete syntaxes +</UL> + +<P> +This is based on two library elements +</P> +<UL> +<LI>base dialogue grammars +<LI>resource grammar libraries +</UL> + +<P> +In general, the only kind of elements that need to be added are +constants (0-place fun's) of the following categories from Dialogue.gf. +</P> +<PRE> + Kind ; -- e.g. Room + Object Kind ; -- e.g. Kitchen + Oper0 ; -- e.g. Stop + Oper1 Kind ; -- e.g. Play + Oper2 Kind Kind ; -- e.g. Add + Move ; -- e.g. MorningMode +</PRE> +<P></P> +<H2>Files in this directory</H2> +<P> +Files (for X = Eng, Fin, Fre, Prolog, Swe): +</P> +<P> +Files provided as library to build on: +</P> +<PRE> + Dialogue.gf -- base dialogue grammar + DialogueX.gf -- implementation instance + DialogueI.gf -- implementation functor + + ResProlog.gf -- help constructs for Prolog terms + + Weekday.gf -- untility grammar with weekdays + WeekdayX.gf + + AuxDialogue.gf-- interface of auxiliary resource-defined opers + AuxX.gf -- instances for different languages +</PRE> +<P> +Files implementing two examples. +</P> +<PRE> + Agenda.gf -- application grammar for agenda + AgendaX.gf + + Lights.gf -- application grammar for lights + Lights.gf +</PRE> +<P></P> +<H2>Files needed to build a new application</H2> +<P> +To build a new application for domain Dom, you thus need +</P> +<PRE> + Dom.gf -- introduce fun's in Kind, Object, Oper0, Oper1, Oper2 + DomX.gf -- concrete syntax of the new fun's for language X +</PRE> +<P></P> +<H2>Some tests</H2> +<P> +You first need to do, with the latest resource grammar version, +</P> +<UL> +<LI><CODE>make present</CODE> in <CODE>lib/resource-1.0</CODE> +<P></P> +To test an application in GF, do e.g. +<LI><CODE>make lights</CODE> to make a package with all the Lights grammars +<LI><CODE>make engcorpus</CODE> to generate an English corpus +<LI><CODE>make swecorpus</CODE> to generate a Swedish corpus +</UL> + +<P> +Here are some other commands: +</P> +<UL> +<LI><CODE>i LightsEng.gf</CODE> in current dir, to load a grammar +<LI><CODE>gr | l -all</CODE> to random-generate +<LI><CODE>gt -depth=4 | pt -transform=typecheck | l -all</CODE> to generate a corpus +<LI><CODE>p "switch off all lights in the kitchen"</CODE> to parse +<LI><CODE>i LightsProlog.gf</CODE> to load the Prolog version +<LI><CODE>pg -printer=gsl -startcat=Move</CODE> to print a Nuance grammar +<LI><CODE>p -lang=LightsEng "switch off all lights" | pt -transform=solve | l -lang=LightsProlog</CODE> +to translate from English to Prolog +<LI><CODE>si -tr -lang=LightsEng | p -cat=Move -lang=LightsEng | pt -transform=solve | l -lang=LightsProlog</CODE> +to translate English speech into Prolog +</UL> + +<P> +The last one is the coolest - but you may need to enable the <CODE>speech_input</CODE> command by installing ATK +and recompiling GF. +</P> + +<!-- html code generated by txt2tags 2.3 (http://txt2tags.sf.net) --> +<!-- cmdline: txt2tags -thtml -ogf-dialogue.html README.txt --> +</BODY></HTML> |
