彭贯军
编程学可,翻译亦可
2018-4-3 10:26
阅读:3536

 知乎链接含图片

https://zhuanlan.zhihu.com/p/35240737

正文共:1531 字 8 图

预计阅读时间: 4 分钟


每次翻译外文文献的时候,把英文复制到谷歌翻译,会出现PDF格式的文本的换行很麻烦,需要手动来删除换行,影响翻译时思考的质量。


想起最近学的python编程,我可不可以用python来解决这个问题呢?

答案是:经过2个小时的努力,可以了。


在公众号服务窗口,输入:  翻快点

即可得到所需安装包及文件。


安装完python3.6.5.exe后,搜索 idle.exe 并打开。

新建文件(New File ),输入

with open('etext.txt','r') as fp:

data = fp.readlines()

data = [line.strip() for line in data]

data = ','.join(data)

data = data.split(',')

data = ' '.join(map(str,data))

with open('welltext.txt','w') as fp:

fp.write(data)


即成了这样


将你复制的PDF格式的文字,粘贴到自己新建的 etext.txt文件


按 F5 运行这个程序代码(即 run module)


就可以得到连续一行格式的 welltext.txt文件了


例子:

这样就能将

  1. It is widely recognized that a visual texture, which humans

  2. can easily perceive, is very difficult to define [17]. The difficulty

  3. results mainly from the fact that different people can define textures

  4. in application-dependent ways or with different perceptual

  5. motivations, and there is no generally agreed-upon definition

  6. [44]. It is not our intention to add here a new one: we simply

  7. observe that it should be as general as possible, because a too

  8. strict definition would allow one to confine his/her work to images

  9. that better fit with it, eventually leading to narrow-domain

  10. solutions.

转换成

  1. It is widely recognized that a visual texture  which humans can easily perceive  is very difficult to define [17]. The difficulty results mainly from the fact that different people can define textures in application-dependent ways or with different perceptual motivations  and there is no generally agreed-upon definition [44]. It is not our intention to add here a new one: we simply observe that it should be as general as possible  because a too strict definition would allow one to confine his/her work to images that better fit with it  eventually leading to narrow-domain solutions.

在谷歌翻译里就是从这样

到这样

编程学可,翻译亦可

在公众号服务窗口,输入: 翻快点

即可得到所需安装包及文件。

 知乎链接含图片

https://zhuanlan.zhihu.com/p/35240737

2017-07-04-2327544148.png


转载本文请联系原作者获取授权,同时请注明本文来自彭贯军科学网博客。

链接地址:https://wap.sciencenet.cn/blog-3292245-1107116.html?mobile=1

收藏

分享到:

当前推荐数:0
推荐到博客首页
网友评论0 条评论
确定删除指定的回复吗?
确定删除本博文吗?