more dragonfly

where can i provide feedback for dragonfly.

need more documentation (examples most useful):
DictListRef - how do you use it and when would you use it

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Dictionary List Reference objects

Hi Firegift,

The DictListRef class you ask about is a grammar element which references a dictionary-list. I'll start off explaining what a dictionary-list is, and then what referencing one means.

DNS and WSR both implement this "list" concept, which basically boils down to a dynamic grammar element within a rule. You know how most of the voice-command grammar must be predefined and loaded into the SR engine, after which it cannot be changed anymore? Well, the "list" is the exception to this rule: its elements can be changed without requiring the grammar to be unloaded and reloaded. Such a "list" simply consists of zero or more elements. Elements can be added and removed.

As far as the SR engine is concerned, these lists contain spoken-forms: the words the user can speak. But, when you're writing a speech-driven application, you're generally not so interested in the spoken-form; instead you'd like to know the "semantic value" associated with those words. This is where the "dictionary" part comes in. Dragonfly's dictionary-list DictList implement such a mapping: its keys are the spoken-forms and their associated values are, ..., well, whatever you'd like them to be, that's up to you the application developer. These dictionary-list objects are simply derived from Python's built-in dict type, so they behave in exactly the same way.

So, the DictList objects contained a mapping of spoken-forms to semantic-values. If you'd like to use such a dictionary-list in a voice-command, simply add a reference to it to the voice-command's definition. In other words, all you have to do is add a DictListRef element to that particular Rule.

There are many examples of how to use these objects in the Dragonfly command-modules repository. (These are slightly involved, since they are real-world applications). An example is the "command memory" module available here:

http://code.google.com/p/dragonfly-modules/source/...

It allows you to say, amongst other things, the following:
"remember last 4 command as |my special command|"
to store the last 4 recognitions as "my special command". It is then possible to say:
"|my special command| 2 times"
to replay the stored recognitions twice. Extremely useful for automating those annoying repetitive tasks. Smiling

The command memory module creates a dictionary-list at line 73, together with a reference to it. This reference is inserted into the main rule further down at line 138 (see line 64 for the default spoken-form of that rule, including the "memory" extra element). Now when the user gives the command to replay a stored memory, you can see how easy the given memory is retrieved at line 118. Standard Python dictionary lookup. And that's all there is to it. Now, if you'd remove the user-configurable spoken-forms, etc., you'd end up with an almost trivial example of how to use these dictionary-lists.

Please let me know if you have any more questions or have any trouble getting this to work for yourself. I'll be happy to help.

-- Christo.

From the _cmdMemory code, it

From the _cmdMemory code, it looks like DictListRef is just a wrapper for DictList that it is dynamic. I think that what it does.

Another question, how can I use a list as extra.

spec = ""

extra= ListRef("kind",["quote","score","class","java"]),
Dictation("words")

i want kind to be a those words for kind. i can't get this to work. not exactly sure how to use this.

it might be good to have a simple examples page

I'm thinking a "getting started" type page that show a few VERY simple examples.

For a list we'd want to know how to use written/spoken forms.

Something like:
"Type folder " which would type the folder name from a list.

program files = "c:\program files"
my documents = "C:\Documents and Settings\Administrator\My Document"

It doesn't have to be a fully-functional, real-world example, the key is to make it as short and simple as possible. If you wanted a little fancier, you could make a "go folder " command for explorer that would go to the address bar and type the folder name.

For a simple example, the folder names should just be hard coded.

My two cents,

Derek
p.s. if there is a simple place you could point us to for this type of example, it would be greatly appreciated

getting stated page is a

getting stated page is a good idea

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Syndicate content