diff --git a/examples/dialogue/AuxDialogue.gf b/examples/dialogue/AuxDialogue.gf new file mode 100644 index 000000000..63b9c6979 --- /dev/null +++ b/examples/dialogue/AuxDialogue.gf @@ -0,0 +1,13 @@ +interface AuxDialogue = open Lang 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/examples/dialogue/AuxEng.gf b/examples/dialogue/AuxEng.gf new file mode 100644 index 000000000..9c4ac8f37 --- /dev/null +++ b/examples/dialogue/AuxEng.gf @@ -0,0 +1,2 @@ +instance AuxEng of AuxDialogue = open LangEng in { +} \ No newline at end of file diff --git a/examples/dialogue/AuxFin.gf b/examples/dialogue/AuxFin.gf new file mode 100644 index 000000000..c3e321b31 --- /dev/null +++ b/examples/dialogue/AuxFin.gf @@ -0,0 +1,2 @@ +instance AuxFin of AuxDialogue = open LangFin in { +} \ No newline at end of file diff --git a/examples/dialogue/AuxFre.gf b/examples/dialogue/AuxFre.gf new file mode 100644 index 000000000..178a60f25 --- /dev/null +++ b/examples/dialogue/AuxFre.gf @@ -0,0 +1,2 @@ +instance AuxFre of AuxDialogue = open LangFre in { +} \ No newline at end of file diff --git a/examples/dialogue/AuxSwe.gf b/examples/dialogue/AuxSwe.gf new file mode 100644 index 000000000..be3e1a117 --- /dev/null +++ b/examples/dialogue/AuxSwe.gf @@ -0,0 +1,2 @@ +instance AuxSwe of AuxDialogue = open LangSwe in { +} \ No newline at end of file diff --git a/examples/dialogue/Dialogue.gf b/examples/dialogue/Dialogue.gf index ccb410d15..13c674731 100644 --- a/examples/dialogue/Dialogue.gf +++ b/examples/dialogue/Dialogue.gf @@ -1,5 +1,7 @@ abstract Dialogue = { + flags startcat=Move ; + cat Move ; Action ; diff --git a/examples/dialogue/Lights.gf b/examples/dialogue/Lights.gf new file mode 100644 index 000000000..ef0f48449 --- /dev/null +++ b/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/examples/dialogue/LightsEng.gf b/examples/dialogue/LightsEng.gf new file mode 100644 index 000000000..eceaa487d --- /dev/null +++ b/examples/dialogue/LightsEng.gf @@ -0,0 +1,19 @@ +--# -path=.:present:prelude + +concrete LightsEng of Lights = + DialogueEng ** open LangEng, ParadigmsEng, AuxEng, Prelude in { + + lin + Light = UseN (regN "light") ; + Room = UseN (regN "room") ; + SwitchOnIn = dirV3 (partV (regV "switch") "on") (mkPreposition "in") ; + SwitchOffIn = dirV3 (partV (regV "switch") "off") (mkPreposition "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/examples/dialogue/LightsFin.gf b/examples/dialogue/LightsFin.gf new file mode 100644 index 000000000..5e51e0951 --- /dev/null +++ b/examples/dialogue/LightsFin.gf @@ -0,0 +1,19 @@ +--# -path=.:present:prelude + +concrete LightsFin of Lights = + DialogueFin ** open LangFin, 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/examples/dialogue/LightsFre.gf b/examples/dialogue/LightsFre.gf new file mode 100644 index 000000000..50f959d0e --- /dev/null +++ b/examples/dialogue/LightsFre.gf @@ -0,0 +1,19 @@ +--# -path=.:present:prelude + +concrete LightsFre of Lights = + DialogueFre ** open LangFre, ParadigmsFre, IrregFre, AuxFre in { + + lin + Light = UseN (regN "lampe") ; + Room = UseN (regN "chambre") ; + SwitchOnIn = dirV3 (regV "allumer") (mkPreposition "dans") ; + SwitchOffIn = dirV3 éteindre_V2 (mkPreposition "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/examples/dialogue/LightsProlog.gf b/examples/dialogue/LightsProlog.gf new file mode 100644 index 000000000..4a93ee469 --- /dev/null +++ b/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 = ss "switch_on" ; + SwitchOffIn = ss "switch_off" ; + SwitchOn = ss "switch_on" ; + SwitchOff = ss "switch_off" ; + + LivingRoom = ss "living_room" ; + Kitchen = ss "kitchen" ; + + MorningMode = ss "morning_mode" ; + +} + diff --git a/examples/dialogue/LightsSwe.gf b/examples/dialogue/LightsSwe.gf new file mode 100644 index 000000000..695c3aa41 --- /dev/null +++ b/examples/dialogue/LightsSwe.gf @@ -0,0 +1,19 @@ +--# -path=.:present:prelude + +concrete LightsSwe of Lights = + DialogueSwe ** open LangSwe, ParadigmsSwe, AuxSwe in { + + lin + Light = UseN (regN "lampa") ; + Room = UseN (mkN "rum" "rummet" "rum" "rummen") ; + SwitchOnIn = dirV3 (regV "tänder") (mkPreposition "i") ; + SwitchOffIn = dirV3 (regV "släcker") (mkPreposition "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/examples/dialogue/Makefile b/examples/dialogue/Makefile new file mode 100644 index 000000000..99d8d0895 --- /dev/null +++ b/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 README.txt diff --git a/examples/dialogue/README b/examples/dialogue/README deleted file mode 100644 index 4bcba889c..000000000 --- a/examples/dialogue/README +++ /dev/null @@ -1,34 +0,0 @@ -Dialogue system grammar examples. - -AR 16/5/2006 - -Files (for X = Eng, Fin, Fre, Prolog, Swe): - - 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 - - Agenda.gf -- application grammar for agenda - AgendaX.gf - -To build a new application for domain Dom, you need - - Dom.gf -- introduce fun's in Kind, Object, Oper0, Oper1, Oper2 - DomX.gf -- concrete syntax of the new fun's for language X - - -To test: - - - 'make present' in lib/resource-1.0 - - 'gf AgendaEng.gf' in current dir, followed by 'gr -cat=Move | l -all' - - or the same thing with other languages - - for Nuance grammar, do 'pg -printer=gsl -startcat=Move' - - to generate a corpus, do 'gt -cat=Move -depth=4 | pt -transform=typecheck | l -all' - - - diff --git a/examples/dialogue/README.html b/examples/dialogue/README.html new file mode 100644 index 000000000..a273e28b9 --- /dev/null +++ b/examples/dialogue/README.html @@ -0,0 +1,124 @@ + + +
+ ++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: +
++This is based on two library elements +
++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 (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 ++ +
+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 ++ +
+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.
+