moebiuscurve / ibus-table-others

ibus-table-others
code.google.com/p/ibus/
GNU General Public License v3.0
15 stars 8 forks source link

Add Vietnamese input methods Telex and VNI #17

Closed McSinyx closed 4 years ago

McSinyx commented 5 years ago

This should close #13.

mike-fabian commented 4 years ago

Thank you for the pull request!

I’ll have a look soon.

By the way, are you aware that there are telex and vni input methods for Vietnamese already in m17n-db:

/usr/share/m17n/vi-telex.mim 
/usr/share/m17n/vi-vni.mim

You can use these with ibus-m17n or with ibus-typing-booster which might be a good alternative to the buggy ibus-unikey and ibus-bogo. Using them with ibus-typing-booster is probably best because that also gives you word completion.

As I develop ibus-typing-booster, I would be interested in feedback how well vi-telex and vi-vni work when using ibus-typing-booster.

McSinyx commented 4 years ago

By the way, are you aware that there are telex and vni input methods for Vietnamese already in m17n-db

Thanks for the suggestion, I've been using that on my side distros where compiling ibus-table-vietnamese is too complicated or I'm just too lazy to do so (e.g. NixOS). ibus-table-vietnamese has the advantage of being able to type Vietnamese and non Vietnamese together without much trouble and thus I use it more on my main.

As I develop ibus-typing-booster, I would be interested in feedback how well vi-telex and vi-vni work when using ibus-typing-booster.

I'll do, and probably suggest my friends to try it out. I rarely type Vietnamese anymore other than my names for copyright and occasionally chatting with friends.

mike-fabian commented 4 years ago

Thanks for the suggestion, I've been using that on my side distros where compiling ibus-table-vietnamese is too complicated or I'm just too lazy to do so (e.g. NixOS). ibus-table-vietnamese has the advantage of being able to type Vietnamese and non Vietnamese together without much trouble and thus I use it more on my main.

You mean switching between Vietnamese and non-Vietnamese is faster with ibus-table than with ibus-m17n?

I guess this is because ibus-table has "direct input mode", i.e. you can switch between table mode (Vietnamese) and direct input mode by pressing just one key, the left shift key (hardcoded at the moment, I’ll make this configurable in future). And with ibus-m17n you usually have to press something like Super+Space and possibly even move around with the arrow keys after Super+Space if you have more than two input methods configured.

ibus-m17n doesn’t have such a “direct input mode”.

But ibus-typing-booster has a “direct input mode”, although it is not there by default, one has to configure it. In the setup tool of ibus-typing-booster there is a "key bindindings" tab. There you will find the command "toggle_input_mode_on_off" which is not bound to any key by default. You can bind this to any key which is convenient for you and then switch ibus-typing-booster on/off with that key.

I'll do, and probably suggest my friends to try it out. I rarely type Vietnamese anymore other than my names for copyright and occasionally chatting with friends.

Thank you very much, I really would like feedback about that.

McSinyx commented 4 years ago

You mean switching between Vietnamese and non-Vietnamese is faster with ibus-table than with ibus-m17n?

Not really, what I mean is, e.g. boost tốc độ can be typed in my table using bo\o\st toosc ddooj while in traditional telex it is booosst toosc ddooj. The real struggle is on the mechanism of undoing (oooss is infact a series of o, ô, oo, óo, oos which requires the user to keep track of the letters while typing since the rule is irregular—AWS is just AWWS instead—when with o\o\s I know what to type without even looking at the screen, e.g. while note-taking or multi-tasking).

But ibus-typing-booster has a “direct input mode”

That's nice, I did not find out about that.

I really would like feedback about that.

Many of my classmates are installing GNU/Linux distros at the moment, hope it's a good chance to do so. It is a pity tho that typing-booster is not packaged on Debian-based systems.

mike-fabian commented 4 years ago

Nguyễn Gia Phong notifications@github.com さんは書きました:

You mean switching between Vietnamese and non-Vietnamese is faster with ibus-table than with ibus-m17n?

