Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 79aadf342696ae4e6d7ecf39888445ef9a71f1a5
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Mon Jan 23 12:49:03 2017 +0100
Calculate the maximum word length for each dictionary individually
It was harcoded to 40 which was about correct for the German hunspell
dictionary. But some dictionaries have longer words (it_IT has a
maximum word length of 48) and some have shorter words (en_GB has a
maximum word length of 28). So using the hardcoded value of 40 might
miss some matches in the Italien dictionary and waste some time using
the British English dictionary trying to complete words which are
already longer then the maximum word length in the en_GB dictionary.
>---------------------------------------------------------------
engine/hunspell_suggest.py | 42 ++++++++++++++++++++++--------------------
1 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/engine/hunspell_suggest.py b/engine/hunspell_suggest.py
index ce56d38..f75b832 100755
--- a/engine/hunspell_suggest.py
+++ b/engine/hunspell_suggest.py
@@ -64,6 +64,7 @@ class Dictionary:
self.encoding = 'UTF-8'
self.words = []
self.word_pairs = []
+ self.max_word_len = 0 # maximum length of words in this dictionary
self.enchant_dict = None
self.pyhunspell_object = None
self.load_dictionary()
@@ -95,6 +96,13 @@ class Dictionary:
(x, itb_util.remove_accents(x))
for x in self.words
]
+ for x in self.words:
+ if len(x) > self.max_word_len:
+ self.max_word_len = len(x)
+ if DEBUG_LEVEL > 1:
+ sys.stderr.write(
+ 'load_dictionary() max_word_len = %s\n'
+ % self.max_word_len)
if IMPORT_ENCHANT_SUCCESSFUL:
self.enchant_dict = enchant.Dict(self.name)
elif IMPORT_HUNSPELL_SUCCESSFUL and dic_path:
@@ -200,16 +208,6 @@ class Hunspell:
'''
if input_phrase in self._suggest_cache:
return self._suggest_cache[input_phrase]
- # If the input phrase is very long, don���t try looking
- # something up in the hunspell dictionaries. The regexp match
- # gets very slow if the input phrase is very long. And there
- # are no very long words in the hunspell dictionaries anyway,
- # the longest word in the German hunspell dictionary currently
- # seems to be ���Geschwindigkeits��bertretungsverfahren��� trying
- # to match words longer than that just wastes time.
- if len(input_phrase) > 40:
- self._suggest_cache[input_phrase] = []
- return []
if DEBUG_LEVEL > 1:
sys.stderr.write(
"Hunspell.suggest() input_phrase=%(ip)s\n"
@@ -240,16 +238,20 @@ class Hunspell:
suggested_words = {}
for dictionary in self._dictionaries:
if dictionary.words:
- if dictionary.word_pairs:
- suggested_words.update([
- (x[0], 0)
- for x in dictionary.word_pairs
- if x[1].startswith(input_phrase_no_accents)])
- else:
- suggested_words.update([
- (x, 0)
- for x in dictionary.words
- if x.startswith(input_phrase)])
+ # If the input phrase is longer than than the maximum
+ # word length in a dictionary, don���t try
+ # complete it, it just wastes time then.
+ if len(input_phrase) <= dictionary.max_word_len:
+ if dictionary.word_pairs:
+ suggested_words.update([
+ (x[0], 0)
+ for x in dictionary.word_pairs
+ if x[1].startswith(input_phrase_no_accents)])
+ else:
+ suggested_words.update([
+ (x, 0)
+ for x in dictionary.words
+ if x.startswith(input_phrase)])
if dictionary.enchant_dict:
if len(input_phrase) >= 4:
# Always pass NFC to enchant and convert the
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 1cef443d12d78b59d35db62fe4965359497ffdd0
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Mon Jan 23 10:03:59 2017 +0100
Improve accent insensitive matching
���filosofic��te��js����� should also match ���filosofic��te��js��i�����.
I.e. if the input typed already contains accents, completing a word
from a hunspell dictionary starting with this input should work.
Until now, ���filosofic��te��js����� was matched against the word from
the dictionary with the accents removed, i.e. ���filosofic��te��js����� was
matched against ���filosofictejsi���, which failed and gave no match.
Now, for languages where accent insentive match makes sense,
the input with accents removed is matched against the dictionary
word with accents removed, i.e. when the input is ���filosofic��te��js�����,
���filosofictejs��� is matched against ���filosofictejsi��� which succeeds
and thus ���filosofic��te��js��i����� is now returned as a match.
>---------------------------------------------------------------
engine/hunspell_suggest.py | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/engine/hunspell_suggest.py b/engine/hunspell_suggest.py
index e301961..26e864e 100755
--- a/engine/hunspell_suggest.py
+++ b/engine/hunspell_suggest.py
@@ -169,9 +169,24 @@ class Hunspell:
>>> h.suggest('Geschwindigkeitsubertre')[0]
('Geschwindigkeitsu��bertretungsverfahren', 0)
+ >>> h.suggest('Geschwindigkeitsu��bertretungsverfahren')[0]
+ ('Geschwindigkeitsu��bertretungsverfahren', 0)
+
+ >>> h.suggest('Gl��hw��rmchen')[0]
+ ('Glu��hwu��rmchen', 0)
+
>>> h.suggest('filosofictejsi')
[('filosofic��te��js��i��', 0), ('filosofic��te��ji', -1)]
+ >>> h.suggest('filosofictejs')[0]
+ ('filosofic��te��js��i��', 0)
+
+ >>> h.suggest('filosofic��te��js��i��')[0]
+ ('filosofic��te��js��i��', 0)
+
+ >>> h.suggest('filosofic��te��js��')[0]
+ ('filosofic��te��js��i��', 0)
+
>>> h = Hunspell(['it_IT'])
>>> h.suggest('principianti')
[('principianti', 0), ('principiati', -1), ('principiante', -1), ('principiarti', -1), ('principiasti', -1)]
@@ -179,6 +194,9 @@ class Hunspell:
>>> h = Hunspell(['es_ES'])
>>> h.suggest('teneis')
[('tene��is', 0), ('tenes', -1), ('tenis', -1), ('teneos', -1), ('tienes', -1), ('te neis', -1), ('te-neis', -1)]
+
+ >>> h.suggest('ten��is')[0]
+ ('tene��is', 0)
'''
if input_phrase in self._suggest_cache:
return self._suggest_cache[input_phrase]
@@ -213,11 +231,16 @@ class Hunspell:
# make sure input_phrase is in the internal normalization form (NFD):
input_phrase = unicodedata.normalize(
itb_util.NORMALIZATION_FORM_INTERNAL, input_phrase)
+ input_phrase_no_accents = unicodedata.normalize(
+ itb_util.NORMALIZATION_FORM_INTERNAL,
+ itb_util.remove_accents(input_phrase))
# But enchant and pyhunspell want NFC as input, make a copy in NFC:
input_phrase_nfc = unicodedata.normalize('NFC', input_phrase)
# '/' is already removed from the buffer, we do not need to
# take care of it in the regexp.
patt_start = re.compile(r'^' + re.escape(input_phrase))
+ patt_start_no_accents = re.compile(
+ r'^' + re.escape(input_phrase_no_accents))
suggested_words = {}
for dictionary in self._dictionaries:
@@ -226,7 +249,7 @@ class Hunspell:
suggested_words.update([
(x[0], 0)
for x in dictionary.word_pairs
- if patt_start.match(x[1])])
+ if patt_start_no_accents.match(x[1])])
else:
suggested_words.update([
(x, 0)
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 4e2b44fd93de23d92c1a6a001291d3c7f27b67d1
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Jan 19 07:33:15 2017 +0100
Release 1.5.19
>---------------------------------------------------------------
ChangeLog | 7 +++++++
configure.ac | 2 +-
typing-booster.appdata.xml | 19 +++++++++++++++++++
3 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4529c74..5618657 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
* Author: Mike FABIAN <mfabian(a)redhat.com>
+* 19 Jan 2017 Released 1.5.19 version
+* Improve setup layout (thanks to Trinh Anh Ngoc <atw1990(a)gmail.com>)
+* Add some more directories to search for dictionaries (for FreeBSD)
+* Wrong variable ���page_size��� was used in set_lookup_table_orientation()
+* Do not try to reopen the pre��dit when any modifier except CapsLock is on (Resolves: rhbz#1414642)
+
+* Author: Mike FABIAN <mfabian(a)redhat.com>
* 17 Jan 2017 Released 1.5.18 version
* Fix typo in the ���Unbreak sqlite on Python 3.6��� patch
* Fix the fallback to use pyhunspell-python3 when python3-enchant is not available
diff --git a/configure.ac b/configure.ac
index dcb5c22..853361b 100755
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ m4_define([package_name], [ibus-typing-booster])
m4_define([ibus_released], [1])
m4_define([ibus_major_version], [1])
m4_define([ibus_minor_version], [5])
-m4_define([ibus_micro_version], [18])
+m4_define([ibus_micro_version], [19])
m4_define(ibus_maybe_datestamp,
m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
diff --git a/typing-booster.appdata.xml b/typing-booster.appdata.xml
index b104a49..55cf373 100644
--- a/typing-booster.appdata.xml
+++ b/typing-booster.appdata.xml
@@ -16,6 +16,25 @@
<url type="bugtracker">https://github.com/mike-fabian/ibus-typing-booster/issues</url>
<url type="help">https://mike-fabian.github.io/ibus-typing-booster/documentation.html</url>
<releases>
+ <release version="1.5.19" date="2017-01-19" urgency="medium">
+ <description>
+ <ul>
+ <li>
+ Improve setup layout (thanks to Trinh Anh Ngoc <atw1990(a)gmail.com>)
+ </li>
+ <li>
+ Add some more directories to search for dictionaries (for FreeBSD)
+ </li>
+ <li>
+ Wrong variable ���page_size��� was used in set_lookup_table_orientation()
+ </li>
+ <li>
+ Do not try to reopen the pre��dit when any modifier except
+ CapsLock is on (Resolves: rhbz#1414642)
+ </li>
+ </ul>
+ </description>
+ </release>
<release version="1.5.18" date="2017-01-17" urgency="medium">
<description>
<ul>
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 3635ddfba8138264ce0088d0e47ade9d39cac6eb
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Jan 19 05:39:22 2017 +0100
Fix some pylint warnings
>---------------------------------------------------------------
engine/hunspell_table.py | 18 +++++++++++-------
pylintrc | 2 +-
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/engine/hunspell_table.py b/engine/hunspell_table.py
index d665157..315bc1c 100644
--- a/engine/hunspell_table.py
+++ b/engine/hunspell_table.py
@@ -1683,9 +1683,9 @@ class TypingBoosterEngine(IBus.Engine):
# ��� and the context before is ���word ��� make the result
# ���word! ���.
pattern_sentence_end = re.compile(
- '^['
+ r'^['
+ re.escape(itb_util.SENTENCE_END_CHARACTERS)
- + ']+[\s]*$')
+ + r']+[\s]*$')
if pattern_sentence_end.search(commit_phrase):
surrounding_text = self.get_surrounding_text()
text = surrounding_text[0].get_text()
@@ -1858,7 +1858,7 @@ class TypingBoosterEngine(IBus.Engine):
applications.
'''
- if not (self.client_capabilities & IBus.Capabilite.SURROUNDING_TEXT):
+ if not self.client_capabilities & IBus.Capabilite.SURROUNDING_TEXT:
# If getting the surrounding text is not supported, leave
# the context as it is, i.e. rely on remembering what was
# typed last.
@@ -2245,7 +2245,8 @@ class TypingBoosterEngine(IBus.Engine):
'''
if DEBUG_LEVEL > 1:
sys.stderr.write(
- "set_show_status_info_in_auxiliary_text(%s, update_dconf = %s)\n"
+ "set_show_status_info_in_auxiliary_text"
+ + "(%s, update_dconf = %s)\n"
%(mode, update_dconf))
if mode == self._show_status_info_in_auxiliary_text:
return
@@ -2596,8 +2597,10 @@ class TypingBoosterEngine(IBus.Engine):
if (key.msymbol not in ('G- ',)
and (key.val in (IBus.KEY_space, IBus.KEY_Tab,
IBus.KEY_Return, IBus.KEY_KP_Enter,
- IBus.KEY_Right, IBus.KEY_KP_Right, IBus.KEY_Delete,
- IBus.KEY_Left, IBus.KEY_KP_Left, IBus.KEY_BackSpace,
+ IBus.KEY_Right, IBus.KEY_KP_Right,
+ IBus.KEY_Delete,
+ IBus.KEY_Left, IBus.KEY_KP_Left,
+ IBus.KEY_BackSpace,
IBus.KEY_Down, IBus.KEY_KP_Down,
IBus.KEY_Up, IBus.KEY_KP_Up,
IBus.KEY_Page_Down, IBus.KEY_KP_Page_Down,
@@ -2716,7 +2719,8 @@ class TypingBoosterEngine(IBus.Engine):
+ 'commit string unexpectedly empty.\n')
return self._return_false(key.val, key.code, key.state)
self._commit_string(commit_string, input_phrase=input_phrase)
- if key.val in (IBus.KEY_Left, IBus.KEY_KP_Left, IBus.KEY_BackSpace):
+ if (key.val
+ in (IBus.KEY_Left, IBus.KEY_KP_Left, IBus.KEY_BackSpace)):
# After committing, the cursor is at the right side of
# the committed string. When the string has been
# committed because of arrow-left or
diff --git a/pylintrc b/pylintrc
index 31e9afe..84a50a7 100644
--- a/pylintrc
+++ b/pylintrc
@@ -242,7 +242,7 @@ max-statements=200
max-parents=7
# Maximum number of attributes for a class (see R0902).
-max-attributes=50
+max-attributes=100
# Minimum number of public methods for a class (see R0903).
min-public-methods=0
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit a4c661e69b0cddbf0f89ebbde371c76283e9f989
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Jan 19 05:44:41 2017 +0100
Wrong variable ���page_size��� was used in set_lookup_table_orientation()
So the orientation was not saved correctly to dconf.
>---------------------------------------------------------------
engine/hunspell_table.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/engine/hunspell_table.py b/engine/hunspell_table.py
index 315bc1c..3a36e4c 100644
--- a/engine/hunspell_table.py
+++ b/engine/hunspell_table.py
@@ -2147,7 +2147,7 @@ class TypingBoosterEngine(IBus.Engine):
self._config.set_value(
self._config_section,
'lookuptableorientation',
- GLib.Variant.new_int32(page_size))
+ GLib.Variant.new_int32(orientation))
def get_lookup_table_orientation(self):
'''Returns the current orientation of the lookup table
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : master
>---------------------------------------------------------------
commit 7fae38b8b7b9501f82205a5db69ac0115f5dd325
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Wed Jan 18 20:56:40 2017 +0100
Do not try to reopen the pre��dit when any modifier except CapsLock is on
Resolves: rhbz#1414642 - Weird stuff happens when trying to reopen a pre��dit of ibus-typing-booster with Left, Right, Backspace, or Delete and any modifier key like Shift, Control, Alt, Meta pressed at the same time.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1414642
>---------------------------------------------------------------
engine/hunspell_table.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/engine/hunspell_table.py b/engine/hunspell_table.py
index 87e8db8..d665157 100644
--- a/engine/hunspell_table.py
+++ b/engine/hunspell_table.py
@@ -121,10 +121,25 @@ class KeyEvent:
self.name = IBus.keyval_name(self.val)
self.unicode = IBus.keyval_to_unicode(self.val)
self.msymbol = self.unicode
+ self.shift = self.state & IBus.ModifierType.SHIFT_MASK != 0
+ self.lock = self.state & IBus.ModifierType.LOCK_MASK != 0
self.control = self.state & IBus.ModifierType.CONTROL_MASK != 0
self.mod1 = self.state & IBus.ModifierType.MOD1_MASK != 0
+ self.mod2 = self.state & IBus.ModifierType.MOD2_MASK != 0
+ self.mod3 = self.state & IBus.ModifierType.MOD3_MASK != 0
+ self.mod4 = self.state & IBus.ModifierType.MOD4_MASK != 0
self.mod5 = self.state & IBus.ModifierType.MOD5_MASK != 0
+ self.button1 = self.state & IBus.ModifierType.BUTTON1_MASK != 0
+ self.button2 = self.state & IBus.ModifierType.BUTTON2_MASK != 0
+ self.button3 = self.state & IBus.ModifierType.BUTTON3_MASK != 0
+ self.button4 = self.state & IBus.ModifierType.BUTTON4_MASK != 0
+ self.button5 = self.state & IBus.ModifierType.BUTTON5_MASK != 0
+ self.super = self.state & IBus.ModifierType.SUPER_MASK != 0
+ self.hyper = self.state & IBus.ModifierType.HYPER_MASK != 0
+ self.meta = self.state & IBus.ModifierType.META_MASK != 0
self.release = self.state & IBus.ModifierType.RELEASE_MASK != 0
+ # MODIFIER_MASK: Modifier mask for the all the masks above
+ self.modifier = self.state & IBus.ModifierType.MODIFIER_MASK != 0
if itb_util.is_ascii(self.msymbol):
if self.control:
self.msymbol = 'C-' + self.msymbol
@@ -1743,6 +1758,41 @@ class TypingBoosterEngine(IBus.Engine):
# surrounding text is probably from the previously
# focused window (bug!), don���t use it.
return self._return_false(key.val, key.code, key.state)
+ if (key.shift
+ or key.control
+ or key.mod1
+ or key.mod2
+ or key.mod3
+ or key.mod4
+ or key.mod5
+ or key.button1
+ or key.button2
+ or key.button3
+ or key.button4
+ or key.button5
+ or key.super
+ or key.hyper
+ or key.meta):
+ # ���Control+Left��� usually positions the cursor one word to
+ # the left in most programs. I.e. after Control+Left the
+ # cursor usually ends up at the left side of a word.
+ # Therefore, one cannot use the same code for reopening
+ # the pre��dit as for just ���Left���. There are similar
+ # problems with ���Alt+Left���, ���Shift+Left���.
+ #
+ # ���Left���, ���Right���, ���Backspace���, ���Delete��� also have similar
+ # problems together with ���Control���, ���Alt���, or ���Shift��� in
+ # many programs. For example ���Shift+Left��� marks (selects)
+ # a region in gedit.
+ #
+ # Maybe better don���t try to reopen the pre��dit at all if
+ # any modifier key is on.
+ #
+ # *Except* for CapsLock. CapsLock causes no problems at
+ # all for reopening the pre��dit, so we don���t want to check
+ # for key.modifier which would include key.lock but check
+ # for the modifiers which cause problems individually.
+ return self._return_false(key.val, key.code, key.state)
if key.val in (IBus.KEY_BackSpace, IBus.KEY_Left, IBus.KEY_KP_Left):
pattern = re.compile(
r'(^|.*[\s]+)(?P<token>[\S]+)[\s]$')