Labs/Ubiquity/Parser Documentation: Difference between revisions

Line 173: Line 173:
=== Filling missing arguments with the selection ===
=== Filling missing arguments with the selection ===


=== Filling missing arguments with the NounType's defaults ===
=== Filling missing arguments with defaults ===


NLParser.ParsedSentence.fillMissingArgsWithDefaults() in parser.js
At this point, we've filled in all the arguments we can fill based on stuff the user has typed and/or selected.  There may still be arguments unfilled; if so, we'll attempt to fill them with default suggestions.
There are two sources that default suggestions can come from.  The first place we check is the verb's argument definitions.  There's a (not yet widely used) feature of the command creation API that lets verbs define defaults for its arguments, like so:  (TODO)
If there's no verb-defined default, we look for a default defined by the noun type.  For example, noun_type_date ( in ubiquity/feed-parts/header/en/nountypes.js ) defines a <tt>default()</tt> function that returns a suggestion for the current date.
A feature that is not yet implemented, but should be, is the ability for a nountype to return multiple defaults instead of just a single default.  It might be useful, for instance, to have <tt>noun_type_language</tt> return as default suggestions the two or three languages that you use most often.
If no default is available from either source, the argument remains empty.
NLParser.ParsedSentence.getAlternateSelectionInterpolations() in parser.js


== Scoring and Sorting Suggestions ==
== Scoring and Sorting Suggestions ==
1,007

edits