Skip to content

Instantly share code, notes, and snippets.

@yunazuno
Created January 18, 2012 06:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yunazuno/1631526 to your computer and use it in GitHub Desktop.
Save yunazuno/1631526 to your computer and use it in GitHub Desktop.
Python port of libskk/tools/tool.vala (prototype)
#!/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