Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Feature/dictionary support #26

Merged
merged 13 commits into from

3 participants

@omicronlab

Finished Preference window and bindings.

I think we've hit our development milestone :D

mugli added some commits
@mugli mugli Added preference support in suggestion builder
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
ff1c575
@mugli mugli Bound dictionary enable/disable preference to suggestion builder
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
eb169fa
@mugli mugli Renamed settings variables
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
9594d18
@mugli mugli Updated engine to obey settings
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
6306547
@mugli mugli Updated settings schema
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
ae5cb3e
@mugli mugli Ooops! Missed to rename a variable in preference :-|
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
ad3e8a1
@mugli mugli Updated engine to obey settings
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
1eaf517
@mugli mugli Added validation in preference window
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
0d40f9d
@mugli mugli Removed 1st number from dictionary search
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
e33683f
@mugli mugli Reverted regex rule for 'a'. Too many suggestion to handle
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
d2c7c7d
@mugli mugli Removed two autocorrect entries
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
8798552
@mugli mugli Added new preference: Commit newline on Enter/Return key
Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
396b54e
@mugli mugli Merge branch 'feature/dictionary-support' of https://github.com/sarim…
…/ibus-avro into feature/dictionary-support
e799f19
@sarim sarim merged commit 83095ee into sarim:feature/dictionary-support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 6, 2012
  1. @mugli

    Added preference support in suggestion builder

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  2. @mugli

    Bound dictionary enable/disable preference to suggestion builder

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  3. @mugli

    Renamed settings variables

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  4. @mugli

    Updated engine to obey settings

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  5. @mugli

    Updated settings schema

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  6. @mugli

    Ooops! Missed to rename a variable in preference :-|

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  7. @mugli

    Updated engine to obey settings

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
Commits on Jul 7, 2012
  1. @mugli

    Added validation in preference window

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  2. @mugli

    Removed 1st number from dictionary search

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  3. @mugli

    Reverted regex rule for 'a'. Too many suggestion to handle

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  4. @mugli

    Removed two autocorrect entries

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  5. @mugli

    Added new preference: Commit newline on Enter/Return key

    mugli authored
    Signed-off-by: Mehdi Hasan <mhasan@omicronlab.com>
  6. @mugli
