def __fill_lookup_table(self): # get segment stat seg_stat = anthy.anthy_segment_stat() self.__context.get_segment_stat(self.__cursor_pos, seg_stat) # fill lookup_table self.__lookup_table.clean() for i in xrange(0, seg_stat.nr_candidate): buf = self.__context.get_segment(self.__cursor_pos, i) candidate = unicode(buf, "utf-8") self.__lookup_table.append_candidate(candidate)
#!/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
#!/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