extended dialogue example

This commit is contained in:
aarne
2006-05-16 20:44:33 +00:00
parent 5082ebd0f4
commit 29d04d8a90
16 changed files with 369 additions and 34 deletions

View File

@@ -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 = <>
} ;
}

View File

@@ -0,0 +1,2 @@
instance AuxEng of AuxDialogue = open LangEng in {
}

View File

@@ -0,0 +1,2 @@
instance AuxFin of AuxDialogue = open LangFin in {
}

View File

@@ -0,0 +1,2 @@
instance AuxFre of AuxDialogue = open LangFre in {
}

View File

@@ -0,0 +1,2 @@
instance AuxSwe of AuxDialogue = open LangSwe in {
}

View File

@@ -1,5 +1,7 @@
abstract Dialogue = {
flags startcat=Move ;
cat
Move ;
Action ;

View File

@@ -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 ;
}

View File

@@ -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"]) ;
}

View File

@@ -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"] ;
}

View File

@@ -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"] ;
}

View File

@@ -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" ;
}

View File

@@ -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"] ;
}

View File

@@ -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

View File

@@ -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'

View File

@@ -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>

View File

@@ -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.