Labs/Ubiquity/Ubiquity Source Tip Author Tutorial: Difference between revisions

Jump to navigation Jump to search
Line 304: Line 304:
This says that the command "echo" takes one argument which is arbitrary text. Whatever text the user enters will get wrapped in an input object and passed into both the preview and execute function.
This says that the command "echo" takes one argument which is arbitrary text. Whatever text the user enters will get wrapped in an input object and passed into both the preview and execute function.


Ubiquity takes care of parsing the user's input, so you don't need to worry about handling prounoun substitution or any of the other natural-language-like features of the Ubiquity parser. Try selecting some text on a page, and Ubiq "echo this". Ubiquity should now echo the selected text.
Try it!  Ubiq "echo hellooooo" and watch what happens.


=== How Arguments are Defined ===
Ubiquity takes care of parsing the user's input, so you don't need to worry about handling prounoun substitution or any of the other natural-language-like features of the Ubiquity parser. Try selecting some text on a page, and Ubiq "echo this". Ubiquity should now echo the selected text. 
 
Note that we gave three pieces of information when defining our argument:  its role, its nountype, and its label.  We'll cover each of these in detail next.
 
=== Argument Roles ===


Your command can take multiple arguments.  Each one is identified by a "role".  To understand roles, it helps to think of your command name as a verb, and each argument as a noun.  Remember that Ubiquity's command line is a pseudo-natural-language environment, so it attempts to be as close to natural language grammar as possible.
Your command can take multiple arguments.  Each one is identified by a "role".  To understand roles, it helps to think of your command name as a verb, and each argument as a noun.  Remember that Ubiquity's command line is a pseudo-natural-language environment, so it attempts to be as close to natural language grammar as possible.
Line 336: Line 340:
"Object" is the most common role.  If a command takes only one argument, that argument is usually an "object".
"Object" is the most common role.  If a command takes only one argument, that argument is usually an "object".


=== What Roles Can I Use? ===
==== What Roles Can I Use? ====


* object  (in "echo helloooo", hello is the object.)
* object  (in "echo helloooo", hello is the object.)
1,007

edits

Navigation menu