Skip to content

Instantly share code, notes, and snippets.

@satyr
Created March 3, 2009 18:52
Show Gist options
  • Save satyr/73453 to your computer and use it in GitHub Desktop.
Save satyr/73453 to your computer and use it in GitHub Desktop.
Modifies a command's frequency score for Noun-First Suggestion.
CmdUtils.CreateCommand({
name: 'set-frequency-of',
icon: 'chrome://ubiquity/skin/icons/favicon.ico',
description:
'Modifies the frequency score of a command for Noun-First Suggestion.',
arguments: {
object: noun_type_enabled_command,
goal_score: noun_type_number,
},
execute: function({object: {text: name, data: cmd}, goal: {text: score}}){
var from = this._getScore(cmd);
displayMessage(cmd.name +' : '+ from +' -> '+ this._setScore(cmd, ~~score),
this);
},
preview: function(pb, {object: {html, data: cmd}}){
pb.innerHTML = (
cmd
? html +' : <b>'+ this._getScore(cmd) + '</b>'
: this.description);
},
get _SM()(context.chromeWindow.gUbiquity
.__cmdManager.__nlParser._suggestionMemory),
_getScore: function(cmd) this._SM.getScore('', cmd.id),
_setScore: function(cmd, score){
var {id} = cmd, sm = this._SM;
sm._table[''][id] = score - 1;
sm.remember('', id);
return score;
},
author: 'satyr', license: 'MIT',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment