Beispiel #1
0
 def __shrink_segment(self, relative_size):
     self.__context.resize_segment(self.__cursor_pos, relative_size)
     conv_stat = anthy.anthy_conv_stat()
     self.__context.get_stat(conv_stat)
     del self.__segments[self.__cursor_pos :]
     for i in xrange(self.__cursor_pos, conv_stat.nr_segment):
         buf = self.__context.get_segment(i, 0)
         text = unicode(buf, "utf-8")
         self.__segments.append((0, text))
     self.__lookup_table_visible = False
     self.__fill_lookup_table()
     self.__invalidate()
     return True
Beispiel #2
0
    def __begin_anthy_convert(self):
        if self.__convert_mode == CONV_MODE_ANTHY:
            return
        self.__convert_mode = CONV_MODE_ANTHY

        self.__preedit_ja_string.insert(u"\0")

        text, cursor = self.__preedit_ja_string.get_hiragana()

        self.__context.set_string(text.encode("utf8"))
        conv_stat = anthy.anthy_conv_stat()
        self.__context.get_stat(conv_stat)

        for i in xrange(0, conv_stat.nr_segment):
            buf = self.__context.get_segment(i, 0)
            text = unicode(buf, "utf-8")
            self.__segments.append((0, text))

        self.__cursor_pos = 0
        self.__fill_lookup_table()
        self.__lookup_table_visible = False
Beispiel #3
0
#!/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
Beispiel #4
0
#!/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