예제 #1
0
def wubi():
    parser = argparse.ArgumentParser()
    parser.add_argument("-t", help="chinese2wubi:cw,wubi2chinese wc")
    parser.add_argument("-c", help="Input chinese words")
    args = parser.parse_args()

    if args.t not in ['wc', 'cw']:
        parser.print_help()
        return
    if not args.c:
        parser.print_help()
        return
    print(get(u(args.c), args.t))
예제 #2
0
파일: test_wubi.py 프로젝트: byccln/wubi
 def test_wubi_with_english3(self):
     self.assertEqual(wubi.get('WenChaoWang ep thd mh', 'wc'),
                      u('WenChaoWang爱自由'))
예제 #3
0
파일: test_wubi.py 프로젝트: byccln/wubi
 def test_chinese_with_english4(self):
     self.assertEqual(wubi.get('爱wang', 'cw'), 'ep wang')
예제 #4
0
파일: test_wubi.py 프로젝트: byccln/wubi
 def test_chinese_with_english3(self):
     self.assertEqual(wubi.get('WenChaoWang 爱自由', 'cw'),
                      'WenChaoWang ep thd mh')
예제 #5
0
파일: script.py 프로젝트: fasiha/cjk-2021
import subprocess
import shutil
import os

# See https://github.com/arcsecw/wubi/issues/8
if not os.path.isdir('wubi'):
  subprocess.run(['git', 'clone', 'https://github.com/arcsecw/wubi', 'wubi-repo'])
  shutil.move('wubi-repo/wubi', '.')

import wubi

original = '很高兴见到你'
words = wubi.get(original, 'cw')
print(words)
print(original)

for word, orig in zip(words.split(), original):
  files = [f'{c}.png' for c in word]
  subprocess.run(['montage', '-tile', 'x0'] + files + ['test.png'])
  subprocess.run([
      'convert', 'test.png', '-font', '/Library/Fonts/Arial Unicode.ttf', '-pointsize', '50',
      f"label:{orig}", '-gravity', 'Center', '-append', 'test2.png'
  ])
  subprocess.run(['convert', 'test2.png', '-bordercolor', 'Black', '-border', '1x1', f'{orig}.png'])
예제 #6
0
def wubi_known(words):
    # The subset of `words` that appear in the dictionary.
    return set(wubi.get(w, 'wc') for w in words if w is not wubi.get(w, 'wc'))
예제 #7
0
def simshape(in_char, frac=1):
    in_wubi = wubi.get(in_char, 'cw')  # Get wubi code
    edit_wubi = edits1(in_wubi)
    simshape_list = list(wubi_known(edit_wubi))
    return sorted(simshape_list, key=lambda k: getf(k),
                  reverse=True)[:len(simshape_list) // frac]