统计和展示单词真题词频的问题
统计和展示单词真题词频的问题
最近在做考研词频和真题例句相关的工作,其实之前写的这篇博客就已经记录了简单、可复现的民用实现方法,商用级别的实现提需求给开发就好了。虽然知道简易的解决方案,但是实际应用到产品中还有各种各样的问题。
如何计算词频
一般来说,在统计词频的时候应当把单词变形(inflection)统计在内,如plays、played和playing不应当单独计数,而统计在play上。
通常这样的问题会采用词型还原(lemmatization)或是词干还原(stemming)的方式解决。
词型还原和词干还原的区别在于,词型还原会考虑单词的词性,而词干还原仅会参照字典将单词还原成词干形式,例如:
lemmatize('meeting', 'n') = meeting
lemmatize('meeting', 'v') = meet
stem('meeting') = meet
因此,词型还原更适合用在需要判断语境的词频计算中。
"I was meeting a girl."
"There was a meeting yesterday."
对于名词与动名词,在词型还原的时候,程序会查询字典,如果程序能在字典中查到名词的条目,则会将lemma归为该名词条目;如果查不到,则会还原成动词,例如:
"When our time of mourning is over, we press forward."
mourning -> mourning
"I am looking forward to listening to to you song."
listening -> listen
同理,对于派生词,因为派生词自己也在字典中拥有条目,所以也不会出现promotion、promotional还原成promote这样的情况,造成错误统计。
友商的解决情况
以某翻译软件为例,大部分词频与我自己写的脚本一致,但是多试几个词,还是会发现很多细节不同之处的。
例如isolate,在2010-2022年的真题中直接使用PDF阅读器搜索能找到如下内容:
1.(2014年英语一)...but opponents of change among the regulators insist that keeping outsiders out of a law firm isolates lawyers from the pressure to make money rather than serve clients ethically.
2.(2016年英语一)[A] isolated
3.(2012年英语二)Companies had won patents for isolated DNA for decades...
4.(2012年英语二)In October the Department of Justice filed a brief in the Myriad case, arguing that an isolated DNA molecule is no less a product of nature...
5.(2015年英语二)No matter how isolated you might feel and how serious the situation is, you should always remember that you are not alone.
6.(2021年英语一)[B] isolated
该软件提示isolate在考研中出现了3次,分别是句子1、句子3和句子4。
因为isolated存在形容词这一条目,使用NLTK分词不仅会将isolated标记为形容词,而且将词频统计在isolated上。
但是查阅字典后发现,isolated形容词有三个意思,每一个都与句中用法对应不上——一个是“far away from other places”,另一个是“having minimal contact or little in common with others”,还有一个是“ single; exceptional”,因此可以判断,isolated在讲DNA的两句中是被动分词,采用的是动词“obtain or extract (a compound, microorganism, etc.) in a pure form”的生化专业释义。
这个案例的启示是:不使用神经网络的模型做词频统计,还是会有边缘案例出现,NLTK等其他库只能解决一部分的问题。
宇宙的尽头仍然是数据标注以及人工校对。
产品经理的想法与现实
对于统计词频这件事情,负责这个项目的产品经理们似乎有不同的意见,这也是本篇开头提到的问题。
对于考纲词mourn,无论是NLTK还是友商的软件均判定其为零频词,但是检索真题PDF文档之后发现,2015年英语二有这样的一句话:
When our time of mourning is over, we press forward, stronger with a greater understanding...
剩余内容已隐藏