[ibus-typing-booster] miketmp-debug: Add optional debug code (3c0ef49)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 3c0ef490cb3d9c454a074eb68fe2baf1b82a35d7
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Wed Jun 12 15:55:07 2013 +0200
Add optional debug code
>---------------------------------------------------------------
ibus-typing-booster/engine/factory.py | 1 +
ibus-typing-booster/engine/hunspell_suggest.py | 22 ++++++
ibus-typing-booster/engine/hunspell_table.py | 68 +++++++++++++++++-
ibus-typing-booster/engine/tabsqlitedb.py | 90 ++++++++++++++++++++++++
4 files changed, 178 insertions(+), 3 deletions(-)
diff --git a/ibus-typing-booster/engine/factory.py b/ibus-typing-booster/engine/factory.py
index 84e64d6..3b61ebf 100755
--- a/ibus-typing-booster/engine/factory.py
+++ b/ibus-typing-booster/engine/factory.py
@@ -23,6 +23,7 @@ import hunspell_table
import tabsqlitedb
import os
import re
+import sys
from gettext import dgettext
_ = lambda a : dgettext ("ibus-typing-booster", a)
diff --git a/ibus-typing-booster/engine/hunspell_suggest.py b/ibus-typing-booster/engine/hunspell_suggest.py
index d373277..e617b6e 100755
--- a/ibus-typing-booster/engine/hunspell_suggest.py
+++ b/ibus-typing-booster/engine/hunspell_suggest.py
@@ -22,6 +22,8 @@ import sys
import unicodedata
import re
+debug_level = int(0)
+
import_enchant_successful = False
import_hunspell_successful = False
try:
@@ -47,6 +49,9 @@ normalization_form_internal = 'NFD'
class Dictionary:
def __init__(self, name=u'en_US'):
+ if debug_level > 1:
+ sys.stderr.write(
+ "Dictionary.__init__(name=%s)" %name)
self.loc = '/usr/share/myspell'
self.name = name
self.encoding = 'UTF-8'
@@ -104,11 +109,24 @@ class Dictionary:
class Hunspell:
def __init__(self, dictionary_names=['en_US']):
+ global debug_level
+ try:
+ debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
+ except:
+ debug_level = int(0)
+ if debug_level > 1:
+ sys.stderr.write(
+ "Hunspell.__init__(dictionary_names=%s)\n"
+ %dictionary_names)
self.dictionary_names = dictionary_names
self.dictionaries = []
self.load_dictionaries()
def load_dictionaries(self):
+ if debug_level > 1:
+ sys.stderr.write(
+ "Hunspell.load_dictionaries() dictionary_names=%s\n"
+ %self.dictionary_names)
for dictionary_name in self.dictionary_names:
self.dictionaries.append(Dictionary(name=dictionary_name))
@@ -124,6 +142,10 @@ class Hunspell:
return []
if type(input_phrase) != type(u''):
input_phrase = input_phrase.decode('utf8')
+ if debug_level > 1:
+ sys.stderr.write(
+ "Hunspell.suggest() input_phrase=%(ip)s\n"
+ %{'ip': input_phrase.encode('UTF-8')})
# http://pwet.fr/man/linux/fichiers_speciaux/hunspell says:
#
# > A dictionary file (*.dic) contains a list of words, one per
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 2a85b0d..162b658 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -87,6 +87,8 @@ class editor(object):
'''Hold user inputs chars and preedit string'''
def __init__ (self, config, database):
+ if debug_level > 1:
+ sys.stderr.write("editor __init__()\n")
self.db = database
self._config = config
self._name = self.db.ime_properties.get('name')
@@ -143,6 +145,10 @@ class editor(object):
# using m17n transliteration
self.trans_m17n_mode = True
try:
+ if debug_level > 1:
+ sys.stderr.write(
+ "calling Transliterator.get(%(m17n)s, %(cur)s)\n"
+ %{'m17n': self._m17ndb, 'cur': self._current_ime})
self.trans = Transliterator.get(self._m17ndb, self._current_ime)
except:
import traceback
@@ -173,12 +179,36 @@ class editor(object):
'NFKD', self._transliterated_string)
else:
self._transliterated_string = self._typed_string
+ if debug_level > 1:
+ sys.stderr.write(
+ "update_transliterated_string() self._typed_string=%s\n"
+ %self._typed_string.encode('UTF-8'))
+ sys.stderr.write(
+ "update_transliterated_string() repr(self._typed_string)=%s\n"
+ %repr(self._typed_string))
+ sys.stderr.write(
+ "update_transliterated_string() "
+ + "self._transliterated_string=%s\n"
+ %self._transliterated_string.encode('UTF-8'))
+ sys.stderr.write(
+ "update_transliterated_string() "
+ + "repr(self._transliterated_string)=%s\n"
+ %repr(self._transliterated_string))
def get_transliterated_string(self):
return self._transliterated_string
def insert_string_at_cursor(self, string_to_insert):
'''Insert typed string at cursor position'''
+ if debug_level > 1:
+ sys.stderr.write("insert_string_at_cursor() string_to_insert=%s\n"
+ %string_to_insert.encode('UTF-8'))
+ sys.stderr.write("insert_string_at_cursor() "
+ + "self._typed_string=%s\n"
+ %self._typed_string.encode('UTF-8'))
+ sys.stderr.write("insert_string_at_cursor() "
+ + "self._typed_string_cursor=%s\n"
+ %self._typed_string_cursor)
self._typed_string = self._typed_string[:self._typed_string_cursor] \
+string_to_insert \
+self._typed_string[self._typed_string_cursor:]
@@ -334,6 +364,9 @@ class editor(object):
def update_candidates (self):
'''Update lookuptable'''
+ if debug_level > 1:
+ sys.stderr.write("update_candidates() self._typed_string=%s\n"
+ %self._typed_string.encode('UTF-8'))
if self._typed_string == self._typed_string_when_update_candidates_was_last_called:
# The input did not change since we came here last, do nothing and leave
# candidates and lookup table unchanged:
@@ -511,13 +544,15 @@ class tabengine (IBus.Engine):
'''The IM Engine for Tables'''
def __init__ (self, bus, obj_path, db ):
- super(tabengine, self).__init__(
- connection=bus.get_connection(),object_path=obj_path)
global debug_level
try:
debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
except:
debug_level = int(0)
+ if debug_level > 1:
+ sys.stderr.write("tabengine.__init__() obj_path=%s\n" %obj_path)
+ super(tabengine, self).__init__(
+ connection=bus.get_connection(), object_path=obj_path)
self._input_purpose = 0
self._has_input_purpose = False
if hasattr(IBus, 'InputPurpose'):
@@ -623,6 +658,8 @@ class tabengine (IBus.Engine):
def _change_mode (self):
'''Shift input mode, TAB -> EN -> TAB
'''
+ if debug_level > 1:
+ sys.stderr.write("tabengine._change_mode()\n")
self.reset ()
self._update_ui ()
@@ -807,8 +844,18 @@ class tabengine (IBus.Engine):
'''
if self._has_input_purpose and self._input_purpose in [IBus.InputPurpose.PASSWORD, IBus.InputPurpose.PIN]:
return False
-
+ if debug_level > 1:
+ sys.stderr.write(
+ "do_process_key_event(keyval=%(kv)s, "
+ + "keycode=%(kc)s, state=%(st)s)\n"
+ %{'kv': keyval, 'kc': keycode, 'st': state})
key = KeyEvent(keyval, keycode, state)
+ if debug_level > 1:
+ sys.stderr.write(
+ "process_key_event() after KeyEvent() "
+ + "key.val=%(kval)s "
+ + "IBus.keyval_to_unicode(key.val)=%(uc)s\n"
+ %{'kval': key.val, 'uc': IBus.keyval_to_unicode(key.code)})
# ignore NumLock mask
key.state &= ~IBus.ModifierType.MOD2_MASK
@@ -829,6 +876,17 @@ class tabengine (IBus.Engine):
return True
if self._editor.is_empty ():
+ if debug_level > 1:
+ sys.stderr.write(
+ "_process_key_event() self._editor.is_empty ():\n")
+ sys.stderr.write(
+ "key.val=%(key.val)s "
+ + "IBus.keyval_to_unicode(key.val)=%(keychar)s\n"
+ %{'key.val': key.val,
+ 'keychar': IBus.keyval_to_unicode(key.val)})
+ sys.stderr.write(
+ "IBus.keyval_name(key.val)=%s\n"
+ %IBus.keyval_name(key.val))
# This is the first character typed since the last commit
# there is nothing in the preëdit yet.
if key.val < 32:
@@ -1120,6 +1178,10 @@ class tabengine (IBus.Engine):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
+ if debug_level > 1:
+ sys.stderr.write(
+ "MOD5_MASK=%(bit)s\n"
+ %{'bit': key.state & IBus.ModifierType.MOD5_MASK})
self._editor.insert_string_at_cursor(typed_character)
if typed_character and unicodedata.category(typed_character) in itb_util.categories_to_trigger_immediate_commit:
input_phrase = self._editor.get_transliterated_string()
diff --git a/ibus-typing-booster/engine/tabsqlitedb.py b/ibus-typing-booster/engine/tabsqlitedb.py
index 78a4b26..e382d82 100755
--- a/ibus-typing-booster/engine/tabsqlitedb.py
+++ b/ibus-typing-booster/engine/tabsqlitedb.py
@@ -29,6 +29,8 @@ import re
import itb_util
import hunspell_suggest
+debug_level = int(0)
+
user_database_version = '0.65'
class ImeProperties:
@@ -80,6 +82,13 @@ class tabsqlitedb:
user_freq >= 1: The number of times the user has used this phrase
'''
def __init__(self, config_filename=None):
+ global debug_level
+ try:
+ debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
+ except:
+ debug_level = int(0)
+ if debug_level > 1:
+ sys.stderr.write("tabsqlitedb.__init__()")
self._phrase_table_column_names = ['id', 'input_phrase', 'phrase', 'p_phrase', 'pp_phrase', 'user_freq', 'timestamp']
self.old_phrases=[]
@@ -241,6 +250,11 @@ class tabsqlitedb:
'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase,
'timestamp': time.time()}
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.update_phrase() sqlstr=%s\n" %sqlstr)
+ sys.stderr.write(
+ "tabsqlitedb.update_phrase() sqlargs=%s\n" %sqlargs)
try:
self.db.execute(sqlstr, sqlargs)
if commit:
@@ -253,8 +267,16 @@ class tabsqlitedb:
'''
Trigger a checkpoint operation.
'''
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.sync_userdb() "
+ + "commit and execute checkpoint ...\n")
self.db.commit()
self.db.execute('PRAGMA wal_checkpoint;')
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.sync_userdb() "
+ + "commit and execute checkpoint done.\n")
def create_tables (self, database):
'''Create table for the phrases.'''
@@ -269,6 +291,17 @@ class tabsqlitedb:
'''
Add phrase to database
'''
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.add_phrase() "
+ + "input_phrase=%(ip)s "
+ + "phrase=%(p)s "
+ + "user_freq=%(uf)s "
+ + "database=%(db)s\n"
+ %{'ip': input_phrase.encode('UTF-8'),
+ 'p': phrase.encode('UTF-8'),
+ 'uf': user_freq,
+ 'db': database})
if not input_phrase or not phrase:
return
input_phrase = unicodedata.normalize(
@@ -299,6 +332,11 @@ class tabsqlitedb:
insert_sqlargs = {'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase,
'user_freq': user_freq, 'timestamp': time.time()}
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.add_phrase() insert_sqlstr=%s\n" %insert_sqlstr)
+ sys.stderr.write(
+ "tabsqlitedb.add_phrase() insert_sqlargs=%s\n" %insert_sqlargs)
try:
self.db.execute (insert_sqlstr, insert_sqlargs)
if commit:
@@ -368,9 +406,22 @@ class tabsqlitedb:
self._normalization_form_internal, p_phrase)
pp_phrase = unicodedata.normalize(
self._normalization_form_internal, pp_phrase)
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() "
+ + "input_phrase=%(ip)s "
+ + "p_phrase=%(p)s "
+ + "pp_phrase=%(pp)s\n"
+ %{'ip': input_phrase.encode('UTF-8'),
+ 'p': p_phrase.encode('UTF-8'),
+ 'pp': pp_phrase.encode('UTF-8')})
phrase_frequencies = {}
for x in self.hunspell_obj.suggest(input_phrase):
phrase_frequencies.update([(x, 0)])
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() hunspell: best_candidates=%s\n"
+ %self.best_candidates(phrase_frequencies))
# Now phrase_frequencies might contain something like this:
#
# {u'code': 0, u'communicability': 0, u'cold': 0, u'colour': 0}
@@ -437,6 +488,10 @@ class tabsqlitedb:
# {u'conspiracy': 6/11, u'code': 0, u'communicability': 0, u'cold': 1/11, u'colour': 4/11}
for x in results_uni:
phrase_frequencies.update([(x[0], x[1]/float(count))])
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() Unigram best_candidates=%s\n"
+ %self.best_candidates(phrase_frequencies))
if not p_phrase:
# If no context for bigram matching is available, return what we have so far:
return self.best_candidates(phrase_frequencies)
@@ -461,6 +516,10 @@ class tabsqlitedb:
# both the weight of 0.5:
for x in results_bi:
phrase_frequencies.update([(x[0], 0.5*x[1]/float(count_p_phrase)+0.5*phrase_frequencies[x[0]])])
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() Bigram best_candidates=%s\n"
+ %self.best_candidates(phrase_frequencies))
if not pp_phrase:
# If no context for trigram matching is available, return what we have so far:
return self.best_candidates(phrase_frequencies)
@@ -487,6 +546,10 @@ class tabsqlitedb:
# get higher weight):
for x in results_tri:
phrase_frequencies.update([(x[0], 0.5*x[1]/float(count_pp_phrase_p_phrase)+0.5*phrase_frequencies[x[0]])])
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.select_words() Trigram best_candidates=%s\n"
+ %self.best_candidates(phrase_frequencies))
return self.best_candidates(phrase_frequencies)
def generate_userdb_desc (self):
@@ -592,6 +655,16 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
input_phrase = unicodedata.normalize(
self._normalization_form_internal, input_phrase)
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.check_phrase_and_update_frequency() "
+ + "phrase=%(p)s, "
+ + "input_phrase=%(t)s, "
+ + "database=%(d)s\n"
+ %{'p': phrase.encode('UTF-8'),
+ 't': input_phrase.encode('UTF-8'),
+ 'd': database})
+
# There should never be more than 1 database row for the same
# input_phrase *and* phrase. So the following query on
# the database should match at most one database
@@ -608,7 +681,17 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
;'''
sqlargs = {'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase}
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.check_phrase_and_update_frequency() sqlstr=%s\n"
+ %sqlstr)
+ sys.stderr.write(
+ "tabsqlitedb.check_phrase_and_update_frequency() sqlargs=%s\n"
+ %sqlargs)
result = self.db.execute(sqlstr, sqlargs).fetchall()
+ if debug_level > 1:
+ sys.stderr.write(
+ "check_phrase_and_update_frequency() result=%s\n" %result)
if len(result) > 0:
# A match was found in user_db, increase user frequency by 1
self.update_phrase(input_phrase = input_phrase,
@@ -630,6 +713,13 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
Or, if “input_phrase” is “None”, remove all rows matching “phrase”
no matter for what input phrase from the database.
'''
+ if debug_level > 1:
+ sys.stderr.write(
+ "tabsqlitedb.remove_phrase() phrase=%(p)s\n"
+ %{'p': phrase.encode('UTF-8')})
+ sys.stderr.write(
+ "tabsqlitedb.remove_phrase() database=%s\n"
+ %database)
if not phrase:
return
phrase = unicodedata.normalize(
8 years, 7 months
[ibus-typing-booster] miketmp-debug: WIP: usage experiment: de_DE & en_GB dictionary (4ea0cc0)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 4ea0cc036fc88dca65df408f14c7a7c531174ac6
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Fri Jan 17 14:52:04 2014 +0100
WIP: usage experiment: de_DE & en_GB dictionary
>---------------------------------------------------------------
ibus-typing-booster/hunspell-tables/de_DE.conf | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/ibus-typing-booster/hunspell-tables/de_DE.conf b/ibus-typing-booster/hunspell-tables/de_DE.conf
index 0f8251d..b7adbb2 100644
--- a/ibus-typing-booster/hunspell-tables/de_DE.conf
+++ b/ibus-typing-booster/hunspell-tables/de_DE.conf
@@ -7,7 +7,7 @@ language = de
author = Mike FABIAN <mfabian(a)redhat.com>
status_prompt = de
layout = default
-hunspell_dict = de_DE.dic
+hunspell_dict = de_DE.dic, en_GB.dic
hunspell_dict_package = hunspell-de
ime_name = German - DE (Hunspell)
symbol = de-DE
8 years, 7 months
[ibus-typing-booster] miketmp-debug: MOD5 experiment (223f032)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 223f0322d79c436848fd0520e8100307c169a6c0
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Feb 20 08:17:03 2014 +0100
MOD5 experiment
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 3 ++-
ibus-typing-booster/hunspell-tables/mr_IN.conf | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 162b658..db4559d 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -940,7 +940,8 @@ class tabengine (IBus.Engine):
if (key.val >= 32
and (not (key.state & (
IBus.ModifierType.MOD1_MASK
- | IBus.ModifierType.CONTROL_MASK)))):
+ | IBus.ModifierType.CONTROL_MASK
+ | IBus.ModifierType.MOD5_MASK)))):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
diff --git a/ibus-typing-booster/hunspell-tables/mr_IN.conf b/ibus-typing-booster/hunspell-tables/mr_IN.conf
index 9f644dd..3c2b675 100644
--- a/ibus-typing-booster/hunspell-tables/mr_IN.conf
+++ b/ibus-typing-booster/hunspell-tables/mr_IN.conf
@@ -6,7 +6,7 @@ description = This is a Marathi typing booster engine table for Marathi language
language = mr
author = Anish Patil <apatil(a)redhat.com>
status_prompt = mr
-layout = default
+layout = default[lv3:ralt_switch]
hunspell_dict = mr_IN.dic
hunspell_dict_package = hunspell-mr
ime_name = Marathi - IN (Hunspell)
8 years, 7 months
[ibus-typing-booster] miketmp-debug: Fix pylint warnings (31a3c88)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 31a3c886c26d62796c94ee2924a3139cfbeec5d5
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Sep 24 14:11:06 2015 +0200
Fix pylint warnings
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 211 +++++++++++++++++---------
1 files changed, 142 insertions(+), 69 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 598f3a8..2a85b0d 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -25,7 +25,6 @@ import os
import sys
import string
import unicodedata
-import curses.ascii
import re
from gi.repository import IBus
from gi.repository import GLib
@@ -67,7 +66,10 @@ def variant_to_value(variant):
return variant
def argb(a, r, g, b):
- return ((a & 0xff)<<24) + ((r & 0xff) << 16) + ((g & 0xff) << 8) + (b & 0xff)
+ return (((a & 0xff)<<24)
+ + ((r & 0xff) << 16)
+ + ((g & 0xff) << 8)
+ + (b & 0xff))
def rgb(r, g, b):
return argb(255, r, g, b)
@@ -129,7 +131,8 @@ class editor(object):
self._current_ime = variant_to_value(self._config.get_value(
self._config_section,
'inputmethod'))
- if self._current_ime == None or not self._current_ime in self._supported_imes:
+ if (self._current_ime == None
+ or not self._current_ime in self._supported_imes):
# There is no ime set in dconf or an unsupported ime, fall
# back to the first of the supported imes:
self._current_ime = self._supported_imes[0]
@@ -140,7 +143,6 @@ class editor(object):
# using m17n transliteration
self.trans_m17n_mode = True
try:
- #self.trans = Translit.Transliterator.get(self._m17ndb, self._current_ime)
self.trans = Transliterator.get(self._m17ndb, self._current_ime)
except:
import traceback
@@ -164,7 +166,8 @@ class editor(object):
self._transliterated_string = self.trans.transliterate(
self._typed_string)[0]
if type(self._transliterated_string) != type(u''):
- self._transliterated_string = self._transliterated_string.decode('UTF-8')
+ self._transliterated_string = (
+ self._transliterated_string.decode('UTF-8'))
if self._current_ime in ['ko-romaja', 'ko-han2']:
self._transliterated_string = unicodedata.normalize(
'NFKD', self._transliterated_string)
@@ -201,8 +204,9 @@ class editor(object):
def remove_character_before_cursor(self):
'''Remove typed character before cursor'''
if self._typed_string_cursor > 0:
- self._typed_string = self._typed_string[:self._typed_string_cursor-1] \
- +self._typed_string[self._typed_string_cursor:]
+ self._typed_string = (
+ self._typed_string[:self._typed_string_cursor-1]
+ +self._typed_string[self._typed_string_cursor:])
self._typed_string_cursor -= 1
self.update_transliterated_string()
self.update_candidates()
@@ -210,8 +214,9 @@ class editor(object):
def remove_character_after_cursor(self):
'''Remove typed character after cursor'''
if self._typed_string_cursor < len(self._typed_string):
- self._typed_string = self._typed_string[:self._typed_string_cursor] \
- +self._typed_string[self._typed_string_cursor+1:]
+ self._typed_string = (
+ self._typed_string[:self._typed_string_cursor]
+ +self._typed_string[self._typed_string_cursor+1:])
self.update_transliterated_string()
self.update_candidates()
@@ -260,9 +265,11 @@ class editor(object):
transliterated_string_up_to_cursor = self.trans.transliterate(
self._typed_string[:self._typed_string_cursor])[0]
if type(transliterated_string_up_to_cursor) != type(u''):
- transliterated_string_up_to_cursor = transliterated_string_up_to_cursor.decode('UTF-8')
+ transliterated_string_up_to_cursor = (
+ transliterated_string_up_to_cursor.decode('UTF-8'))
else:
- transliterated_string_up_to_cursor = self._typed_string[:self._typed_string_cursor]
+ transliterated_string_up_to_cursor = (
+ self._typed_string[:self._typed_string_cursor])
if self._current_ime in ['ko-romaja', 'ko-han2']:
transliterated_string_up_to_cursor = unicodedata.normalize(
'NFKD', transliterated_string_up_to_cursor)
@@ -287,7 +294,8 @@ class editor(object):
if not phrase:
return
phrase = unicodedata.normalize('NFC', phrase)
- transliterated_string = unicodedata.normalize('NFC', self._transliterated_string)
+ transliterated_string = unicodedata.normalize(
+ 'NFC', self._transliterated_string)
attrs = IBus.AttrList ()
if not phrase.startswith(transliterated_string):
# this is a candidate which does not start exactly
@@ -295,17 +303,23 @@ class editor(object):
# for a spelling correction:
if debug_level > 0:
phrase = phrase + u' ✓'
- attrs.append(IBus.attr_foreground_new(rgb(0xff,0x00,0x00), 0, len(phrase)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0xff, 0x00, 0x00), 0, len(phrase)))
elif user_freq > 10:
# this is a frequently used phrase:
- attrs.append(IBus.attr_foreground_new(rgb(0xff,0x7f,0x00), 0, len(phrase)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0xff, 0x7f, 0x00), 0, len(phrase)))
else:
- # this is a system phrase that has been used less then 10 times or maybe never:
- attrs.append(IBus.attr_foreground_new(rgb(0x00,0x00,0x00), 0, len(phrase)))
+ # this is a system phrase that has been used less
+ # then 10 times or maybe never:
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x00, 0x00, 0x00), 0, len(phrase)))
if debug_level > 0:
phrase += u' ' + str(user_freq)
attrs.append(IBus.attr_foreground_new(
- rgb(0x00,0xff,0x00), len(phrase) - len(str(user_freq)), len(phrase)))
+ rgb(0x00, 0xff, 0x00),
+ len(phrase) - len(str(user_freq)),
+ len(phrase)))
text = IBus.Text.new_from_string(phrase)
i = 0
while attrs.get(i) != None:
@@ -331,21 +345,29 @@ class editor(object):
prefix_length = 0
prefix = u''
if self._transliterated_string:
- stripped_transliterated_string = itb_util.lstrip_token(self._transliterated_string)
+ stripped_transliterated_string = (
+ itb_util.lstrip_token(self._transliterated_string))
if len(stripped_transliterated_string) >= self._min_char_complete:
- prefix_length = len(self._transliterated_string) - len(stripped_transliterated_string)
+ prefix_length = (
+ len(self._transliterated_string)
+ - len(stripped_transliterated_string))
if prefix_length:
prefix = self._transliterated_string[0:prefix_length]
try:
- self._candidates = self.db.select_words(stripped_transliterated_string, p_phrase=self._p_phrase, pp_phrase=self._pp_phrase)
+ self._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 self._candidates:
if prefix:
- self._candidates = [(prefix+x[0], x[1]) for x in self._candidates]
+ 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])
+ self.append_candidate_to_lookup_table(
+ phrase=x[0], user_freq=x[1])
return True
def arrow_down(self):
@@ -421,7 +443,7 @@ class editor(object):
return u''
return self._candidates[index][0]
- def alt_number (self,index):
+ def alt_number (self, index):
'''Remove the phrase selected with Alt+Number from the user database.
The index parameter should start from 0.
@@ -453,7 +475,8 @@ class editor(object):
if len (self._candidates) > real_index:
# this index is valid
can = self._candidates[real_index]
- self.db.remove_phrase(phrase=can[0], database='user_db', commit=True)
+ self.db.remove_phrase(
+ phrase=can[0], database='user_db', commit=True)
# call update_candidates() to get a new SQL query. The
# input has not really changed, therefore we must clear
# the remembered list of transliterated characters to
@@ -488,7 +511,8 @@ class tabengine (IBus.Engine):
'''The IM Engine for Tables'''
def __init__ (self, bus, obj_path, db ):
- super(tabengine,self).__init__ (connection=bus.get_connection(),object_path=obj_path)
+ super(tabengine, self).__init__(
+ connection=bus.get_connection(),object_path=obj_path)
global debug_level
try:
debug_level = int(os.getenv('IBUS_TYPING_BOOSTER_DEBUG_LEVEL'))
@@ -516,16 +540,19 @@ class tabengine (IBus.Engine):
if tabengine._page_size > 9:
tabengine._page_size = 9 # maximum page size supported
- self._show_number_of_candidates = variant_to_value(self._config.get_value(
+ self._show_number_of_candidates = variant_to_value(
+ self._config.get_value(
self._config_section,
'shownumberofcandidates'))
if self._show_number_of_candidates == None:
self._show_number_of_candidates = False
- self._icon_dir = '%s%s%s%s' % (os.getenv('IBUS_HUNSPELL_TABLE_LOCATION'),
- os.path.sep, 'icons', os.path.sep)
+ self._icon_dir = '%s%s%s%s' % (
+ os.getenv('IBUS_HUNSPELL_TABLE_LOCATION'),
+ os.path.sep, 'icons', os.path.sep)
- self._status = self.db.ime_properties.get('status_prompt').encode('utf8')
+ self._status = self.db.ime_properties.get(
+ 'status_prompt').encode('utf8')
self._page_down_keys = [IBus.KEY_Page_Down, IBus.KEY_KP_Page_Down]
self._page_up_keys = [IBus.KEY_Page_Up, IBus.KEY_KP_Page_Up]
@@ -591,7 +618,7 @@ class tabengine (IBus.Engine):
def do_destroy(self):
self.reset ()
self.do_focus_out ()
- super(tabengine,self).destroy()
+ super(tabengine, self).destroy()
def _change_mode (self):
'''Shift input mode, TAB -> EN -> TAB
@@ -602,13 +629,17 @@ class tabengine (IBus.Engine):
def _update_preedit (self):
'''Update Preedit String in UI'''
# editor.get_caret() should also use NFC!
- _str = unicodedata.normalize('NFC', self._editor.get_transliterated_string())
+ _str = unicodedata.normalize(
+ 'NFC', self._editor.get_transliterated_string())
if _str == u'':
- super(tabengine, self).update_preedit_text(IBus.Text.new_from_string(u''), 0, False)
+ super(tabengine, self).update_preedit_text(
+ IBus.Text.new_from_string(u''), 0, False)
else:
attrs = IBus.AttrList()
- attrs.append(IBus.attr_foreground_new(rgb(0x0e,0x0e,0xa0), 0, len(_str)))
- attrs.append(IBus.attr_underline_new(IBus.AttrUnderline.SINGLE, 0, len(_str)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x0e, 0x0e, 0xa0), 0, len(_str)))
+ attrs.append(IBus.attr_underline_new(
+ IBus.AttrUnderline.SINGLE, 0, len(_str)))
text = IBus.Text.new_from_string(_str)
i = 0
while attrs.get(i) != None:
@@ -618,22 +649,31 @@ class tabengine (IBus.Engine):
attr.get_start_index(),
attr.get_end_index())
i += 1
- super(tabengine, self).update_preedit_text(text, self._editor.get_caret(), True)
+ super(tabengine, self).update_preedit_text(
+ text, self._editor.get_caret(), True)
def _update_aux (self):
'''Update Aux String in UI'''
- aux_string = u'(%d / %d)' % (self._editor._lookup_table.get_cursor_pos() + 1,
- self._editor._lookup_table.get_number_of_candidates())
+ aux_string = u'(%d / %d)' % (
+ self._editor._lookup_table.get_cursor_pos() + 1,
+ self._editor._lookup_table.get_number_of_candidates())
if aux_string:
# Colours do not work at the moment in the auxiliary text!
# Needs fix in ibus.
attrs = IBus.AttrList()
- attrs.append(IBus.attr_foreground_new(rgb(0x95,0x15,0xb5),0,len(aux_string)))
+ attrs.append(IBus.attr_foreground_new(
+ rgb(0x95, 0x15, 0xb5),
+ 0,
+ len(aux_string)))
if debug_level > 0:
- context = u' ' + self._editor._pp_phrase + u' ' + self._editor._p_phrase
+ context = (
+ u' ' + self._editor._pp_phrase
+ + u' ' + self._editor._p_phrase)
aux_string += context
attrs.append(IBus.attr_foreground_new(
- rgb(0x00,0xff,0x00),len(aux_string)-len(context), len(aux_string)))
+ rgb(0x00, 0xff, 0x00),
+ len(aux_string)-len(context),
+ len(aux_string)))
text = IBus.Text.new_from_string(aux_string)
i = 0
while attrs.get(i) != None:
@@ -644,9 +684,10 @@ class tabengine (IBus.Engine):
attr.get_end_index())
i += 1
visible = True
- if self._editor._lookup_table.get_number_of_candidates() == 0 \
- or self._show_number_of_candidates == False \
- or (self._tab_enable and not self.is_lookup_table_enabled_by_tab):
+ if (self._editor._lookup_table.get_number_of_candidates() == 0
+ or self._show_number_of_candidates == False
+ or (self._tab_enable
+ and not self.is_lookup_table_enabled_by_tab)):
visible = False
super(tabengine, self).update_auxiliary_text(text, visible)
else:
@@ -684,7 +725,8 @@ class tabengine (IBus.Engine):
input_phrase = self._editor.get_transliterated_string()
# commit always in NFC:
commit_phrase = unicodedata.normalize('NFC', commit_phrase)
- super(tabengine,self).commit_text(IBus.Text.new_from_string(commit_phrase))
+ super(tabengine, self).commit_text(
+ IBus.Text.new_from_string(commit_phrase))
self._editor.clear_input()
self._update_ui ()
self._commit_happened_after_focus_in = True
@@ -703,8 +745,9 @@ class tabengine (IBus.Engine):
text = text.decode('UTF-8')
cursor_pos = surrounding_text[1]
anchor_pos = surrounding_text[2]
- # The commit_phrase is *not* yet in the surrounding text, it will
- # show up there only when the next key event is processed:
+ # The commit_phrase is *not* yet in the surrounding text,
+ # it will show up there only when the next key event is
+ # processed:
pattern = re.compile(r'(?P<white_space>[\s]+)$', re.UNICODE)
match = pattern.search(text[:cursor_pos])
if match:
@@ -744,7 +787,9 @@ class tabengine (IBus.Engine):
# surrounding text is probably from the previously
# focused window (bug!), don’t use it.
return
- tokens = [itb_util.strip_token(x) for x in itb_util.tokenize(text[:cursor_pos])]
+ tokens = ([
+ itb_util.strip_token(x)
+ for x in itb_util.tokenize(text[:cursor_pos])])
if len(tokens):
self._editor._p_phrase = tokens[-1]
if len(tokens) > 1:
@@ -799,7 +844,8 @@ class tabengine (IBus.Engine):
if key.val in (IBus.KEY_BackSpace,):
# When the end of a word is reached again by typing backspace,
# try to get that word back into preedit:
- if not (self.client_capabilities & IBus.Capabilite.SURROUNDING_TEXT):
+ if not (self.client_capabilities
+ & IBus.Capabilite.SURROUNDING_TEXT):
return False
surrounding_text = self.get_surrounding_text()
text = surrounding_text[0].get_text()
@@ -814,7 +860,8 @@ class tabengine (IBus.Engine):
# surrounding text is probably from the previously
# focused window (bug!), don’t use it.
return False
- pattern = re.compile(r'(^|.*[\s]+)(?P<token>[\S]+)[\s]$', re.UNICODE)
+ pattern = re.compile(
+ r'(^|.*[\s]+)(?P<token>[\S]+)[\s]$', re.UNICODE)
match = pattern.match(text[:cursor_pos])
if not match:
return False
@@ -827,12 +874,15 @@ class tabengine (IBus.Engine):
# back to the application because the whitespace has
# already been deleted.
token = match.group('token')
- self.delete_surrounding_text(-1-len(token),1+len(token))
+ self.delete_surrounding_text(-1-len(token), 1+len(token))
self.get_context()
self._editor.insert_string_at_cursor(token)
self._update_ui()
return True
- if key.val >= 32 and (not (key.state & (IBus.ModifierType.MOD1_MASK | IBus.ModifierType.CONTROL_MASK))):
+ if (key.val >= 32
+ and (not (key.state & (
+ IBus.ModifierType.MOD1_MASK
+ | IBus.ModifierType.CONTROL_MASK)))):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
@@ -840,14 +890,17 @@ class tabengine (IBus.Engine):
# very unlikely to be part of a word
# (e.g. punctuation, a symbol, ..), we might want to
# avoid completion and commit something immediately:
- if typed_character and unicodedata.category(typed_character) in itb_util.categories_to_trigger_immediate_commit:
+ if (typed_character
+ and unicodedata.category(typed_character)
+ in itb_util.categories_to_trigger_immediate_commit):
if not self._editor.trans_m17n_mode:
# Do not just pass the character through,
# commit it properly. For example if it is a
# “.” we might want to remove whitespace
# between the “.” and the previous word and this is
# done in commit_string().
- self.commit_string(typed_character, input_phrase = typed_character)
+ self.commit_string(
+ typed_character, input_phrase = typed_character)
return True
# If transliteration is used, we may need to
# handle a punctuation or symbol character. For
@@ -859,7 +912,8 @@ class tabengine (IBus.Engine):
self._editor.insert_string_at_cursor(typed_character)
self._update_ui()
return True
- if typed_character and unicodedata.digit(typed_character, -1) != -1:
+ if (typed_character
+ and unicodedata.digit(typed_character, -1) != -1):
if not self._editor.trans_m17n_mode:
# If a digit has been typed and no transliteration
# is used, we can pass it through
@@ -872,8 +926,10 @@ class tabengine (IBus.Engine):
transliterated_digit = self._editor.trans.transliterate(
typed_character)[0]
if type(transliterated_digit) != type(u''):
- transliterated_digit = transliterated_digit.decode('utf8')
- self.commit_string(transliterated_digit, input_phrase=transliterated_digit)
+ transliterated_digit = (
+ transliterated_digit.decode('utf8'))
+ self.commit_string(
+ transliterated_digit, input_phrase=transliterated_digit)
return True
if key.val == IBus.KEY_Escape:
@@ -907,21 +963,24 @@ class tabengine (IBus.Engine):
self._update_ui ()
return res
- if key.val in (IBus.KEY_Left, IBus.KEY_KP_Left) and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val in (IBus.KEY_Left, IBus.KEY_KP_Left)
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.control_arrow_left()
self._update_ui()
return True
- if key.val in (IBus.KEY_Right, IBus.KEY_KP_Right) and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val in (IBus.KEY_Right, IBus.KEY_KP_Right)
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.control_arrow_right()
self._update_ui()
return True
- if key.val == IBus.KEY_BackSpace and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val == IBus.KEY_BackSpace
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.remove_string_before_cursor()
@@ -935,7 +994,8 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
- if key.val == IBus.KEY_Delete and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val == IBus.KEY_Delete
+ and key.state & IBus.ModifierType.CONTROL_MASK):
if self._editor.is_empty():
return False
self._editor.remove_string_after_cursor()
@@ -949,18 +1009,27 @@ class tabengine (IBus.Engine):
self._update_ui()
return True
- if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9 and self._editor._candidates and key.state & IBus.ModifierType.CONTROL_MASK:
+ if (key.val >= IBus.KEY_1
+ and key.val <= IBus.KEY_9
+ and self._editor._candidates
+ and key.state & IBus.ModifierType.CONTROL_MASK):
res = self._editor.alt_number (key.val - IBus.KEY_1)
self._update_ui ()
return res
- if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9 and self._editor._candidates and key.state & IBus.ModifierType.MOD1_MASK:
+ if (key.val >= IBus.KEY_1
+ and key.val <= IBus.KEY_9
+ and self._editor._candidates
+ and key.state & IBus.ModifierType.MOD1_MASK):
res = self._editor.alt_number (key.val - IBus.KEY_1)
self._update_ui ()
return res
- if key.val >= IBus.KEY_1 and key.val <= IBus.KEY_9 and self._editor._candidates:
- phrase = self._editor.get_string_from_lookup_table_current_page(key.val - IBus.KEY_1)
+ if (key.val >= IBus.KEY_1
+ and key.val <= IBus.KEY_9
+ and self._editor._candidates):
+ phrase = self._editor.get_string_from_lookup_table_current_page(
+ key.val - IBus.KEY_1)
if phrase:
self.commit_string(phrase + u' ')
return True
@@ -996,7 +1065,8 @@ class tabengine (IBus.Engine):
if self._editor.is_empty():
return False
if key.val in (IBus.KEY_Right, IBus.KEY_KP_Right):
- if self._editor._typed_string_cursor < len(self._editor._typed_string):
+ if (self._editor._typed_string_cursor
+ < len(self._editor._typed_string)):
self._editor._typed_string_cursor += 1
self._update_ui()
return True
@@ -1107,7 +1177,7 @@ class tabengine (IBus.Engine):
# effect of comparing the dconf sections case insentively
# in some locales, it would fail for example if Turkish
# locale (tr_TR.UTF-8) is set.
- if sys.version_info >= (3,0,0): # Python3
+ if sys.version_info >= (3, 0, 0): # Python3
return re.sub(r'[_:]', r'-', section).translate(
''.maketrans(
string.ascii_uppercase,
@@ -1119,9 +1189,11 @@ class tabengine (IBus.Engine):
string.ascii_lowercase).decode('ISO-8859-1'))
def __config_value_changed_cb(self, config, section, name, value):
- if self.config_section_normalize(self._config_section) != self.config_section_normalize(section):
+ if (self.config_section_normalize(self._config_section)
+ != self.config_section_normalize(section)):
return
- print("config value %(n)s for engine %(en)s changed" %{'n': name, 'en': self._name})
+ print("config value %(n)s for engine %(en)s changed"
+ %{'n': name, 'en': self._name})
value = variant_to_value(value)
if name == "tabenable":
if value == 1:
@@ -1157,7 +1229,8 @@ class tabengine (IBus.Engine):
if value != 'NoIme':
print("Switching to transliteration using ime=%s" %value)
self._editor.trans_m17n_mode = True
- self._editor.trans = Transliterator.get(self._editor._m17ndb, value)
+ self._editor.trans = Transliterator.get(
+ self._editor._m17ndb, value)
else:
print("Switching off transliteration.")
self._editor.trans_m17n_mode = False
8 years, 7 months
[ibus-typing-booster] miketmp-debug: Update .pot file and German translations for the new setup property (f561fb9)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit f561fb934fd99b3b69c11f92a180326549f2e710
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Sep 24 13:51:50 2015 +0200
Update .pot file and German translations for the new setup property
>---------------------------------------------------------------
ibus-typing-booster/po/de.po | 15 ++++++++++++---
ibus-typing-booster/po/ibus-typing-booster.pot | 13 +++++++++++--
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/ibus-typing-booster/po/de.po b/ibus-typing-booster/po/de.po
index 50b8ea8..2f81838 100644
--- a/ibus-typing-booster/po/de.po
+++ b/ibus-typing-booster/po/de.po
@@ -10,8 +10,8 @@ msgid ""
msgstr ""
"Project-Id-Version: ibus-typing-booster 0.0.16\n"
"Report-Msgid-Bugs-To: http://code.google.com/p/ibus/issues/entry\n"
-"POT-Creation-Date: 2013-12-20 11:18+0530\n"
-"PO-Revision-Date: 2013-11-14 12:59+0100\n"
+"POT-Creation-Date: 2015-09-24 13:49+0200\n"
+"PO-Revision-Date: 2015-09-24 13:51+0200\n"
"Last-Translator: Mike FABIAN <mfabian(a)redhat.com>\n"
"Language-Team: German <trans-de(a)lists.fedoraproject.org>\n"
"Language: de\n"
@@ -20,6 +20,15 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+#: engine/hunspell_table.py:550
+msgid "Setup"
+msgstr "Einstellungen"
+
+#: engine/hunspell_table.py:552
+#, python-format
+msgid "Configure ibus-typing-booster “%(name)s”"
+msgstr "Ibus Typing Booster \"%(name)s\" Einstellungen"
+
#: setup/main.py:89
#, python-format
msgid "Unknown format of engine name: IBUS_ENGINE_NAME=%(name)s"
@@ -53,7 +62,7 @@ msgstr "Ibus Typing Booster \"%(symbol)s\" Einstellungen"
#: setup/main.py:211
msgid "Another instance of this app is already running."
-msgstr ""
+msgstr "Eine Instanz dieses Programms läuft schon."
#: setup/main.py:295
msgid "Open File ..."
diff --git a/ibus-typing-booster/po/ibus-typing-booster.pot b/ibus-typing-booster/po/ibus-typing-booster.pot
index 839e34b..eebb06e 100644
--- a/ibus-typing-booster/po/ibus-typing-booster.pot
+++ b/ibus-typing-booster/po/ibus-typing-booster.pot
@@ -8,15 +8,24 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://code.google.com/p/ibus/issues/entry\n"
-"POT-Creation-Date: 2013-12-20 11:18+0530\n"
+"POT-Creation-Date: 2015-09-24 13:49+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL(a)li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
+#: engine/hunspell_table.py:550
+msgid "Setup"
+msgstr ""
+
+#: engine/hunspell_table.py:552
+#, python-format
+msgid "Configure ibus-typing-booster “%(name)s”"
+msgstr ""
+
#: setup/main.py:89
#, python-format
msgid "Unknown format of engine name: IBUS_ENGINE_NAME=%(name)s"
8 years, 7 months
[ibus-typing-booster] miketmp-debug: add sys.stderr.write("mike ..." debug messages) (1422342)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 1422342daea3f8f72a69d76acec82f985594f86a
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Wed Jun 12 15:55:07 2013 +0200
add sys.stderr.write("mike ..." debug messages)
>---------------------------------------------------------------
ibus-typing-booster/engine/factory.py | 1 +
ibus-typing-booster/engine/hunspell_suggest.py | 2 ++
ibus-typing-booster/engine/hunspell_table.py | 18 ++++++++++++++++++
ibus-typing-booster/engine/tabsqlitedb.py | 19 +++++++++++++++++++
4 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/ibus-typing-booster/engine/factory.py b/ibus-typing-booster/engine/factory.py
index 84e64d6..3b61ebf 100755
--- a/ibus-typing-booster/engine/factory.py
+++ b/ibus-typing-booster/engine/factory.py
@@ -23,6 +23,7 @@ import hunspell_table
import tabsqlitedb
import os
import re
+import sys
from gettext import dgettext
_ = lambda a : dgettext ("ibus-typing-booster", a)
diff --git a/ibus-typing-booster/engine/hunspell_suggest.py b/ibus-typing-booster/engine/hunspell_suggest.py
index d373277..6974093 100755
--- a/ibus-typing-booster/engine/hunspell_suggest.py
+++ b/ibus-typing-booster/engine/hunspell_suggest.py
@@ -109,6 +109,7 @@ class Hunspell:
self.load_dictionaries()
def load_dictionaries(self):
+ print("mike dictionary_names=%s\n" %self.dictionary_names)
for dictionary_name in self.dictionary_names:
self.dictionaries.append(Dictionary(name=dictionary_name))
@@ -124,6 +125,7 @@ class Hunspell:
return []
if type(input_phrase) != type(u''):
input_phrase = input_phrase.decode('utf8')
+ sys.stderr.write("mike in suggest input_phrase=%(ip)s\n" %{'ip': input_phrase.encode('UTF-8')})
# http://pwet.fr/man/linux/fichiers_speciaux/hunspell says:
#
# > A dictionary file (*.dic) contains a list of words, one per
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index 598f3a8..dcc8356 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -85,6 +85,7 @@ class editor(object):
'''Hold user inputs chars and preedit string'''
def __init__ (self, config, database):
+ sys.stderr.write("mike editor __init__\n")
self.db = database
self._config = config
self._name = self.db.ime_properties.get('name')
@@ -141,6 +142,7 @@ class editor(object):
self.trans_m17n_mode = True
try:
#self.trans = Translit.Transliterator.get(self._m17ndb, self._current_ime)
+ sys.stderr.write("mike calling Transliterator.get(%(m17n)s, %(cur)s)\n" %{'m17n': self._m17ndb, 'cur': self._current_ime})
self.trans = Transliterator.get(self._m17ndb, self._current_ime)
except:
import traceback
@@ -170,12 +172,19 @@ class editor(object):
'NFKD', self._transliterated_string)
else:
self._transliterated_string = self._typed_string
+ sys.stderr.write("mike in update_transliterated_string() self._typed_string=%s\n" %self._typed_string.encode('UTF-8'))
+ sys.stderr.write("mike in update_transliterated_string() repr(self._typed_string)=%s\n" %repr(self._typed_string))
+ sys.stderr.write("mike in update_transliterated_string() self._transliterated_string=%s\n" %self._transliterated_string.encode('UTF-8'))
+ sys.stderr.write("mike in update_transliterated_string() repr(self._transliterated_string)=%s\n" %repr(self._transliterated_string))
def get_transliterated_string(self):
return self._transliterated_string
def insert_string_at_cursor(self, string_to_insert):
'''Insert typed string at cursor position'''
+ sys.stderr.write("mike in insert_string_at_cursor() string_to_insert=%s\n" %string_to_insert.encode('UTF-8'))
+ sys.stderr.write("mike in insert_string_at_cursor() self._typed_string=%s\n" %self._typed_string.encode('UTF-8'))
+ sys.stderr.write("mike in insert_string_at_cursor() self._typed_string_cursor=%s\n" %self._typed_string_cursor)
self._typed_string = self._typed_string[:self._typed_string_cursor] \
+string_to_insert \
+self._typed_string[self._typed_string_cursor:]
@@ -320,6 +329,7 @@ class editor(object):
def update_candidates (self):
'''Update lookuptable'''
+ sys.stderr.write("mike in update_candidates() self._typed_string=%s\n" %self._typed_string.encode('UTF-8'))
if self._typed_string == self._typed_string_when_update_candidates_was_last_called:
# The input did not change since we came here last, do nothing and leave
# candidates and lookup table unchanged:
@@ -488,6 +498,7 @@ class tabengine (IBus.Engine):
'''The IM Engine for Tables'''
def __init__ (self, bus, obj_path, db ):
+ sys.stderr.write("mike in tabengine __init__() obj_path=%s\n" %obj_path)
super(tabengine,self).__init__ (connection=bus.get_connection(),object_path=obj_path)
global debug_level
try:
@@ -596,6 +607,7 @@ class tabengine (IBus.Engine):
def _change_mode (self):
'''Shift input mode, TAB -> EN -> TAB
'''
+ sys.stderr.write("mike in hunspell_table.py _change_mode()\n")
self.reset ()
self._update_ui ()
@@ -763,7 +775,10 @@ class tabengine (IBus.Engine):
if self._has_input_purpose and self._input_purpose in [IBus.InputPurpose.PASSWORD, IBus.InputPurpose.PIN]:
return False
+ sys.stderr.write("mike in process_key_event keyval=%(kv)s keycode=%(kc)s state=%(st)s\n" %{'kv': keyval, 'kc': keycode, 'st': state})
key = KeyEvent(keyval, keycode, state)
+ sys.stderr.write("mike after KeyEvent() in process_key_event key.val=%(kval)s\n" %{'kval': key.val})
+ sys.stderr.write("mike after KeyEvent() in process_key_event key.val=%(kval)s IBus.keyval_to_unicode(key.val)=%(uc)s\n" %{'kval': key.val, 'uc': IBus.keyval_to_unicode(key.code)})
# ignore NumLock mask
key.state &= ~IBus.ModifierType.MOD2_MASK
@@ -784,6 +799,9 @@ class tabengine (IBus.Engine):
return True
if self._editor.is_empty ():
+ sys.stderr.write("mike self._editor.is_empty ():\n")
+ sys.stderr.write("mike key.val=%(key.val)s IBus.keyval_to_unicode(key.val)=%(keychar)s\n" %{'key.val': key.val, 'keychar': IBus.keyval_to_unicode(key.val)})
+ sys.stderr.write("mike IBus.keyval_name(key.val)=%s\n" %IBus.keyval_name(key.val))
# This is the first character typed since the last commit
# there is nothing in the preëdit yet.
if key.val < 32:
diff --git a/ibus-typing-booster/engine/tabsqlitedb.py b/ibus-typing-booster/engine/tabsqlitedb.py
index 78a4b26..2815503 100755
--- a/ibus-typing-booster/engine/tabsqlitedb.py
+++ b/ibus-typing-booster/engine/tabsqlitedb.py
@@ -241,6 +241,8 @@ class tabsqlitedb:
'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase,
'timestamp': time.time()}
+ sys.stderr.write("mike update_phrase() sqlstr=%s\n" %sqlstr)
+ sys.stderr.write("mike update_phrase() sqlargs=%s\n" %sqlargs)
try:
self.db.execute(sqlstr, sqlargs)
if commit:
@@ -253,8 +255,10 @@ class tabsqlitedb:
'''
Trigger a checkpoint operation.
'''
+ sys.stderr.write("mike sync_userdb() commit and execute checkpoint ...\n")
self.db.commit()
self.db.execute('PRAGMA wal_checkpoint;')
+ sys.stderr.write("mike sync_userdb() commit and execute checkpoint done.\n")
def create_tables (self, database):
'''Create table for the phrases.'''
@@ -269,6 +273,7 @@ class tabsqlitedb:
'''
Add phrase to database
'''
+ sys.stderr.write("mike in add_phrase() input_phrase=%(ip)s phrase=%(p)s user_freq=%(uf)s database=%(db)s\n" %{'ip': input_phrase.encode('UTF-8'), 'p': phrase.encode('UTF-8'), 'uf': user_freq, 'db': database})
if not input_phrase or not phrase:
return
input_phrase = unicodedata.normalize(
@@ -299,6 +304,8 @@ class tabsqlitedb:
insert_sqlargs = {'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase,
'user_freq': user_freq, 'timestamp': time.time()}
+ sys.stderr.write("mike add_phrase() insert_sqlstr=%s\n" %insert_sqlstr)
+ sys.stderr.write("mike add_phrase() insert_sqlargs=%s\n" %insert_sqlargs)
try:
self.db.execute (insert_sqlstr, insert_sqlargs)
if commit:
@@ -368,9 +375,11 @@ class tabsqlitedb:
self._normalization_form_internal, p_phrase)
pp_phrase = unicodedata.normalize(
self._normalization_form_internal, pp_phrase)
+ sys.stderr.write("mike in select_words() input_phrase=%(ip)s p_phrase=%(p)s pp_phrase=%(pp)s\n" %{'ip': input_phrase.encode('UTF-8'), 'p': p_phrase.encode('UTF-8'), 'pp': pp_phrase.encode('UTF-8')})
phrase_frequencies = {}
for x in self.hunspell_obj.suggest(input_phrase):
phrase_frequencies.update([(x, 0)])
+ sys.stderr.write("mike in select_words() hunspell: best_candidates=%s\n" %self.best_candidates(phrase_frequencies))
# Now phrase_frequencies might contain something like this:
#
# {u'code': 0, u'communicability': 0, u'cold': 0, u'colour': 0}
@@ -437,6 +446,7 @@ class tabsqlitedb:
# {u'conspiracy': 6/11, u'code': 0, u'communicability': 0, u'cold': 1/11, u'colour': 4/11}
for x in results_uni:
phrase_frequencies.update([(x[0], x[1]/float(count))])
+ sys.stderr.write("mike in select_words() Unigram best_candidates=%s\n" %self.best_candidates(phrase_frequencies))
if not p_phrase:
# If no context for bigram matching is available, return what we have so far:
return self.best_candidates(phrase_frequencies)
@@ -461,6 +471,7 @@ class tabsqlitedb:
# both the weight of 0.5:
for x in results_bi:
phrase_frequencies.update([(x[0], 0.5*x[1]/float(count_p_phrase)+0.5*phrase_frequencies[x[0]])])
+ sys.stderr.write("mike in select_words() Bigram best_candidates=%s\n" %self.best_candidates(phrase_frequencies))
if not pp_phrase:
# If no context for trigram matching is available, return what we have so far:
return self.best_candidates(phrase_frequencies)
@@ -487,6 +498,7 @@ class tabsqlitedb:
# get higher weight):
for x in results_tri:
phrase_frequencies.update([(x[0], 0.5*x[1]/float(count_pp_phrase_p_phrase)+0.5*phrase_frequencies[x[0]])])
+ sys.stderr.write("mike in select_words() Trigram best_candidates=%s\n" %self.best_candidates(phrase_frequencies))
return self.best_candidates(phrase_frequencies)
def generate_userdb_desc (self):
@@ -592,6 +604,8 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
input_phrase = unicodedata.normalize(
self._normalization_form_internal, input_phrase)
+ sys.stderr.write("mike check_phrase() phrase=%(p)s, input_phrase=%(t)s, database=%(d)s\n" %{'p': phrase.encode('UTF-8'), 't': input_phrase.encode('UTF-8'), 'd': database})
+
# There should never be more than 1 database row for the same
# input_phrase *and* phrase. So the following query on
# the database should match at most one database
@@ -608,7 +622,10 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
;'''
sqlargs = {'input_phrase': input_phrase,
'phrase': phrase, 'p_phrase': p_phrase, 'pp_phrase': pp_phrase}
+ sys.stderr.write("mike sqlstr=%s\n" %sqlstr)
+ sys.stderr.write("mike sqlargs=%s\n" %sqlargs)
result = self.db.execute(sqlstr, sqlargs).fetchall()
+ sys.stderr.write("mike result=%s\n" %result)
if len(result) > 0:
# A match was found in user_db, increase user frequency by 1
self.update_phrase(input_phrase = input_phrase,
@@ -630,6 +647,8 @@ CREATE TABLE phrases (id INTEGER PRIMARY KEY, input_phrase TEXT, phrase TEXT, p_
Or, if “input_phrase” is “None”, remove all rows matching “phrase”
no matter for what input phrase from the database.
'''
+ sys.stderr.write("mike remove_phrase() phrase=%(p)s\n" %{'p': phrase.encode('UTF-8')})
+ sys.stderr.write("mike remove_phrase() database=%s\n" %database)
if not phrase:
return
phrase = unicodedata.normalize(
8 years, 7 months
[ibus-typing-booster] miketmp-debug: MOD5 experiment (03f4a67)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 03f4a6756505cb79b9898e7400f4bf9dabf65572
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Thu Feb 20 08:17:03 2014 +0100
MOD5 experiment
>---------------------------------------------------------------
ibus-typing-booster/engine/hunspell_table.py | 3 ++-
ibus-typing-booster/hunspell-tables/mr_IN.conf | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ibus-typing-booster/engine/hunspell_table.py b/ibus-typing-booster/engine/hunspell_table.py
index dcc8356..1402406 100644
--- a/ibus-typing-booster/engine/hunspell_table.py
+++ b/ibus-typing-booster/engine/hunspell_table.py
@@ -850,7 +850,7 @@ class tabengine (IBus.Engine):
self._editor.insert_string_at_cursor(token)
self._update_ui()
return True
- if key.val >= 32 and (not (key.state & (IBus.ModifierType.MOD1_MASK | IBus.ModifierType.CONTROL_MASK))):
+ if key.val >= 32 and (not (key.state & (IBus.ModifierType.MOD1_MASK | IBus.ModifierType.CONTROL_MASK | IBus.ModifierType.MOD5_MASK))):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
@@ -1068,6 +1068,7 @@ class tabengine (IBus.Engine):
typed_character = IBus.keyval_to_unicode(key.val)
if type(typed_character) != type(u''):
typed_character = typed_character.decode('UTF-8')
+ sys.stderr.write("mike: MOD5_MASK=%(bit)s\n" %{'bit': key.state & IBus.ModifierType.MOD5_MASK})
self._editor.insert_string_at_cursor(typed_character)
if typed_character and unicodedata.category(typed_character) in itb_util.categories_to_trigger_immediate_commit:
input_phrase = self._editor.get_transliterated_string()
diff --git a/ibus-typing-booster/hunspell-tables/mr_IN.conf b/ibus-typing-booster/hunspell-tables/mr_IN.conf
index 9f644dd..3c2b675 100644
--- a/ibus-typing-booster/hunspell-tables/mr_IN.conf
+++ b/ibus-typing-booster/hunspell-tables/mr_IN.conf
@@ -6,7 +6,7 @@ description = This is a Marathi typing booster engine table for Marathi language
language = mr
author = Anish Patil <apatil(a)redhat.com>
status_prompt = mr
-layout = default
+layout = default[lv3:ralt_switch]
hunspell_dict = mr_IN.dic
hunspell_dict_package = hunspell-mr
ime_name = Marathi - IN (Hunspell)
8 years, 7 months
[ibus-typing-booster] miketmp-debug: WIP: usage experiment: de_DE & en_GB dictionary (655d7b6)
by mfabian@fedoraproject.org
Repository : http://git.fedorahosted.org/git/?p=ibus-typing-booster.git
On branch : miketmp-debug
>---------------------------------------------------------------
commit 655d7b68cb01fffca141ba6a06d0e1995588d725
Author: Mike FABIAN <mfabian(a)redhat.com>
Date: Fri Jan 17 14:52:04 2014 +0100
WIP: usage experiment: de_DE & en_GB dictionary
>---------------------------------------------------------------
ibus-typing-booster/hunspell-tables/de_DE.conf | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/ibus-typing-booster/hunspell-tables/de_DE.conf b/ibus-typing-booster/hunspell-tables/de_DE.conf
index 0f8251d..b7adbb2 100644
--- a/ibus-typing-booster/hunspell-tables/de_DE.conf
+++ b/ibus-typing-booster/hunspell-tables/de_DE.conf
@@ -7,7 +7,7 @@ language = de
author = Mike FABIAN <mfabian(a)redhat.com>
status_prompt = de
layout = default
-hunspell_dict = de_DE.dic
+hunspell_dict = de_DE.dic, en_GB.dic
hunspell_dict_package = hunspell-de
ime_name = German - DE (Hunspell)
symbol = de-DE
8 years, 7 months