-
-
Save tani/1998922054769fc2860995d29fa8b74d to your computer and use it in GitHub Desktop.
Python port of libskk/tools/tool.vala (prototype)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from gi.repository import Skk | |
import sys | |
Skk.init() | |
dictionaries = [] | |
dictionary = Skk.FileDict.new("/usr/share/skk/SKK-JISYO.L", "EUC-JP") | |
dictionaries.append(dictionary) | |
context = Skk.Context.new(dictionaries) | |
for line in sys.stdin: | |
line = line.rstrip() | |
context.process_key_events(line) | |
output = context.poll_output() | |
preedit = context.get_property('preedit') | |
print ( | |
"{{ \"input\": \"{input}\", " + | |
"\"output\": \"{output}\", " + | |
"\"preedit\": \"{preedit}\" }}").format( | |
input=line, | |
output=output, | |
preedit=preedit | |
) | |
context.reset() | |
context.clear_output() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment