2025年使用Matlab实现英文单词的"形近词"查找

使用Matlab实现英文单词的"形近词"查找引言 最近在背考博词汇 考博词汇是 12000 词左右 短时间内去记忆这么多单词是很有挑战性的 我个人习惯用的方法是 将陌生的长单词分成熟悉的小单词 用小单词造句 把生词的意义包含进去 多读一些这个生词的句子 在语境中加深意义 通过一个与这个生词长的很相近的自己很熟悉的词来记忆生词 艾宾浩斯多次复习减少遗忘 第三个方法就是用 形近词 去记忆

大家好,我是讯享网,很高兴认识大家。

引言

最近在背考博词汇,考博词汇是12000词左右.

短时间内去记忆这么多单词是很有挑战性的.我个人习惯用的方法是:

  1. 将陌生的长单词分成熟悉的小单词, 用小单词造句, 把生词的意义包含进去;
  2. 多读一些这个生词的句子, 在语境中加深意义;
  3. 通过一个与这个生词长的很相近的自己很熟悉的词来记忆生词.
  4. 艾宾浩斯多次复习减少遗忘.

这个方法我感觉是很好用的, 就跟有个朋友给你介绍新朋友一样.

而且, 因为在背单词的时候常常很容易将一个单词与他的形近词相混淆, 所以, 在背单词的时候如果能查找形近词该多好啊.

把一些形近词放到一起, 便于记忆,也便于辨析.

比如:

complexity complicacy complicate complicity simplicity

讯享网网上虽然有不少英语学习爱好者和研究教育机构整理的形近词词库,遗憾的是,并没有一款词典能够提供形近词查询功能.

金山词霸等词典软件虽然可以使用通配符, 但是, 通过通配符去找形近词需要你自己去拟定通配规则, 很麻烦.

考察了一下,做了个简单的小程序,这下子,大大辅助我背单词了.

方法

用正则表达式也可以实现, 不过, 需要你自己定义n多的变形规则.很麻烦.

在这里,我主要是通过计算两词之间的编辑距离(edit distance)[1]来判断.

另外,还有Jaro–Winkler distance[5], 还有发音相似度(phonetic distance)[6]都可以考虑使用, 我这里暂时只用了L氏距离.

关于L氏算法的一个直观的实例:


讯享网

用法

  1. 提供你想查询的词汇;
  2. 提供相似度阈值n(n就是edit distance,意思就是通过几次元编辑操作,插入,删除,替换, 可以实现两个单词的匹配);
  3. 提供你想要查询的词典(这里用的是一个txt格式的word list);

运行算法之后, 会对word list进行一次遍历,计算词典里每个词跟你要查询词之间的edit distance, 最后, 用一个阈值过滤出最相近的单词.

效果

edit distance取3.

从四六级词库里插simple的形近词,有4个(算上它自己):

代码

主函数:

讯享网%% this is the main function % Input : % wordToMatch - input word % distThresh - edit distance threshold, usually use 3 % dicPath - file path of the word list file, txt format with every % line of a single word % % Output : % command window output % % Created by visionfans @ 2011.07.20 function findSimilarWords(wordToMatch, distThresh, dicPath ) global word; word = wordToMatch; %% check parameters switch nargin case 0, error('Wrong arguments!'); case 1, distThresh = 3; dicPath = '46.txt'; end %% load word list wordList = loadWordList(dicPath); %% calculate edit distance editDist = cellfun(@calcEditDist,wordList); %% filter the similar words similarWords = wordList(editDist < distThresh); %% display results fprintf('There are %d similar words with "%s" : \n', length(similarWords), word); cellfun(@(x)fprintf('\t%s\n', x),similarWords); end

L氏距离计算函数:

%% this function is used to calculate the Levenshtein Edit Distance % % S1 and S2 are two words you want to calculate their edit distance % % Created by visionfans @ 2011.07.20 function dist = calcEditDist(s1,s2)         global word;     if nargin == 1         s2 = word;     end              %% calculate the edit distance with DP     m = length(s1);     n = length(s2);     if m*n == 0         dist = Inf;         return;     end          table = zeros(m,n);     table(:,1) = 0:m-1;     table(1,:) = 0:n-1;          for i=2:m         for j=2:n             if s1(i-1)==s2(j-1)                 table(i,j) = table(i-1,j-1);             else                 table(i,j) = 1 + min([(min(table(i-1,j),table(i,j-1))),table(i-1,j-1)]);             end         end     end          %% set result     dist = table(m,n);     return; end 

词典加载函数:

讯享网%% this function is used to load the dictionary file % The dictionary file is a text file with the format of every line be a % single word. % % You can find a word list file with adequate common words here: %    Kevin's Word List Page - http://wordlist.sourceforge.net/ % % Created by visionfans @ 2011.07.20 function wordList = loadWordList(dictPath)     fprintf('Loading word list ...\n');     fid = fopen(dictPath);     i = 1;     tline = fgetl(fid);     while ischar(tline)         wordList{i,1} = tline;         tline = fgetl(fid);         i = i+1;     end     fclose(fid); end


补充

有很多更全的词库文件,在这里[7]可以找到很多.

感谢Jukuu网工程师YNYS提供四六级word list, Thanks.微笑

-----------------------------------------------------------------------个人使用,所以懒得改C了.

References

[1] Edit distance , http://nlp.stanford.edu/IR-book/html/htmledition/edit-distance-1.html

[2] Levenshtein distance - Wikipedia, the free encyclopedia, http://en.wikipedia.org/wiki/Levenshtein_distance

[3] How to Write a Spelling Corrector, http://norvig.com/spell-correct.html

[4] Approximate string matching - Wikipedia, the free encyclopedia, http://en.wikipedia.org/wiki/Approximate_string_matching

[5] Jaro–Winkler distance - Wikipedia, the free encyclopedia, http://en.wikipedia.org/wiki/Jaro-Winkler_distance

[6] Soundex - Wikipedia, the free encyclopedia, http://en.wikipedia.org/wiki/Soundex

[7] Dictionary & Glossary Links; Downloadable Word Lists, http://www.net-comber.com/wordurls.html

    小讯
    上一篇 2025-02-08 19:07
    下一篇 2025-03-04 15:36

    相关推荐

    版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
    如需转载请保留出处:https://51itzy.com/kjqy/38537.html