Not really, what I mean is, e.g. boost tốc độ can be typed in my table using bo\o\st toosc ddooj while in traditional telex it is booosst toosc ddooj. The real struggle is on the mechanism of undoing (oooss is infact a series of o, ô, oo, óo, oos which requires the user to keep track of the letters while typing since the rule is irregular--AWS is just AWWS instead--when with o\o\s` I know what to type without even looking at the screen, e.g. while note-taking or multi-tasking).

Ah, very interesting!

Maybe vi-telex.mim should be improved to support these bo\o\st way of writing as well?

I really would like feedback about that.

Many of my classmates are installing GNU/Linux distros at the moment, hope it's a good chance to do so. It is a pity tho that typing-booster is not packaged on Debian-based systems.

I would be very happy if somebody would package it for Debian-based distros. Maybe I have to do it myself if nobody else does it, but there is so much stuff to do ...

I test ibus-typing-booster from time to time on Debian, Ubuntu, Linux Mint, ..., so I know it works there as well. Would be good to package it there as well. Currently I package it for Fedora and for OpenSUSE and somebody else is so nice to package it for FreeBSD.

mike-fabian commented 4 years ago

Mike FABIAN maiku.fabian@gmail.com さんは書きました:

Nguyễn Gia Phong notifications@github.com さんは書きました:

Not really, what I mean is, e.g. boost tốc độ can be typed in my table using bo\o\st toosc ddooj while in traditional telex it is booosst toosc ddooj.

Ah, very interesting!

Maybe vi-telex.mim should be improved to support these bo\o\st way of writing as well?

I had a quick look at vi-telex.mim and it looks quite complicated. It is probably possible to improve it to support writing in that style as well, but it is not trivial to change.

McSinyx commented 4 years ago

First of all, thank you for the merge. Release 1.3.11 has the wrong tarball however (ibus-table instead of *-others).

I am typing on typing booster for English at the moment and it's quite a good experience (I'm not really good at spelling, I have to use dictionary completion on Vim all the time to improve typing speed). It has some latency but it's somewhat comparable to what I have in Vim. I can't seem to get it to work with the Vietnamese m17n: I cannot find that option. vi_VN does not have word list though (I am not aware of any, obviously not hunspell, Vietnamese word list packaged along with any distro). I'm trying it for French too and it works kinda well (if that's not consider cheating in Duolingo).

ibus-m17n doesn’t have such a “direct input mode”.

I had a quick look at vi-telex.mim and it looks quite complicated.

Turns out ibus-m17n vi-telex is using backslash for toggling the direct input mode, similar to Shift in ibus-table.

mike-fabian commented 4 years ago

First of all, thank you for the merge. Release 1.3.11 has the wrong tarball however (ibus-table instead of *-others).

Thank you for noticing! I just fixed it, it should have the right tarball now.

mike-fabian commented 4 years ago

I am typing on typing booster for English at the moment and it's quite a good experience (I'm not really good at spelling, I have to use dictionary completion on Vim all the time to improve typing speed). It has some latency but it's somewhat comparable to what I have in Vim. I can't seem to get it to work with the Vietnamese m17n: I cannot find that option.

Here is a screen shot of the setup tool of ibus-typing-booster :

ibus-typing-booster-adding-vi-input-method

In the lower half of that tab one can add input methods. The screen shot shows how to add Vietnamese input methods, for example vi-telex (All these input methods come from m17n-db).

mike-fabian commented 4 years ago

vi_VN does not have word list though (I am not aware of any, obviously not hunspell, Vietnamese word list packaged along with any distro).

On Fedora 31, a vi_VN.dic exists:

mfabian@taka:~
$ rpm -qf /usr/share/myspell/vi_VN.dic 
hunspell-vi-0.20120418-4.fc31.noarch
mfabian@taka:~

It is pretty small though:

$ wc /usr/share/myspell/vi_VN.dic
 6632  6632 39852 /usr/share/myspell/vi_VN.dic
mfabian@taka:~
$ 

and it contains only quite short words, so I am not sure how useful that is. According to the URL in the Fedora hunspell-vi.spec file it seems to come from here:

https://extensions.openoffice.org/en/project/vietnamese-spellchecker

mike-fabian commented 4 years ago

ibus-typing-booster <= 2.7.5 looks for dictionary files only in

    dirnames = [
        '/usr/share/hunspell',
        '/usr/share/myspell',
        '/usr/share/myspell/dicts',
        '/usr/local/share/hunspell', # On FreeBSD the dictionaries are here
        '/usr/local/share/myspell',
        '/usr/local/share/myspell/dicts',
    ]

So you would need to drop a vi_VN.dic into one of these directories if you can find a useful one.

ibus-typing-booster >= 2.7.6 added two more directories:

    datadir = os.path.join(os.path.dirname(__file__), '../data')
    user_datadir = xdg_save_data_path('ibus-typing-booster/data')
    dirnames = [
        user_datadir,
        datadir,
        '/usr/share/hunspell',
        '/usr/share/myspell',
        '/usr/share/myspell/dicts',
        '/usr/local/share/hunspell', # On FreeBSD the dictionaries are here
        '/usr/local/share/myspell',
        '/usr/local/share/myspell/dicts',
    ]

I.e. it looks first in ~/.local/share/ibus-typing-booster/data, then in the system directories. So a user can easily add a xx_YY.dic with a word list in his home directory now if no dictionary exists in the system or if he has found a better one than the system dictionary.

mike-fabian commented 4 years ago

I'm trying it for French too and it works kinda well (if that's not consider cheating in Duolingo).

I am using it a lot for French as well, my French still sucks, I am really a beginner and ibus-typing-booster helps me a lot to get the spelling right, especially the accents. One can usually type a French word without accents and get the word with the correct accents in the suggestions.

I’m also using it in Duolingo, Duolingo is my favorite testcase for manual testing before I make a new release of ibus-typing-booster.

ibus-m17n doesn’t have such a “direct input mode”. I had a quick look at vi-telex.mim and it looks quite complicated.

Turns out ibus-m17n vi-telex is using backslash for toggling the direct input mode, similar to Shift in ibus-table.

Oh, I didn’t know that, interesting.

mike-fabian commented 4 years ago

vi-telex-mcsinyx.mim.gz

mike-fabian commented 4 years ago

I attached a vi-telex-mcsinyx.mim.gz file to my last comment. If you download and gunzip that file and put vi-telex-mcsinyx.mim into the ~/.m17n.d/ folder (Create that directory if it doesn’t exist), then you will be able to use the input method you made for ibus-table with ibus-m17n and with ibus-typing-booster.

You can add vi-telex-mcsinyx then in the "Dictionaries and input methods" tab of the setup tool of ibus-typing-booster.

ibus-typing-booster >= 2.6.8 is needed for that to work, older versions of ibus-typing-booster had the list of m17n-db input methods hardcoded.

ibus-typing-booster >= 2.6.8 searches not only the system directory (usually /usr/share/m17n) but also the user directory indicated by the M17NDIR environment variable or if that variable is not set it searches the ~/.m17n.d directory if that exists.

So you can add an input method by dropping a useable .mim file into ~/.m17n.d.

mike-fabian commented 4 years ago

Here is a small quote from the attached vi-telex-mcsinyx.mim.gz:

;; vi-telex-mcsinyx.mim
;;
;; Special Vietnamese telex input method by Nguyễn Gia Phong <notifications@github.com> 

(input-method vi telex-mcsinyx)

(description
"Nguyễn Gia Phong’s Vietnamese telex input method")

(title "Telex McSinyx")

(map
 (trans

  ...

  ("o" "o")
  ("o\\" "o")
  ("of" "ò")
  ("os" "ó")
  ("or" "ỏ")
  ("ox" "õ")
  ("oj" "ọ")
  ("oo" "ô")
  ("oo\\" "ô")
  ("oof" "ồ")
  ("oos" "ố")
  ("oor" "ổ")
  ("oox" "ỗ")
  ("ooj" "ộ")
  ("ow" "ơ")
  ("ow\\" "ơ")
  ("owf" "ờ")
  ("ows" "ớ")
  ("owr" "ở")
  ("owx" "ỡ")
  ("owj" "ợ")

  ...

  ("yj" "ỵ")))

(state
  (init
    (trans)))

You see that it is very easy to translate a simple ibus-table input method into a simple m17n-db input method.

mike-fabian commented 4 years ago

What do you think of vi-telex-mcsinyx.mim? Isn’t that just as good as the table for ibus-table? And, it not only works with ibus-m17n but also with ibus-typing-booster.

McSinyx commented 4 years ago

First of all, thank you for your detailed instructions and sorry for the late reply. I've discovered that due to improper configuration of the typing-booster and m17n on NixOS, the m17n does not show up (this is definitely a bug, I'll try to take a look at it in the upcoming holiday).

So far, I'm quite happy with boosting my spelling for french and english, with setting min number of chars for completion to 3 to balance with the latency. For vietnamese, however, it does not seem be to worth it, due to the short avg length of words that you may have noticed (since each word represent only one single syllable). Though, thank you for showing me about constructing the m17n file, the lisp syntax really interests me.

About typing booster I have a question: how to disable adding spaces after word commit? I cannot seem to be able to find it in the options tab.

I’m also using it in Duolingo, Duolingo is my favorite testcase for manual testing before I make a new release of ibus-typing-booster.

Now I cannot do it without thinking some people in the rank might just use it for testing their input methods :smile:

mike-fabian commented 4 years ago

So far, I'm quite happy with boosting my spelling for french and english, with setting min number of chars for completion to 3 to balance with the latency. For vietnamese, however, it does not seem be to worth it, due to the short avg length of words that you may have noticed (since each word represent only one single syllable). Though, thank you for showing me about constructing the m17n file, the lisp syntax really interests me.

Ah, I already noticed that the Vietnamese hunspell file has only very short words, and I wondered why that is. I didn’t know that Vietnamese always has short words.

About typing booster I have a question: how to disable adding spaces after word commit? I cannot seem to be able to find it in the options tab.

In the options tab there is only an option to choose whether you want a space or not after committing with a mouse click.

But in the key bindings tab there is more:

commit_candidate_1   []
commit_candidate_1_plus_space ['1', 'KP_1', 'F1']
... same for candidates 2-9 ...

The above are the defaults.

So typing 1, keypad 1, or F1 will commit the first candidate and add a space by default.

You could change it like this:

commit_candidate_1   ['1', 'KP_1', 'F1']
commit_candidate_1_plus_space []
... same for candidates 2-9 ...

then typing 1, keypad 1, or F1 will commit the first candidate and add not add a space.

You could also do

commit_candidate_1   ['1']
commit_candidate_1_plus_space ['KP_1', 'F1']
... same for candidates 2-9 ...

to have 1 commit without space and keypad one and F1 with space.

Or even use completely different keys.

I originally implemented this fine grained configurability of these key bindings because some user wanted to commit the first candidate without space by typing arrow-right (By default, arrow-right would commit the preedit, not the first candidate. But by changing the above key bindings, you can even make arrow-right commit the first candidate. That is not useful for me personally, but it is now possible to configure it like that).

Maybe this way to do it is a bit complicated because you usually have to change the key bindings for all candidates 1-9. Before I had only simple options whether numbers 1-9 should trigger a commit or not and whether committing a candidate should add a space or not. Now, if you don’t want the numbers 1-9 to commit candidates because you want to type numbers into the preedit, you have to remove 1 from commit_candidate_1_plus_space, 2 from commit_candidate_2_plus_space, ... Before it was one click in the option tab whether numbers should commit or not.

But the new system is much more flexible and allows adding spaces on commit with some keys but not with others and even committing with completely different keys if desired.

McSinyx commented 4 years ago

Oops, I thought I've already replied until I link this to a friend earlier today. Where is the config file for the bindings, since adding shortcut for e.g. commit_candidate_1 does not override the *_plus_space variant, at least on my setup? Happy lunar (almost) new year BTW!

mike-fabian commented 4 years ago

Oops, I thought I've already replied until I link this to a friend earlier today. Where is the config file for the bindings, since adding shortcut for e.g. commit_candidate_1 does not override the *_plus_space variant, at least on my setup? Happy lunar (almost) new year BTW!

No, it does not overrride the *_plus_space variant. If you want that the key '1' commits the first candidate without a space, you add this to commit_candidate_1 and remove it from commit_candidate_1_plus_space.

mike-fabian commented 4 years ago

Where is the config file for the bindings,

There is no config file for this, the settings are stored with gsettings.

$ dconf dump /org/freedesktop/ibus/engine/typing-booster/
[/]
addspaceoncommit=true
arrowkeysreopenpreedit=false
autocommitcharacters=''
autoselectcandidate=false
colordictionary=true
colordictionarystring='rgb(127,127,127)'
colorinlinecompletion=true
colorinlinecompletionstring='rgb(252,175,62)'
colorspellcheck=true
coloruserdb=true
debuglevel=2
dictionary='de_DE,fr_FR,en_GB'
dictionaryinstalltimestamp='2019-12-19 17:19:22'
emojipredictions=false
googleapplicationcredentials='/home/mfabian/etc/mike-voice-recognition-29b7d3e68be6.json'
inlinecompletion=true
inputmethod='t-latn-post,NoIME'
keybindings={'remove_candidate_6': <['Control+6', 'Control+KP_6', 'Control+F6']>, 'remove_candidate_2': <['Control+2', 'Control+KP_2', 'Control+F2']>, 'commit_candidate_5': <@as []>, 'next_input_method': <['Control+Down', 'Control+KP_Down']>, 'lookup_table_page_up': <['Page_Up', 'KP_Page_Up', 'KP_Prior']>, 'remove_candidate_8': <['Control+8', 'Control+KP_8', 'Control+F8']>, 'setup': <['Mod5+F10']>, 'select_previous_candidate': <['Shift+Tab', 'Shift+ISO_Left_Tab', 'Up', 'KP_Up']>, 'previous_input_method': <['Control+Up', 'Control+KP_Up']>, 'commit_candidate_6': <@as []>, 'remove_candidate_3': <['Control+3', 'Control+KP_3', 'Control+F3']>, 'lookup_related': <['Mod5+F12']>, 'select_next_candidate': <['Tab', 'ISO_Left_Tab', 'Down', 'KP_Down']>, 'remove_candidate_9': <['Control+9', 'Control+KP_9', 'Control+F9']>, 'commit_candidate_1': <@as []>, 'remove_candidate_4': <['Control+4', 'Control+KP_4', 'Control+F4']>, 'commit_candidate_7': <@as []>, 'next_dictionary': <['Mod1+Down', 'Mod1+KP_Down']>, 'toggle_input_mode_on_off': <['KP_Subtract']>, 'commit_candidate_2': <@as []>, 'speech_recognition': <['Insert']>, 'commit_candidate_8': <@as []>, 'lookup_table_page_down': <['Page_Down', 'KP_Page_Down', 'KP_Next']>, 'remove_candidate_5': <['Control+5', 'Control+KP_5', 'Control+F5']>, 'toggle_emoji_prediction': <['Mod5+F6']>, 'toggle_hide_input': <['Shift+Control+Escape']>, 'commit_candidate_3': <@as []>, 'toggle_off_the_record': <['Mod5+F9']>, 'cancel': <['Escape']>, 'enable_lookup': <['Tab', 'ISO_Left_Tab']>, 'commit_candidate_9': <@as []>, 'previous_dictionary': <['Mod1+Up', 'Mod1+KP_Up']>, 'commit_candidate_1_plus_space': <['1', 'KP_1', 'F1']>, 'commit_candidate_2_plus_space': <['2', 'KP_2', 'F2']>, 'commit_candidate_3_plus_space': <['3', 'KP_3', 'F3']>, 'commit_candidate_4_plus_space': <['4', 'KP_4', 'F4']>, 'commit_candidate_5_plus_space': <['5', 'KP_5', 'F5']>, 'commit_candidate_6_plus_space': <['6', 'KP_6', 'F6']>, 'commit_candidate_4': <@as []>, 'commit_candidate_7_plus_space': <['7', 'KP_7', 'F7']>, 'commit_candidate_9_plus_space': <['9', 'KP_9', 'F9']>, 'remove_candidate_1': <['Control+1', 'Control+KP_1', 'Control+F1']>, 'commit_candidate_8_plus_space': <['8', 'KP_8', 'F8']>, 'remove_candidate_7': <['Control+7', 'Control+KP_7', 'Control+F7']>}
labeldictionary=true
labelspellcheck=true
labeluserdb=false
mincharcomplete=1
offtherecord=false
pagesize=6
preeditstyleonlywhenlookup=false
preeditunderline=1
qtimmoduleworkaround=false
rememberlastusedpreeditime=true
shownumberofcandidates=true
showstatusinfoinaux=true
tabenable=false
usedigitsasselectkeys=false
$

you can set this stuff from the command line using dconf or gsettings, but it is far easier to use the setup tool of ibus-typing-booster.

McSinyx commented 4 years ago

Sorry for the late reply, I've just realized that due to the lack of icons on KDE (or maybe not, I'm referring to the transparent buttons on the two sides of tab list), I was unaware of the next hidden tabs 2020-01-27T16:10:44

It was so embarrassing that I only found the custom binding settings and wondering why do you have it while I'm on the latest-ish version already. Anyway, thank you for your support, typing booster is quite of an pleasant experience for me!

mike-fabian commented 4 years ago

Oh, this looks terrible on KDE! Really almost invisible! I wonder whether I could do anything to improve t his on KDE ...

mike-fabian commented 4 years ago

For me it does show these icons even on KDE:

Screenshot

I don’t know how they can disappear, maybe it is a problem in a certain theme.

McSinyx commented 4 years ago

I don’t know how they can disappear, maybe it is a problem in a certain theme.

Yep, it's the fault on my side, I'm sorry for the unclear phrasing (the lack of icons on KDE) and the inconvenience it costed you (seemingly you fired a VM just to check it out). Again, thank you for your support!