1,先比较两个字符串大小,记录差值(n)。
2,搜索str2中 字符增1位(减1位)能与str1中相同的个数,补齐,从n中减去这个值。
3,搜索str2中 字符增2位(减2位)能与str1中相同的个数,补齐,从n中减去这个值。
。
4,n==0或搜索不到时,直接补齐。呵呵 偶是菜菜,随便想想
2,搜索str2中 字符增1位(减1位)能与str1中相同的个数,补齐,从n中减去这个值。
3,搜索str2中 字符增2位(减2位)能与str1中相同的个数,补齐,从n中减去这个值。
。
4,n==0或搜索不到时,直接补齐。呵呵 偶是菜菜,随便想想
用StringBuilder类
StringBuilder str2=new StringBuilder();
str2.Append(str1.ToString());
因为这是我对文本处理时碰到的问题, 要判断两个文本是否具有一定的相似性, 如果相似则两个文本只取一个。 而判断txt2是否与txt1文本相似, 得知道txt2 最少得经过多少次 插入 和 删除 才能与txt1一样。(一个英文单词当作一个汉字看待).谢谢大家!!
有个公式啦,diff = (remove + insert)/ length1 + length2, 其中remove and insert are the number of words to be removed and inserted in the second in order to obtain the first one.
length1 and length2 are the length in wordds of the first and the second text, respectively.diff有个阈值,超过了就认为是不相似的了,