diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-06-11 14:57:22 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-06-11 14:57:22 +0800 |
| commit | 58bb35853d8a5ba128c827afb307b2ead467f6c8 (patch) | |
| tree | dedf07bc33a45a2f5c4c0937620c8eb680d37101 /engine | |
| parent | b4ae75975083abb847a654edb0d48d888056d0e5 (diff) | |
| download | ibus-58bb35853d8a5ba128c827afb307b2ead467f6c8.tar.gz ibus-58bb35853d8a5ba128c827afb307b2ead467f6c8.tar.xz ibus-58bb35853d8a5ba128c827afb307b2ead467f6c8.zip | |
Add anthy engine
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/anthy/Makefile | 8 | ||||
| -rw-r--r-- | engine/anthy/Makefile.am | 35 | ||||
| -rw-r--r-- | engine/anthy/anthy.i | 81 | ||||
| -rwxr-xr-x | engine/anthy/test.py | 21 |
4 files changed, 145 insertions, 0 deletions
diff --git a/engine/anthy/Makefile b/engine/anthy/Makefile new file mode 100644 index 0000000..36dbf74 --- /dev/null +++ b/engine/anthy/Makefile @@ -0,0 +1,8 @@ +all: _anthy.so + +anthy.py anthy_wrap.c: anthy.i + swig -python -I/usr/include $< +_anthy.so: anthy_wrap.c + $(CC) -shared -o $@ $^ -fPIC `python-config --cflags --libs` `pkg-config anthy --cflags --libs` +clean: + $(RM) anthy.py anthy_wrap.c _anthy.so diff --git a/engine/anthy/Makefile.am b/engine/anthy/Makefile.am new file mode 100644 index 0000000..b3d3f9b --- /dev/null +++ b/engine/anthy/Makefile.am @@ -0,0 +1,35 @@ +anthy_PYTHON = \ + anthy.py \ + anthyengine.py \ + convertor.py \ + conv_tables.py \ + anthy_panel.py \ + __init__.py \ + $(NULL) + +anthydir = $(datadir)/gik/ime/anthy + +module_LTLIBRARIES = _anthy.la +moduledir = $(datadir)/gik/ime/anthy +_anthy_la_SOURCES = anthy_wrap.c +_anthy_la_CFLAGS = \ + @ANTHY_CFLAGS@ \ + `python-config --cflags` +_anthy_la_LDFLAGS = \ + @ANTHY_LIBS@ \ + `python-config --ldflags` \ + -avoid-version -module + +anthy.py anthy_wrap.c: anthy.i + swig -python $< + +CLEANFILES = \ + anthy.py \ + anthy.pyc \ + anthy.pyo \ + anthy_wrap.c \ + $(NULL) +EXTRA_DIST = \ + anthy.i \ + test.py \ + $(NULL) diff --git a/engine/anthy/anthy.i b/engine/anthy/anthy.i new file mode 100644 index 0000000..2441bb7 --- /dev/null +++ b/engine/anthy/anthy.i @@ -0,0 +1,81 @@ +/* anthy.i */ + %module anthy + %{ + /* Put header files here or function declarations like below */ + #include <anthy/anthy.h> + %} + +%init %{ + anthy_init (); +%} + + +/* anthy_context_t */ +%include anthy/anthy.h +struct anthy_context {}; +%extend anthy_context { + anthy_context () { + return anthy_create_context (); + } + + void reset () { + anthy_reset_context (self); + } + + int set_string (char *str) { + return anthy_set_string (self, str); + } + + void resize_segment (int a1, int a2) { + anthy_resize_segment (self, a1, a2); + } + + int get_stat (struct anthy_conv_stat *a1) { + return anthy_get_stat (self, a1); + } + + int get_segment_stat (int a1, struct anthy_segment_stat *a2) { + return anthy_get_segment_stat (self, a1, a2); + } + + int get_segment (int a1, int a2, char *a3, int a4) { + return anthy_get_segment (self, a1, a2, a3, a4); + } + + int commit_segment (int a1, int a2) { + return anthy_commit_segment (self, a1, a2); + } + + int set_prediction_string (const char *a1) { + return anthy_set_prediction_string (self, a1); + } + + int get_prediction_stat (struct anthy_prediction_stat *a1) { + return anthy_get_prediction_stat (self, a1); + } + + int get_prediction (int a1, char *a2, int a3) { + return anthy_get_prediction (self, a1, a2, a3); + } + + int commit_prediction (int a1) { + return anthy_commit_prediction(self, a1); + } + + void _print () { + anthy_print_context (self); + } + + int _set_encoding (int encoding) { + return anthy_context_set_encoding (self, encoding); + } + + int set_reconversion_mode (int mode) { + return anthy_set_reconversion_mode (self, mode); + } + + ~anthy_context () { + anthy_release_context (self); + } +}; + diff --git a/engine/anthy/test.py b/engine/anthy/test.py new file mode 100755 index 0000000..cd67997 --- /dev/null +++ b/engine/anthy/test.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import anthy +import sys + +ctx = anthy.anthy_context () +ctx._set_encoding (2) +if len(sys.argv) >= 2: + ctx.set_string (sys.argv[1]) +else: + ctx.set_string ("γγΎγγ") +conv_stat = anthy.anthy_conv_stat () +seg_stat = anthy.anthy_segment_stat () +ctx.get_stat (conv_stat) +for i in range (0, conv_stat.nr_segment): + ctx.get_segment_stat (i, seg_stat) + buf = " " + i = ctx.get_segment (i, 0, buf, 10) + print buf[:i] +# anthy.anthy_release_context (ctx) +ctx = None |
