import os
os.getcwd() # 查看当前工作路径 get corrent work dir
D:\yianzhuang\Anaconda3\lib\site-packages\ipykernel\parentpoller.py:116: UserWarning: Parent poll failed.  If the frontend dies,the kernel may be left running.  Please let us knowabout your system (bitness, Python, etc.) atipython-dev@scipy.orgipython-dev@scipy.org""")'D:\\yianzhuang\\python\\Jupyter-Notebook\\IELTS'
import pandas as pd
import re
file = r"C:\Users\小红帽\AppData\Local\kingsoft\WPS Cloud Files\userdata\qing\filecache\小红帽的云文档\雅思\听力\剑桥雅思听力179考点词\雅思听力179考点词.xlsx" # 要打开的文件名data = pd.read_excel(file,usecols=2) # 读取Excel文件
data # 咱来看看里面长啥样子
序号 考点词 同义替换
0 1 reserve book
1 2 in advance ahead,before
2 3 have to must,should,need,require,neceaasry,be supposed...
3 4 adjust change,alter,modify,shift,revert
4 5 and and also, as well as, with, in addition, not o...
5 6 but however, yet, instead
6 7 because why, as a result, therefore, cause
7 8 diversity a variety of, a number of, a range of, various...
8 9 fee money,cost, price,expense,budget,fund,financia...
9 10 establish build, create,construct,set up, install
10 11 transfer move, relocate
11 12 habitat live, territory
12 13 international contries,continents,global
13 14 export abroad, overseas
14 15 vegetation plant,tree,forest,botanic,grass,herb
15 16 animal mammal, wildlife,creature,species
16 17 feature characteristic,trait,property
17 18 emigrate move, go away
18 19 food feed on, eat
19 20 allergic cannot eat
20 21 fitness health,medical,sickness,illness,gym
21 22 tradition custom,convention,local culture, lifestyle
22 23 entertainment recreation, leisure activities
23 24 press media, TV, newspaper, radio
24 25 online internet, website
25 26 publicity website, media,news,marketing
26 27 picture photo,photography,camera,image
27 28 jewellery rings,bracelets,necklaces,precious stones, gem...
28 29 artwork painting, drawing, craft
29 30 statue sculpture, carving
... ... ... ...
149 150 well-known famous, fame
150 151 specilalise in focus, emphasis, concentrate
151 152 part component, proportion, percent, secion, elemen...
152 153 typical representative,common,average
153 154 uncommon special,unique,unusual,rare
154 155 accurately precisely
155 156 expand add,enlarge,increase,spaces
156 157 climb go up, increase
157 158 enhance improve, increase
158 159 power force, energy
159 160 fuel coal,firewood,petrol,gas
160 161 refurbish redecorate
161 162 preference like,priority
162 163 trust less suspicious, believe, no doubt
163 164 computer laptop
164 165 handy convenient
165 166 demonstrate display,show,exhibition
166 167 important significant,major,main,primary
167 168 straightforward direct,first-hand,simple, clear
168 169 disused empty,abandoned
169 170 donate charity,give, volunteer
170 171 work item
171 172 turn switch
172 173 information details,data,graph,chart
173 174 visualise imagine
174 175 repetition over and over
175 176 poor weak
176 177 durable stronger,longer
177 178 pollutant contaminant
178 179 continue ahead, go on, keep doing

179 rows × 3 columns

# 根据逗号分割 函数
def split_comma(letters):letters = letters.split(',')return letters # 去除前后空字符串 函数
def strip(letters):letters = letters.strip()return letters
data['test'] = data['同义替换'].apply(split_comma) # 应用逗号分割函数
data
序号 考点词 同义替换 test
0 1 reserve book [book]
1 2 in advance ahead,before [ahead, before]
2 3 have to must,should,need,require,neceaasry,be supposed... [must, should, need, require, neceaasry, be su...
3 4 adjust change,alter,modify,shift,revert [change, alter, modify, shift, revert]
4 5 and and also, as well as, with, in addition, not o... [and also, as well as, with, in addition, ...
5 6 but however, yet, instead [however, yet, instead]
6 7 because why, as a result, therefore, cause [why, as a result, therefore, cause]
7 8 diversity a variety of, a number of, a range of, various... [a variety of, a number of, a range of, var...
8 9 fee money,cost, price,expense,budget,fund,financia... [money, cost, price, expense, budget, fund, f...
9 10 establish build, create,construct,set up, install [build, create, construct, set up, install]
10 11 transfer move, relocate [move, relocate]
11 12 habitat live, territory [live, territory]
12 13 international contries,continents,global [contries, continents, global]
13 14 export abroad, overseas [abroad, overseas]
14 15 vegetation plant,tree,forest,botanic,grass,herb [plant, tree, forest, botanic, grass, herb]
15 16 animal mammal, wildlife,creature,species [mammal, wildlife, creature, species]
16 17 feature characteristic,trait,property [characteristic, trait, property]
17 18 emigrate move, go away [move, go away]
18 19 food feed on, eat [feed on, eat]
19 20 allergic cannot eat [cannot eat]
20 21 fitness health,medical,sickness,illness,gym [health, medical, sickness, illness, gym]
21 22 tradition custom,convention,local culture, lifestyle [custom, convention, local culture, lifestyle]
22 23 entertainment recreation, leisure activities [recreation, leisure activities]
23 24 press media, TV, newspaper, radio [media, TV, newspaper, radio]
24 25 online internet, website [internet, website]
25 26 publicity website, media,news,marketing [website, media, news, marketing]
26 27 picture photo,photography,camera,image [photo, photography, camera, image]
27 28 jewellery rings,bracelets,necklaces,precious stones, gem... [rings, bracelets, necklaces, precious stones,...
28 29 artwork painting, drawing, craft [painting, drawing, craft]
29 30 statue sculpture, carving [sculpture, carving]
... ... ... ... ...
149 150 well-known famous, fame [famous, fame]
150 151 specilalise in focus, emphasis, concentrate [focus, emphasis, concentrate]
151 152 part component, proportion, percent, secion, elemen... [component, proportion, percent, secion, e...
152 153 typical representative,common,average [representative, common, average]
153 154 uncommon special,unique,unusual,rare [special, unique, unusual, rare]
154 155 accurately precisely [precisely]
155 156 expand add,enlarge,increase,spaces [add, enlarge, increase, spaces]
156 157 climb go up, increase [go up, increase]
157 158 enhance improve, increase [improve, increase]
158 159 power force, energy [force, energy]
159 160 fuel coal,firewood,petrol,gas [coal, firewood, petrol, gas]
160 161 refurbish redecorate [redecorate]
161 162 preference like,priority [like, priority]
162 163 trust less suspicious, believe, no doubt [less suspicious, believe, no doubt]
163 164 computer laptop [laptop]
164 165 handy convenient [convenient]
165 166 demonstrate display,show,exhibition [display, show, exhibition]
166 167 important significant,major,main,primary [significant, major, main, primary]
167 168 straightforward direct,first-hand,simple, clear [direct, first-hand, simple, clear]
168 169 disused empty,abandoned [empty, abandoned]
169 170 donate charity,give, volunteer [charity, give, volunteer]
170 171 work item [item]
171 172 turn switch [switch]
172 173 information details,data,graph,chart [details, data, graph, chart]
173 174 visualise imagine [imagine]
174 175 repetition over and over [over and over]
175 176 poor weak [weak]
176 177 durable stronger,longer [stronger, longer]
177 178 pollutant contaminant [contaminant]
178 179 continue ahead, go on, keep doing [ahead, go on, keep doing]

179 rows × 4 columns

data2 = pd.DataFrame(columns=["序号", "单词", "类型"])for i in range(len(data)):df2 = pd.DataFrame({"序号":[i+1],"单词":[data['考点词'][i]], "类型":["考点词"]})data2 = data2.append(df2)for j in data['test'][i]:df2 = pd.DataFrame({"序号":[i+1],"单词":[j], "类型":["同义词"]})data2 = data2.append(df2)
data2['单词'] = data2['单词'].apply(strip) # 应用  取出前后空字符串 函数
data2
序号 单词 类型
0 1 reserve 考点词
0 1 book 同义词
0 2 in advance 考点词
0 2 ahead 同义词
0 2 before 同义词
0 3 have to 考点词
0 3 must 同义词
0 3 should 同义词
0 3 need 同义词
0 3 require 同义词
0 3 neceaasry 同义词
0 3 be supposed to 同义词
0 3 demand 同义词
0 3 order 同义词
0 4 adjust 考点词
0 4 change 同义词
0 4 alter 同义词
0 4 modify 同义词
0 4 shift 同义词
0 4 revert 同义词
0 5 and 考点词
0 5 and also 同义词
0 5 as well as 同义词
0 5 with 同义词
0 5 in addition 同义词
0 5 not only…but also 同义词
0 6 but 考点词
0 6 however 同义词
0 6 yet 同义词
0 6 instead 同义词
... ... ... ...
0 169 empty 同义词
0 169 abandoned 同义词
0 170 donate 考点词
0 170 charity 同义词
0 170 give 同义词
0 170 volunteer 同义词
0 171 work 考点词
0 171 item 同义词
0 172 turn 考点词
0 172 switch 同义词
0 173 information 考点词
0 173 details 同义词
0 173 data 同义词
0 173 graph 同义词
0 173 chart 同义词
0 174 visualise 考点词
0 174 imagine 同义词
0 175 repetition 考点词
0 175 over and over 同义词
0 176 poor 考点词
0 176 weak 同义词
0 177 durable 考点词
0 177 stronger 同义词
0 177 longer 同义词
0 178 pollutant 考点词
0 178 contaminant 同义词
0 179 continue 考点词
0 179 ahead 同义词
0 179 go on 同义词
0 179 keep doing 同义词

700 rows × 3 columns

# 保存文件
data2.to_excel(r"C:\Users\小红帽\AppData\Local\kingsoft\WPS Cloud Files\userdata\qing\filecache\小红帽的云文档\雅思\听力\剑桥雅思听力179考点词\雅思听力179考点词(整理).xlsx")
# 暂时调试不成功
import requests# 有道翻译 函数
def translate(string):data = {'doctype': 'json','type': 'AUTO','i':string}url = "http://fanyi.youdao.com/translate"r = requests.get(url, params=data)result = r.json()return result['translateResult'][0][0]['tgt']
translate("你好")
---------------------------------------------------------------------------JSONDecodeError                           Traceback (most recent call last)<ipython-input-8-c4aa0877c98e> in <module>()8     result = r.json()9     return result['translateResult'][0][0]['tgt']
---> 10 translate("你好")<ipython-input-8-c4aa0877c98e> in translate(string)6     url = "http://fanyi.youdao.com/translate"7     r = requests.get(url, params=data)
----> 8     result = r.json()9     return result['translateResult'][0][0]['tgt']10 translate("你好")D:\yianzhuang\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs)890                     # used.891                     pass
--> 892         return complexjson.loads(self.text, **kwargs)893 894     @property~\AppData\Roaming\Python\Python37\site-packages\simplejson\__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)523             parse_constant is None and object_pairs_hook is None524             and not use_decimal and not kw):
--> 525         return _default_decoder.decode(s)526     if cls is None:527         cls = JSONDecoder~\AppData\Roaming\Python\Python37\site-packages\simplejson\decoder.py in decode(self, s, _w, _PY3)368         if _PY3 and isinstance(s, bytes):369             s = str(s, self.encoding)
--> 370         obj, end = self.raw_decode(s)371         end = _w(s, end).end()372         if end != len(s):~\AppData\Roaming\Python\Python37\site-packages\simplejson\decoder.py in raw_decode(self, s, idx, _w, _PY3)398             elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':399                 idx += 3
--> 400         return self.scan_once(s, idx=_w(s, idx).end())JSONDecodeError: Expecting value: line 1 column 1 (char 0)

雅思听力179(雅思听力同义词替换python整理)相关推荐

  1. 中国大陆部分雅思考点新增雅思考试(IELTS)机考模式

    北京2018年8月13日电 /美通社/ -- 为了满足雅思考生不断增长的考试需求,并向雅思考生提供更好的服务,英国文化教育协会(雅思考试主办方)宣布,中国大陆部分雅思考点将新增雅思考试(IELTS)机 ...

  2. 大学计算机专业高考听力,高考英语听力测试对考生听力策略反拨作用的研究

    摘要: 高考是我国高等院校招生的全国统一性考试,高考听力测试作为听力测试一部分主要测试高考考生的英语听力能力是否达到高校招生的选拔要求.在2011年,有933余万考生参加了高考,其中山东省参加高考的考 ...

  3. 学计算机高考英语听力考试,高考英语听力机考,常识、实操、备考,你要知道这些...

    原标题:高考英语听力机考,常识.实操.备考,你要知道这些 关于北京高考英语听力考试,从相关政策.考试安排和注意事项,再到备考,你需要知道的,都在这儿啦! 这些基本常识你要知道: 北京高考英语听力考试 ...

  4. 英语在线听力翻译器_英语听力翻译app下载-英语听力翻译官方版v2.1.4-upan

    英语听力翻译是一款英语翻译在线教学的软件,一个为用户轻松学习大量英语知识的内容,指在使用户将课内英语知识和课外英语知识结合起来,致力于让用户自由地学习英语哦!在英语听力翻译应用程序中,它还可以帮助用户 ...

  5. [转帖]华为的“大海思”与“小海思”

    华为的"大海思"与"小海思" https://www.cnbeta.com/articles/tech/828275.htm 没先到华为海思这么狠.. 作为华为 ...

  6. 自考计算机 英语有听力吗,英语自考听力本科,自考只剩一门是什么感受?

    如果你想利用业余时间提升一下自己又没有好的选择,那么你可以看先关于下英语自考听力本科.通过本文的自考只剩一门是什么感受?,自考本科英语的口译与听力是怎么考的难吗?,自考英文本科,法语二外这么备考?,自 ...

  7. SEO批量文章繁简转换,同义词替换

    网站建设如何批量将繁体字转成简体字,繁简互转的方式很多,怎么将多篇繁体字文章转化为对应的简体字文章?SEO内容处理工具可以对在线或本地Word.Excel.TXT.HTML等繁体文章批量转化为简体文章 ...

  8. 文本数据增强二(EDA、同义词替换-新增-交换-删除-生成同义句)

    一.中文文本数据增强 (中文.同义句生成.enhance.augment.text.data.nlp.样本不均衡.语料不够.数据不足.扩充增加),相较于图片,中文文本数据强的效果似乎没那么靠谱(效果没 ...

  9. 【英语】重要句型+同义词替换(粉色笔记本)

    重要句型 vary from person to person The opinion of the problem varies from person to person. 对问题的看法因人而异 ...

最新文章

  1. LNMP--Nginx的日志切割
  2. webpack中loader加载器配置postCss自动添加CSS兼容前缀
  3. Bootstrap导航栏
  4. Spring的IOC原理(通俗解释)
  5. android画布原理,Android触摸事件如何实现笔触画布详解
  6. Spark GraphX相关使用方法
  7. 我的编程能力是从什么时候开始突飞猛进的?
  8. No rule to make target `/usr/lib/arm-linux-gnueabihf/libopencv_videostab.so.2.4.8'
  9. 设计模式必须遵守的六大原则
  10. java游戏开发教程_JAVA快速开发游戏代码实现 aide教程
  11. 用excel产生多组随机抽签数
  12. springboot整合mybatis拦截器分页
  13. 西安省某小学能耗监测及电力监控系统的研究与应用
  14. 2022年终总结(脚踏实地,仰望星空)
  15. 搭建asp会议签到系统 第三章 会议签到
  16. 信创-东方通和达梦适配
  17. PCB设计1 模块间的隔离
  18. HTML和CSS内容总结
  19. 腾讯发布“天眼云镜”主机安全产品
  20. 厦门计算机中专学校,厦门十大中专学校

热门文章

  1. 泛微发布内外协同的客服管理系统-睦客邻
  2. QT模型索引使用QModelIndex
  3. 小米mix刷鸿蒙系统,力拼鸿蒙和iOS!小米手机最新系统MIUI13来了:多款老机型无缘...
  4. TDSQL-C for PostgreSQL 主从架构详解
  5. 关于word中插入CAD大图的调整
  6. 怎样把酷狗音乐wav转化成高品质的MP3格式?
  7. Problem : 12306
  8. 你的设备中缺少重要的安全和质量修复
  9. 机器视觉应用于蔬果检测方面的相关英语词汇
  10. python3 PyPDF2分割pdf