1,007
edits
| Line 180: | Line 180: | ||
=== Binding arguments to the FullyParsedSentences === | === Binding arguments to the FullyParsedSentences === | ||
Remember that the underlying Translate command object (defined in ubiquity/standard-feeds/general.js) has methods like: | |||
<pre> | |||
execute: function( directObj, languages ) | |||
preview: function( pBlock, directObj, languages ) | |||
</pre> | |||
(where "languages" is a dictionary of modifier arguments, i.e. the "to" and "from" arguments) | |||
A FullyParsedSentence object wraps a command object along with specific values for the directObj and modifier arguments. So client code can call <tt>.execute()</tt> or <tt>.preview()</tt> methods on a FullyParsedSentence object without having to supply values for the directObject or modifiers -- you can think of those values as already having been "bound". Instead, the function signatures look like this: | |||
<pre> | |||
execute: function( context ) | |||
preview: function( context, previewBlock ) | |||
</pre> | |||
See ubiquity/modules/cmdmanager.js to see an example of client code using the external API of the FullyParsedSentence objects returned as suggestions from NLParser.Parser.getSuggestionList() and NLParser.Parser.getSentence(). | |||
=== Sorting the suggestions and returning them === | === Sorting the suggestions and returning them === | ||
edits