Repository :
http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : multilingual
---------------------------------------------------------------
commit 9b20e6a02aac94eff1366949aa104cf34a68fd01
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Wed Mar 23 15:06:28 2016 +0100
WIP: multilingual
---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 47 ++++++++++++++++++++----
ibus-typing-booster/hunspell-tables/mr_IN.conf | 2 +-
2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py
b/ibus-typing-booster/engine/hunspell_table.py
index 902d583..483684e 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -322,7 +322,8 @@ class editor(object):
transliterated_string = unicodedata.normalize(
'NFC', self._transliterated_string)
attrs = IBus.AttrList ()
- if not phrase.startswith(transliterated_string):
+ if not (phrase.startswith(transliterated_string)
+ or phrase.startswith(u''.join(self._typed_string))):
# this is a candidate which does not start exactly
# as the transliterated user input, i.e. it is a suggestion
# for a spelling correction:
@@ -372,9 +373,10 @@ class editor(object):
self._lookup_table.clear()
self._lookup_table.set_cursor_visible(False)
self._candidates = []
- prefix_length = 0
- prefix = u''
+ transliterated_candidates = []
if self._transliterated_string:
+ prefix_length = 0
+ prefix = u''
stripped_transliterated_string = (
itb_util.lstrip_token(self._transliterated_string))
if len(stripped_transliterated_string) >= self._min_char_complete:
@@ -384,17 +386,48 @@ class editor(object):
if prefix_length:
prefix = self._transliterated_string[0:prefix_length]
try:
- self._candidates = self.db.select_words(
+ transliterated_candidates = self.db.select_words(
stripped_transliterated_string,
p_phrase=self._p_phrase,
pp_phrase=self._pp_phrase)
except:
import traceback
traceback.print_exc()
+ if transliterated_candidates and prefix:
+ transliterated_candidates = (
+ [(prefix+x[0], x[1]) for x in transliterated_candidates])
+ untransliterated_candidates = []
+ if True and self._typed_string:
+ prefix_length = 0
+ prefix = u''
+ untransliterated_string = u''.join(self._typed_string)
+ stripped_untransliterated_string = (
+ itb_util.lstrip_token(untransliterated_string))
+ if len(stripped_untransliterated_string) >= self._min_char_complete:
+ prefix_length = (
+ len(untransliterated_string)
+ - len(stripped_untransliterated_string))
+ if prefix_length:
+ prefix = untransliterated_string[0:prefix_length]
+ try:
+ untransliterated_candidates = self.db.select_words(
+ stripped_untransliterated_string,
+ p_phrase=self._p_phrase,
+ pp_phrase=self._pp_phrase)
+ except:
+ import traceback
+ traceback.print_exc()
+ if untransliterated_candidates and prefix:
+ untransliterated_candidates = (
+ [(prefix+x[0], x[1]) for x in untransliterated_candidates])
+ self._candidates = sorted(
+ transliterated_candidates + untransliterated_candidates,
+ key = lambda x: (
+ -1*x[1], # user_freq descending
+ len(x[0]), # len(phrase) ascending
+ x[0] # phrase alphabetical
+ ))[:20]
if self._candidates:
- if prefix:
- self._candidates = (
- [(prefix+x[0], x[1]) for x in self._candidates])
for x in self._candidates:
self.append_candidate_to_lookup_table(
phrase=x[0], user_freq=x[1])
diff --git a/ibus-typing-booster/hunspell-tables/mr_IN.conf
b/ibus-typing-booster/hunspell-tables/mr_IN.conf
index 9f644dd..ef009cd 100644
--- a/ibus-typing-booster/hunspell-tables/mr_IN.conf
+++ b/ibus-typing-booster/hunspell-tables/mr_IN.conf
@@ -7,7 +7,7 @@ language = mr
author = Anish Patil <apatil(a)redhat.com>
status_prompt = mr
layout = default
-hunspell_dict = mr_IN.dic
+hunspell_dict = mr_IN.dic, en_GB.dic
hunspell_dict_package = hunspell-mr
ime_name = Marathi - IN (Hunspell)
symbol = mr-IN