【机器翻译】【数据集】WMT2022的第一个生物医药训练集获得

在处理一个包含1.5万多段落的PubMed数据集时,遇到langdetect.lang_detect_exception.LangDetectException错误,提示文本中没有检测到语言特征。为避免影响数据处理,脚本中通过try-except块捕获该异常并选择跳过,同时记录错误次数。fetch_pubmed_articles方法已修改,当检测到此类异常时,会继续处理剩余数据。后续步骤包括对数据进行分句和对齐,但目前尚未实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

书接上文

遇到一个报错

langdetect.lang_detect_exception.LangDetectException: No features in text.

没有检测出语言类型

那跳过吧,反正数据挺多的 (不是

修改这个脚本的fetch_pubmed_articles方法

# fetch
err=0

def fetch_pubmed_articles(ids):
	ids = ",".join(ids)
	handle = Entrez.efetch(db="pubmed", id=ids, retmode="xml")
	records = Entrez.read(handle)
	#print(records)
	set_articles = []
	set_langs = []
	for record in get_set_articles(records):
		#print(record)
		try:
			article, langs = build_article(record)
			set_articles.append(article)
			set_langs.append(langs)
		except LangDetectException as e:
			err+=1
			print(e+":"+str(err))
		finally:
			continue # 跳过吧
	handle.close()
	#print(len(articles))
	return set_articles, set_langs

这个数据集是段落数据,1.5w多条

后续如果要使用还得分句,对齐,如果要用有时间再做吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值