diff options
| -rw-r--r-- | examples/dialogue/AuxDialogue.gf | 13 | ||||
| -rw-r--r-- | examples/dialogue/AuxEng.gf | 2 | ||||
| -rw-r--r-- | examples/dialogue/AuxFin.gf | 2 | ||||
| -rw-r--r-- | examples/dialogue/AuxFre.gf | 2 | ||||
| -rw-r--r-- | examples/dialogue/AuxSwe.gf | 2 | ||||
| -rw-r--r-- | examples/dialogue/Dialogue.gf | 2 | ||||
| -rw-r--r-- | examples/dialogue/Lights.gf | 16 | ||||
| -rw-r--r-- | examples/dialogue/LightsEng.gf | 19 | ||||
| -rw-r--r-- | examples/dialogue/LightsFin.gf | 19 | ||||
| -rw-r--r-- | examples/dialogue/LightsFre.gf | 19 | ||||
| -rw-r--r-- | examples/dialogue/LightsProlog.gf | 20 | ||||
| -rw-r--r-- | examples/dialogue/LightsSwe.gf | 19 | ||||
| -rw-r--r-- | examples/dialogue/Makefile | 14 | ||||
| -rw-r--r-- | examples/dialogue/README | 34 | ||||
| -rw-r--r-- | examples/dialogue/README.html | 124 | ||||
| -rw-r--r-- | examples/dialogue/README.txt | 96 |
16 files changed, 369 insertions, 34 deletions
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 @@ +<!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 README.txt --> +</BODY></HTML> diff --git a/examples/dialogue/README.txt b/examples/dialogue/README.txt new file mode 100644 index 000000000..68ec539a9 --- /dev/null +++ b/examples/dialogue/README.txt @@ -0,0 +1,96 @@ +Dialogue system grammars using GF resource. + +AR 16/5/2006 + +==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. + |
