/usr/share/pyshared/sunpinyin/test.py is in python-sunpinyin 2.0.3+git20140127-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
from pyslm import Slm, SlmState
from pytrie import PinyinTrie, PinyinTrieNode, WordInfo
def test_pyslm ():
slm = Slm ()
if not slm.load ("../data/lm_sc.t3g"):
return
pr, result = slm.transfer (SlmState(0,0), 58614)
print "pr =", pr, "\tresult = %s" % result
pr, result = slm.transfer (result, 75956)
print "pr =", pr, "\tresult = %s" % result
pr, result = slm.transfer (result, 84582)
print "pr =", pr, "\tresult = %s" % result
his = slm.history_state_of (result)
print "his = %s" % his
slm.historify (result)
print "result = %s" % result
print 'last_word_id =', slm.last_word_id (result)
slm.free ()
def test_pytrie ():
trie = PinyinTrie()
if not trie.load ("../data/pydict_sc.bin"):
return
root = trie.get_root_node ()
node = trie.transfer (root, 0x1000)
for w in node.get_words ():
print w
print trie.is_valid (node, False, 0)
print trie[10000]
print trie.get_symbol_id (u'。')
trie.free ()
test_pyslm()
test_pytrie()
# -*- indent-tabs-mode: nil -*- vim:et:ts=4
|