1,007
edits
Changes
→Introduction to Noun Types
Our example command only cares about the <code>.text</code> attribute of the input, because it simply wants plain text. Often, when the user invokes your command by typing a few short words into the input box, <code>.text</code>, <code>.html</code>, and <code>.summary</code> will all have exactly the same value, and <code>.data</code> will be null. Many, if not most, commands that you write will only care about the text value. Nevertheless, the other versions of the input data are provided to you in case they differ from <code>.text</code> and in case your command has a use for them.
Notice that we specified the type of argument to expect by passing in an object — in this case, the predefined <code>noun_arb_text</code> object, which accepts any arbitrary text as a valid argument. If we had wanted to restrict the inputs that our command could take, we could have used a more specific noun-type object to restrict the scope of the argument: for instance, <code>noun_type_date</code> to accept only dates (like the "check-calendar" command) or <code>noun_type_language</code> to accept only names of languages (like the optional modifiers for the "translate" command).
The benefit of specifying a more restrictive noun-type is that it helps the Ubiquity parser generate better suggestions and auto-completions based on user-input. For instance, if the user has a date selected, commands that operate specifically on dates are more likely to be apropos than commands that take arbitrary text, so Ubiquity can suggest the date-specific commands first.
Once you are familiar with writing commands, you should check out the [http://hg.toolness.com/ubiquity-firefox/file/6caa9d66b3bb/ubiquity/chrome/content/nlparser/en/nountypes.js nountypes.js], which has the implementation for most of the noun-types. You can see what noun types are already available for your commands to use, what still needs to be written, and where the existing implementations could use improvement — and then come [[Labs/Ubiquity#Participation|get involved]] to help us improve them.