Skip to content
evankrause edited this page Apr 23, 2024 · 7 revisions

Parser

Our most commonly used parser is the TLDL Parser Component, which uses lambda calculus to assemble a semantic representation of an input utterance based on a dictionary specified in the loaded dictionary file:

createInstance(edu.tufts.hrilab.slug.parsing.TLDL.TLDLParserComponentImpl.class, "-dict robotLanguage.dict");

Replace robotLanguage.dict with whatever dictionary you decide to use. The recommended all-purpose dictionary is templatedict.dict, which contains dictionary entries for most demos in the lab. If you edit this template, please ensure the demo language is still parseable.

The dictionary contains entries for words or phrases with their associated syntax, semantics, and any supplemental information:

bake; C/REF; #x.bake(?ADDRESSEE,$x)
the; REF/RN; #x.$x; DEFINITE
cake; RN; cake; VAR

The parser’s goal, when parsing a sentence like "bake the cake" is to identify a series of dictionary entries that can “combine” with each other successfully, resulting in a syntactic "terminal category" for the overall sentence, and a semantic term with all variables filled in. Terminal categories for a sentence include C (command), S (statement), G (greeting), ACK (acknowledgment), QYN (yes or no question), or QWH (who/what/when/where/why/how question).

The dictionary entries for "the" and "cake" can combine because their syntax entries match: "the" has a syntactic type of REF/RN, which means that the overall type is REF once it finds an argument of type RN. $x is substituted in the lambda expression with the semantics of the argument when the entries are combined.

the cake; REF; cake; DEFINITE,VAR

Similarly, "bake" has a syntactic type of C/REF, which means that it can combine with a following phrase with a syntactic type of REF, so "bake" and "the cake" can combine to result in the overall terminal category C. ?ADDRESSEE is filled in with whatever agent was last spoken to, and because "cake" was also identified as a DEFINITE VAR in its entry, it is replaced by a variable in the final semantics.

bake the cake; C; bake(self,VAR0)

This information is packed into an Utterance, which also includes information about variable VAR0 (such that it has the property "cake") that can be used to ground it to a reference when the utterance is sent to Reference Resolution later on in the natural language process.

You can use templates for frequently used dictionary entry constructions as shown in the tutorial dictionary below. For example, since VERBT is a template with the same construction that decided on for "bake" above, you could simply define "bake" like this:

bake; VERBT

Tutorial

Try adding new dictionary entries to the sample robotLanguage.dict file seen here:

START-TEMPLATES

%nouns
THING;{RN; ph ; VAR}, {DN; ph}
%intransitive verb
VERBI; {C\AGENT ; #x.ph()}, {C ; ph()}
%transitive verb
VERBT; {(C/REF)\AGENT ; #x#y.ph($y)}, {C/REF ; #x.ph($x)}, {((C/ARM)/REF)\AGENT ; #x#y#a.ph($y,$a)}, {(C/ARM)/REF ; #x#a.ph($x,$a)}
%ditransitive verb with agent arguments
VERBDTA; {((C/AGENT)/AGENT)\AGENT ; #x#y#z.ph($y,$z)}, {(C/AGENT)/AGENT ; #x#y.ph($x,$y)}
%transitive verb with direction argument
%also supports a distance in the given direction
VERBTD; {((C/VAL)/DIR)\AGENT; #a#x#y.ph($x,$y)}, {(C/VAL)/DIR ; #x#y.ph($x,$y)}, {(C/DIR)\AGENT ; #x#y.ph($y)}, {C/DIR ; #x.ph($x)}
%ditransitive verb
VERBDT; {((C/REF)/AGENT)\AGENT ; #x#y#z.ph($y,$z)}, {((S/PP)/REF)\AGENT ; #x#y#z.ph($y,$z)}, {(C/REF)/AGENT ; #x#y.ph($x,$y)}
%addressing actors by name
ADDRESSABLE; {G/G, S/S, C/C, QYN/QYN, QWH/QWH, G\G, S\S, C\C, QYN\QYN, QWH\QWH; #x.directAddress(ph,$x)}, {AGENT ; ph}

END-TEMPLATES

%%%%

arm; N ; arm
arms; N ; arms

crouch down; VERBI ; crouchDown
stand up; VERBI ; standUp
stand; VERBI ; stand

please; C / C, C \ C, Pron \ Pron, S \ S ; #x. $x
hello; G ; hello

raise; C / NP[your]; #x. raise($x)
relax ; VERBI; rest

right; DIR; right
right; N/N ; #x.right$x

robot one; ADDRESSABLE; robotone

turn; VERBTD ; turn

your; NP[your] / N ; # x. $x

Clone this wiki locally