Skip to content

Instantly share code, notes, and snippets.

@jerrita
Created September 16, 2017 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerrita/d5c979278c70410581bb3155610216fe to your computer and use it in GitHub Desktop.
Save jerrita/d5c979278c70410581bb3155610216fe to your computer and use it in GitHub Desktop.
英语听写工具重写
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6.1 (C:\Users\78298\AppData\Local\Programs\Python\Python36\python.exe)" project-jdk-type="Python SDK" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/engwords.iml" filepath="$PROJECT_DIR$/.idea/engwords.iml" />
</modules>
</component>
</project>
import random
import pickle
aspect n. 方面;层面
impression n. 印象;感想;印记
take up 拿起;接受;开始;继续
constant adj. 时常发生的;连续不断的
constantly adv. 不断地
jet n. 喷气式飞机
△jet lag 飞行时差反应
△flashback n. 闪回;倒叙
previous adj. 在前的;早先的
uncertain adj. 不确切的;无把握的
guide n. 指导;向导;导游 vt. 指引;指导
tablet n. 药片
△expertise n. 专家意见;专门知识(技能等)
capsule n. 太空舱;胶囊
steward n. 乘务员;服务员
stewardess n. 女乘务员
opening n. (出入的)通路;开口;开端
sideways adv. 往(向、从)一侧;侧着;侧面朝前
surrounding n. 周围的事物;环境 adj. 周围的
tolerate vt. 容忍;忍受
△combination n. 结合;组合
lack vi. & vt. 缺乏;没有 n. 缺乏;短缺的东西
adjustment n. 调整;调节
mask n. 面具;面罩;伪装
be back on one’s feet (困境后)恢复;完全复原
△hover vi. 盘旋
carriage n. 运输工具;四轮马车;客车
press vi. & vt. 按;压;逼迫 n. 按;压;印刷;新闻
fasten vt. 系牢;扎牢
belt n. 腰带;皮带
safety belt 安全带
lose sight of… 看不见……
sweep up 打扫;横扫
flash vt. & vi. (使)闪光;(使)闪现
switch n. 开关;转换 vt. 转换
timetable n. 时间表;时刻表
△exhausted adj. 筋疲力尽的;疲惫不堪的
slide into (快捷而悄声地)移动;溜进……
optimistic adj. 乐观(主义)的
△pessimistic adj. 悲观(主义)的
speed up 加速
△pedal n. 踏板;脚蹬
△alien n. 外星人;外国人 adj. 陌生的;外国的;外星球的
mud n. 泥(浆)
desert n. 沙漠;荒原
△enormous adj. 巨大的;庞大的
△imitate vt. 模仿;仿造
△moveable adj. 可移动的;活动的
citizen n. 公民;居民;市民
typist n. 打字员
typewriter n. 打字机
postage n. 邮资
postcode n. 邮政编码
button n. 钮锃;按钮
instant n. 瞬间;片刻 adj. 立即的;立刻的
receiver n. 接受者;接收器;电话听筒
△efficiency n. 效率;功效
△efficient adj. 效率高的;有能力的
△ribbon n. 丝带;带状物
dustbin n. 垃圾箱
△dispose vt. 布置;安排
△disposal n. 清除;处理
ecology n. 生态;生态学
greedy adj. 贪吃的;贪婪的;贪心的
swallow vt. 吞下;咽下
material n. 原料;材料
recycle vt. 回收利用;再利用
△manufacture vt.(用机器)大量生产;成批制造
goods n. 货物
△etc abbr. 诸如此类;等等
representative n. 代表;典型人物 adj. 典型的;有代表性的
settlement n. 定居;解决
motivation n. 动机
import pickle
# 输出格式[word,trans]
filepth = input('请输入文件名:')
txt = open('input/' + filepth + '.txt', 'r',encoding='utf-8').read()
out = []
cx = ['adv.', 'n.', 'v.', 'vi.', 'vt.', 'adj.', 'prep.']
# 除去特殊字符并拆分
txt = txt.replace('△', '')
txt = txt.replace('…', '...')
txt = txt.split('\n')
for i in txt:
if len(i) == 0:
continue
i = i.split(' ')
isword = False
# 存在词性即为单词
for t in i:
if t in cx:
isword = True
if isword:
# 单词处理方式
out.append((i[0], ' '.join(i[1:])))
else:
# 短语处理方式,一般短语翻译之间无空格,先进行异常处理
if len(i) == 1:
continue
out.append((' '.join(i[:-1]),i[-1]))
# 处理完毕,现在进行输出
output = open('output/' + filepth + '.dic','wb')
pickle.dump(out,output)
output.close()
input('处理完成,输出任意键退出')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment