Created
January 6, 2014 07:20
-
-
Save conanca/8279361 to your computer and use it in GitHub Desktop.
将搜狗拼音导出的文本词库转换成ibus-libpinyin的用户词典
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
'''将搜狗拼音导出的文本词库转换成ibus-libpinyin的用户词典 | |
by Conanca | |
''' | |
content = open("搜狗词库导出_2014_1_6.txt").read().decode('utf16').encode('utf8') | |
lines = content.split('\n') | |
f=open('ibus.txt','w') | |
for line in lines: | |
if line and ' ' in line and line[:1]!=';': | |
i=line.index(' ') | |
newline = line[i+1:-1] + ' '+line[1:i] + '\n' | |
f.write(newline) | |
print newline | |
f.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment