File: test.py

package info (click to toggle)
ibus-anthy 1.5.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,196 kB
  • sloc: python: 13,094; makefile: 523; sh: 330; ansic: 264
file content (21 lines) | stat: -rw-r--r-- 530 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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