This page is out of date. Refresh to see the latest.
View
2  autocorrect.js
@@ -78,8 +78,6 @@ var db =
":-S": ":-S",
":-SS": ":-SS",
":-t": ":-t",
- ":\ufb01": ":\ufb01",
- ":-\ufb01": ":-\ufb01",
":u": ":u",
":-w": ":-w",
":x": ":x",
View
42 avropref.ui
@@ -65,7 +65,7 @@
</packing>
</child>
<child>
- <object class="GtkSwitch" id="switch_auxtxt">
+ <object class="GtkSwitch" id="switch_preview">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -79,7 +79,7 @@
</packing>
</child>
<child>
- <object class="GtkSwitch" id="switch_lutable">
+ <object class="GtkSwitch" id="switch_dict">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -93,6 +93,36 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Commit newline on Enter/Return key:</property>
+ <property name="justify">right</property>
+ <property name="width_chars">25</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="switch_newline">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -101,7 +131,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -120,7 +150,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -134,7 +164,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -152,7 +182,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
View
14 avroregexlib.js
@@ -247,21 +247,9 @@ AvroRegex.prototype = {
},
{
"find":"a",
- "replace":"(([অএ]্যা?)|[অআএ]|([‍‌]?(্য)?া)|(য়া))?",
+ "replace":"(([অএ]্যা?)|[অআএ]|([‍‌]?(্য)?া)|(য়া))",
"rules":
[
- {
- "matches":
- [
- {
- "type":"prefix",
- "scope":"punctuation",
- "value":"",
- "negative":"FALSE"
- }
- ],
- "replace":"(([অএ]্যা?)|[অআএ]|([‍‌]?(্য)?া)|(য়া))"
- }
]
},
{
View
19 com.omicronlab.avro.gschema.xml
@@ -1,20 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="com.omicronlab.avro" path="/com/omicronlab/avro/">
- <key type="b" name="switch-auxtxt">
+ <key type="b" name="switch-preview">
<default>true</default>
- <summary>switch-auxtxt</summary>
- <description>Whether Auxiliary (English) Text will be shown</description>
+ <summary>switch-preview</summary>
+ <description>Whether Preview window (auxiliary text, suggestions) will be shown</description>
</key>
- <key type="b" name="switch-lutable">
+ <key type="b" name="switch-dict">
<default>true</default>
- <summary>switch-lutable</summary>
- <description>Whether Dictionary Suggestion will be shown</description>
+ <summary>switch-dict</summary>
+ <description>Whether dictionary suggestions will be shown</description>
+ </key>
+ <key type="b" name="switch-newline">
+ <default>false</default>
+ <summary>switch-newline</summary>
+ <description>Whether enter key should commit newline after applying candidate</description>
</key>
<key type="i" name="lutable-size">
<default>16</default>
<summary>lutable-size</summary>
- <description>Dictionary Suggestion Lookup Table Size</description>
+ <description>Dictionary suggestion lookup table size</description>
</key>
<key type="i" name="cboxorient">
<default>0</default>
View
30 dbsearch.js
@@ -119,36 +119,6 @@ DBSearch.prototype = {
case 'z':
tableList = ["h", "j", "jh", "z"];
break;
- case '1':
- tableList = ["e"];
- break;
- case '2':
- tableList = ["d"];
- break;
- case '3':
- tableList = ["t"];
- break;
- case '4':
- tableList = ["c"];
- break;
- case '5':
- tableList = ["p"];
- break;
- case '6':
- tableList = ["ch"];
- break;
- case '7':
- tableList = ["s"];
- break;
- case '8':
- tableList = ["aa"];
- break;
- case '9':
- tableList = ["n"];
- break;
- case '0':
- tableList = ["sh"];
- break;
default:
break;
}
View
61 main-gjs.js
@@ -94,7 +94,7 @@ if (bus.is_connected()) {
} else if (keyval == IBus.Return || keyval == IBus.space || keyval == IBus.Tab) {
if (engine.buffertext.length > 0){
- if (keyval == IBus.Return && engine.buffertext.length > 0 && engine.currentSuggestions.length > 1){
+ if (keyval == IBus.Return && engine.buffertext.length > 0 && engine.currentSuggestions.length > 1 && (!engine.setting_switch_newline)){
commitCandidate(engine);
return true;
} else {
@@ -225,7 +225,10 @@ if (bus.is_connected()) {
engine.setting = Gio.Settings.new("com.omicronlab.avro");
//set up a asynchronous callback for instant change later
- engine.setting.connect('changed',function(){readSetting(engine);});
+ engine.setting.connect('changed',
+ function(){
+ readSetting(engine);
+ });
//read manually first time
readSetting(engine);
@@ -233,10 +236,20 @@ if (bus.is_connected()) {
function readSetting(engine){
- engine.setting_switch_auxtxt = engine.setting.get_boolean('switch-auxtxt');
- engine.setting_switch_lutable = engine.setting.get_boolean('switch-lutable');
+ engine.setting_switch_preview = engine.setting.get_boolean('switch-preview');
+ engine.setting_switch_dict = engine.setting.get_boolean('switch-dict');
+ engine.setting_switch_newline = engine.setting.get_boolean('switch-newline');
engine.lookuptable.set_orientation(engine.setting.get_int('cboxorient'));
- engine.lookuptable.set_page_size(engine.setting.get_int('lutable-size'));
+ engine.setting_lutable_size = engine.setting.get_int('lutable-size');
+ engine.lookuptable.set_page_size(engine.setting_lutable_size);
+
+ if (!engine.setting_switch_preview){
+ engine.setting_switch_dict = false;
+ }
+
+ var dictPref = suggestionBuilder.getPref();
+ dictPref.dictEnable = engine.setting_switch_dict;
+ suggestionBuilder.setPref(dictPref);
}
@@ -254,7 +267,7 @@ if (bus.is_connected()) {
function updateCurrentSuggestions(engine){
var suggestion = suggestionBuilder.suggest(engine.buffertext);
- engine.currentSuggestions = suggestion['words'].slice(0);
+ engine.currentSuggestions = suggestion['words'].slice(0, engine.setting_lutable_size);
engine.currentSelection = suggestion['prevSelection'];
fillLookupTable (engine);
@@ -262,26 +275,35 @@ if (bus.is_connected()) {
function fillLookupTable (engine){
- var auxiliaryText = IBus.Text.new_from_string(engine.buffertext);
- if (engine.setting_switch_auxtxt)
- engine.update_auxiliary_text(auxiliaryText, true);
- engine.lookuptable.clear();
- engine.currentSuggestions.forEach(function(word){
- let wtext = IBus.Text.new_from_string(word);
- //default, ibus sets "1,2,3,4...." as label, i didn't find how to hide it,but a empty string can partially hide it
- let wlabel = IBus.Text.new_from_string('');;
- engine.lookuptable.append_candidate(wtext);
- engine.lookuptable.append_label(wlabel);
- });
+ if (engine.setting_switch_preview){
+ var auxiliaryText = IBus.Text.new_from_string(engine.buffertext);
+ engine.update_auxiliary_text(auxiliaryText, true);
+
+ if (engine.setting_switch_dict){
+ engine.lookuptable.clear();
+
+ engine.currentSuggestions.forEach(function(word){
+ let wtext = IBus.Text.new_from_string(word);
+ //default, ibus sets "1,2,3,4...." as label, i didn't find how to hide it,but a empty string can partially hide it
+ let wlabel = IBus.Text.new_from_string('');;
+ engine.lookuptable.append_candidate(wtext);
+ engine.lookuptable.append_label(wlabel);
+ });
+ }
+ }
preeditCandidate(engine);
}
function preeditCandidate(engine){
- engine.lookuptable.set_cursor_pos(engine.currentSelection);
- engine.update_lookup_table_fast(engine.lookuptable,true);
+ if (engine.setting_switch_preview){
+ if (engine.setting_switch_dict){
+ engine.lookuptable.set_cursor_pos(engine.currentSelection);
+ engine.update_lookup_table_fast(engine.lookuptable,true);
+ }
+ }
var preeditText = IBus.Text.new_from_string(engine.currentSuggestions[engine.currentSelection]);
engine.update_preedit_text(preeditText, engine.currentSuggestions[engine.currentSelection].length, true);
@@ -387,6 +409,7 @@ if (bus.is_connected()) {
}
component.add_engine(avroenginedesc);
+
if (exec_by_ibus) {
bus.request_name("org.freedesktop.IBus.Avro", 0);
} else {
View
21 pref.js
@@ -38,14 +38,27 @@ function runpref() {
builder.add_from_file(eevars.get_pkgdatadir() + "/avropref.ui");
let prefwindow = builder.get_object("window1");
- let switch_auxtxt = builder.get_object("switch_auxtxt");
- let switch_lutable = builder.get_object("switch_lutable");
+ let switch_preview = builder.get_object("switch_preview");
+ let switch_dict = builder.get_object("switch_dict");
+ let switch_newline = builder.get_object("switch_newline");
let lutable_size = builder.get_object("lutable_size");
let cboxorient = builder.get_object("cboxorient");
+
+ switch_preview.connect("notify::active", function(widget, data){
+ if (!switch_preview.get_active()){
+ switch_dict.set_active(false);
+ }
+ });
+
+ //Initialize after loading
+ if (!switch_preview.get_active()){
+ switch_dict.set_active(false);
+ }
let setting = Gio.Settings.new("com.omicronlab.avro")
- setting.bind("switch-auxtxt", switch_auxtxt, "active", Gio.SettingsBindFlags.DEFAULT)
- setting.bind("switch-lutable", switch_lutable, "active", Gio.SettingsBindFlags.DEFAULT)
+ setting.bind("switch-preview", switch_preview, "active", Gio.SettingsBindFlags.DEFAULT)
+ setting.bind("switch-dict", switch_dict, "active", Gio.SettingsBindFlags.DEFAULT)
+ setting.bind("switch-newline", switch_newline, "active", Gio.SettingsBindFlags.DEFAULT)
setting.bind("lutable-size", lutable_size, "value", Gio.SettingsBindFlags.DEFAULT)
setting.bind("cboxorient", cboxorient, "active", Gio.SettingsBindFlags.DEFAULT)
View
129 suggestionbuilder.js
@@ -47,6 +47,15 @@ SuggestionBuilder.prototype = {
this._phoneticCache = {};
this._loadCandidateSelectionsFromFile();
this._tempCache = {};
+ this._pref = this._defaultPref();
+ },
+
+
+ _defaultPref: function(){
+ var pref = {};
+ pref.dictEnable = true;
+
+ return pref;
},
@@ -243,52 +252,63 @@ SuggestionBuilder.prototype = {
_joinSuggestion: function(autoCorrect, dictSuggestion, phonetic, splitWord){
var words = [];
- /* 1st Item: Autocorrect */
- if (autoCorrect['corrected']){
- words.push(autoCorrect['corrected']);
- //Add autocorrect entry to dictSuggestion for suffix support
- if (!autoCorrect['exact']){
- dictSuggestion.push(autoCorrect['corrected']);
- }
- }
+ if (!this._pref.dictEnable){
+ words.push(phonetic);
+ words[0] = splitWord['begin'] + words[0] + splitWord['end'];
+
+ var suggestion = {};
+ suggestion['words'] = words;
+ suggestion['prevSelection'] = 0;
+ } else {
+
+ /* 1st Item: Autocorrect */
+ if (autoCorrect['corrected']){
+ words.push(autoCorrect['corrected']);
+ //Add autocorrect entry to dictSuggestion for suffix support
+ if (!autoCorrect['exact']){
+ dictSuggestion.push(autoCorrect['corrected']);
+ }
+ }
- /* 2rd Item: Dictionary Avro Phonetic */
- //Update Phonetic Cache
- if(!this._phoneticCache[splitWord['middle'].toLowerCase()]){
- if (dictSuggestion.length > 0){
- this._phoneticCache[splitWord['middle'].toLowerCase()] = dictSuggestion.slice(0);
- }
- }
- //Add Suffix
- var dictSuggestionWithSuffix = this._addSuffix(splitWord);
+ /* 2rd Item: Dictionary Avro Phonetic */
+ //Update Phonetic Cache
+ if(!this._phoneticCache[splitWord['middle'].toLowerCase()]){
+ if (dictSuggestion.length > 0){
+ this._phoneticCache[splitWord['middle'].toLowerCase()] = dictSuggestion.slice(0);
+ }
+ }
+ //Add Suffix
+ var dictSuggestionWithSuffix = this._addSuffix(splitWord);
- var sortedWords = this._sortByPhoneticRelevance(phonetic, dictSuggestionWithSuffix);
- for (i in sortedWords){
- this._addToArray(words, sortedWords[i]);
- }
+ var sortedWords = this._sortByPhoneticRelevance(phonetic, dictSuggestionWithSuffix);
+ for (i in sortedWords){
+ this._addToArray(words, sortedWords[i]);
+ }
- /* 3rd Item: Classic Avro Phonetic */
- this._addToArray(words, phonetic);
+ /* 3rd Item: Classic Avro Phonetic */
+ this._addToArray(words, phonetic);
- var suggestion = {};
+ var suggestion = {};
- //Is there any previous custom selection of the user?
- suggestion['prevSelection'] = this._getPreviousSelection(splitWord, words);
+ //Is there any previous custom selection of the user?
+ suggestion['prevSelection'] = this._getPreviousSelection(splitWord, words);
- //Add padding to all, except exact autocorrect
- for (i in words){
- if (autoCorrect['exact']){
- if (autoCorrect['corrected'] != words[i]){
- words[i] = splitWord['begin'] + words[i] + splitWord['end'];
+ //Add padding to all, except exact autocorrect
+ for (i in words){
+ if (autoCorrect['exact']){
+ if (autoCorrect['corrected'] != words[i]){
+ words[i] = splitWord['begin'] + words[i] + splitWord['end'];
+ }
+ } else {
+ words[i] = splitWord['begin'] + words[i] + splitWord['end'];
+ }
}
- } else {
- words[i] = splitWord['begin'] + words[i] + splitWord['end'];
- }
- }
- suggestion['words'] = words;
+ suggestion['words'] = words;
+ }
+
return suggestion;
},
@@ -422,7 +442,28 @@ SuggestionBuilder.prototype = {
},
+
+ _logger: function (obj, msg){
+ print ((msg || 'Log') + ': ' + JSON.stringify(obj, null, '\t'));
+ },
+
+
+ getPref: function(){
+ return this._pref;
+ },
+
+
+ setPref: function(pref){
+ //TODO: Add Validation
+ this._pref = pref;
+ },
+
+
stringCommitted: function(word, candidate){
+ if (!this._pref.dictEnable){
+ return;
+ }
+
//If it is called, user made the final decision here
//Check and save selection without suffix if that is not present
@@ -441,17 +482,16 @@ SuggestionBuilder.prototype = {
updateCandidateSelection: function(word, candidate){
+ if (!this._pref.dictEnable){
+ return;
+ }
+
//Seperate begining and trailing padding characters, punctuations etc. from whole word
var splitWord = this._separatePadding(word);
this._updateCandidateSelection(splitWord['middle'], candidate);
},
- _logger: function (obj, msg){
- print ((msg || 'Log') + ': ' + JSON.stringify(obj, null, '\t'));
- },
-
-
suggest: function(word){
//Seperate begining and trailing padding characters, punctuations etc. from whole word
var splitWord = this._separatePadding(word);
@@ -462,8 +502,11 @@ SuggestionBuilder.prototype = {
//Convert the word to Bangla using 3 separate methods
var phonetic = this._getClassicPhonetic(splitWord['middle']);
- var dictSuggestion = this._getDictionarySuggestion(splitWord);
- var autoCorrect = this._getAutocorrect(word, splitWord);
+
+ if (this._pref.dictEnable){
+ var dictSuggestion = this._getDictionarySuggestion(splitWord);
+ var autoCorrect = this._getAutocorrect(word, splitWord);
+ }
//Prepare suggestion object
var suggestion = this._joinSuggestion(autoCorrect, dictSuggestion, phonetic, splitWord);
Something went wrong with that request. Please try again.