基于改进编辑距离的字符串相似度求解算法

————————————

基金项目基金项目::吉林省发改委基金资助项目(吉发改高技[2012]747号)

作者简介作者简介::姜 华(1964-),男,副教授,主研方向:文本挖掘,Web 挖掘,聚类算法;韩安琪、王美佳、王 峥、吴雲玲,硕士研究生 收稿日期收稿日期::2012-10-15 修回日期修回日期::2013-01-17 E-mail :hanaq633@https://www.360docs.net/doc/6a15862121.html,

基于改进编辑距离的字符串相似度求解算法

姜 华a,b ,韩安琪a,b ,王美佳a,b ,王 峥a,b ,吴雲玲a,b

(东北师范大学 a. 计算机科学与信息技术学院;b. 智能信息处理吉林省高校重点实验室,长春 130117)

摘 要:编辑距离(LD)算法在求解两个字符串的相似问题时只考虑了编辑操作次数,未考虑字符串之间的公共子串对相似度的影响。为此,提出一种基于改进编辑距离的字符串相似度求解算法,对字符串相似度度量公式及Levenshtein 矩阵计算方法进行改进。在计算编辑距离时,以原有矩阵求出两字符串的最长公共子串及所有LD 回溯路径。选取一个单词作为源串,一组与源串不同程度相似的单词为目标串,将改进的相似度度量公式与现有的字符串相似度计算方法进行比较,改进公式减少了进入胜者表的目标串数,相似度的样本极差和标准差分别为0.331和0.150。实验结果表明,改进算法在不改变空间复杂度的情况下,计算字符串相似度的准确性更高,且查询方式更灵活。

关键词关键词::编辑距离;LD 算法;回溯路径;最长公共子串;相似度;模糊查询

Solution Algorithm of String Similarity

Based on Improved Levenshtein Distance

JIANG Hua a,b , HAN An-qi a,b , WANG Mei-jia a,b , WANG Zheng a,b , WU Yun-ling a,b

(a. School of Computer Science and Information Technology; b. University Key Laboratory of Intelligent Information Processing

in Jilin Province, Northeast Normal University, Changchun 130117, China)

【Abstract 】When calculating the similarity of strings, the Levenshtein Distance(LD) algorithm only considers the operating times and ignores the common substrings of two strings. Aiming at this problem, an improved Levenshtein distance algorithm is proposed to calculate the similarity. The new algorithm improves the formula of similarity and the Levenshtein matrix. When calculating the distance, the new algorithm calculates the longest common substring and all the LD backtracking paths in the original matrix at the same time. Selecting a word in the experiment as a source string, a set of similar words of the different degrees of the source string as a target string, the new similarity measure formula is compared with the existing string similarity calculation method, the new formula reduces the number of target strings into the winner table with similarity sample range and standard deviation of 0.331 and 0.150, respectively. Experimental results show that the new algorithm has higher accuracy and more flexible searching way in the same space complexity.

【Key words 】Levenshtein Distance(LD); LD algorithm; backtracking path; the longest common substring; similarity; fuzzy query DOI: 10.3969/j.issn.1000-3428.2014.01.047

计 算 机 工 程 Computer Engineering 第40卷 第1期 V ol.40 No.1 2014年1月

January 2014

·人工智能及识别技术人工智能及识别技术·· 文章编号文章编号::1000—3428(2014)01—0222—06 文献标识码文献标识码::A

中图分类号中图分类号::TP311.12

1 概述

字符串相似问题在文本比较、信息处理等领域,具有非常广泛的应用背景。求解2个字符串之间相似度的方法按照所依据特征的不同通常可以划分为3类[1]:基于字面相似的方法,基于统计关联的方法,基于语义相似的方法。其中,基于字面相似的方法主要有基于编辑距离的方法和基于相同字或词的方法。编辑距离(Levenshtein Distance, LD)算法通常被用于输入字符串的快速模糊匹配、英文辅助写作等领域,是一种经典而广为使用的方法。近年来常见的对编辑距离算法进行改进的方法有将编辑距离和Jaccard

相结合,编辑距离在中文背景下增加“替换”原子操作;在应用领域方面,编辑距离近似字符串和空间结合以支持多种查询,近似字符串匹配和在数据库上的关键字检索相结合等。文献[2-3]将整条记录作为一个字符串,通过计算 2个字符串的编辑距离来判断2条记录是否相似;文献[4-5]分别提出了2种计算字符串相似度的公式;文献[5]通过计算前后非相邻字符间的交换操作,改进了编辑距离算法,实现了编辑操作的最小化。文献[6]计算词汇之间的语义距离,同时赋予不同编辑操作不同的权重实现了相似句子检索。虽然后人对编辑距离增加了原子操作“替换”,但编辑距离规定的编辑操作仍不够灵活。

相关文档
最新文档