当前位置: 首页 > news >正文

seo的站外优化流程郑州网站设计的公司

seo的站外优化流程,郑州网站设计的公司,做行业分析的网站,沈阳个人网站建设选择lcs文本相似度常见的问题是检测并显示两个文本的差异#xff08;尤其是几百行或几千行#xff09;。 使用纯java.lang.String类方法可能是一种解决方案#xff0c;但是对于此类操作最重要的问题是#xff0c;“性能”将不能令人满意。 我们需要一种有效的解决方案#xff… lcs文本相似度 常见的问题是检测并显示两个文本的差异尤其是几百行或几千行。 使用纯java.lang.String类方法可能是一种解决方案但是对于此类操作最重要的问题是“性能”将不能令人满意。 我们需要一种有效的解决方案其可能具有以下观点 文字差异工具示例 该问题包含两个部分 检测两个文本的差异为了检测差异此解决方案中使用了一种有效的LCS最长公共子序列动态算法 。 该解决方案具有Otext1WordCount * text2WordCount复杂度并在下面被编码为“ longestCommonSubsequence”方法。 可视化差异为了进行可视化使用了基于HTML标签的方法该方法将text2的新单词标记为绿色将text1的旧单词标记为红色。 此解决方案具有OchangedWordsCount *text1WordCount text2WordCount复杂度并在下面被编码为“ markTextDifferences”方法。 注意1为简单起见“ normalizeText”方法用于删除\ n\ t和多个空格字符。 注意2此类创建为Vaadin组件。 但是“ longestCommonSubsequence”是纯通用的“ markTextDifferences”方法是基于HTML的可视组件的通用因此它们也可以用于不同的框架。 import java.util.ArrayList; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.VerticalLayout;/** * Text comparison component which marks differences of two texts with colors. * * author cb */ public class TextCompareComponent extends CustomComponent {private Layout mainLayout new VerticalLayout();private ArrayListString longestCommonSubsequenceList;private static final String INSERT_COLOR #99FFCC;private static final String DELETE_COLOR #CB6D6D;public TextCompareComponent(String text1, String text2) {text1 normalizeText(text1);text2 normalizeText(text2);this.longestCommonSubsequenceList longestCommonSubsequence(text1, text2);String result markTextDifferences(text1, text2, longestCommonSubsequenceList, INSERT_COLOR, DELETE_COLOR);Label label new Label(result, Label.CONTENT_XHTML);mainLayout.addComponent(label);setCompositionRoot(mainLayout);}/*** Finds a list of longest common subsequences (lcs) of given two texts.* * param text1* param text2* return - longest common subsequence list*/private ArrayListString longestCommonSubsequence(String text1,String text2){String[] text1Words text1.split( );String[] text2Words text2.split( );int text1WordCount text1Words.length;int text2WordCount text2Words.length;int[][] solutionMatrix new int[text1WordCount 1][text2WordCount 1];for (int i text1WordCount - 1; i 0; i--) {for (int j text2WordCount - 1; j 0; j--) {if (text1Words[i].equals(text2Words[j])){solutionMatrix[i][j] solutionMatrix[i 1][j 1] 1;}else {solutionMatrix[i][j] Math.max(solutionMatrix[i 1][j],solutionMatrix[i][j 1]);}}}int i 0, j 0;ArrayListString lcsResultList new ArrayListString();while (i text1WordCount j text2WordCount) {if (text1Words[i].equals(text2Words[j])) {lcsResultList.add(text2Words[j]);i;j;} else if (solutionMatrix[i 1][j] solutionMatrix[i][j 1]) {i;}else {j;}}return lcsResultList;}/*** Normalizes given string by deleting \n, \t and extra spaces.* * param text - initial string* return - normalized string*/private String normalizeText(String text) {text text.trim();text text.replace(\n, );text text.replace(\t, );while (text.contains( )) {text text.replace( , );}return text;}/*** Returns colored inserted/deleted text representation of given two texts.* Uses longestCommonSubsequenceList to determine colored sections.** param text1* param text2* param lcsList* param insertColor* param deleteColor* return - colored result text*/private String markTextDifferences(String text1, String text2,ArrayListString lcsList, String insertColor, String deleteColor) {StringBuffer stringBuffer new StringBuffer();if (text1 ! null lcsList ! null) {String[] text1Words text1.split( );String[] text2Words text2.split( );int i 0, j 0, word1LastIndex 0, word2LastIndex 0;for (int k 0; k lcsList.size(); k) {for (i word1LastIndex, j word2LastIndex;i text1Words.length j text2Words.length;) {if (text1Words[i].equals(lcsList.get(k)) text2Words[j].equals(lcsList.get(k))) {stringBuffer.append(SPAN lcsList.get(k) /SPAN);word1LastIndex i 1;word2LastIndex j 1;i text1Words.length;j text2Words.length;}else if (!text1Words[i].equals(lcsList.get(k))) {for (; i text1Words.length !text1Words[i].equals(lcsList.get(k)); i) {stringBuffer.append(SPAN styleBACKGROUND-COLOR: deleteColor text1Words[i] /SPAN);}} else if (!text2Words[j].equals(lcsList.get(k))) {for (; j text2Words.length !text2Words[j].equals(lcsList.get(k)), j) {stringBuffer.append(SPAN styleBACKGROUND-COLOR: insertColor text2Words[j] /SPAN);}}}}for (; word1LastIndex text1Words.length; word1LastIndex) {stringBuffer.append(SPAN styleBACKGROUND-COLOR: deleteColor text1Words[word1LastIndex] /SPAN);}for (; word2LastIndex text2Words.length; word2LastIndex) {stringBuffer.append(SPAN styleBACKGROUND-COLOR: insertColor text2Words[word2LastIndex] /SPAN);}}return stringBuffer.toString();} } 参考我们的JCG合作伙伴 Cagdas Basaraner在CodeBuild博客上使用LCS方法实现了通用文本比较工具 。 翻译自: https://www.javacodegeeks.com/2012/05/generic-text-comparison-tool-with-lcs.htmllcs文本相似度
http://www.zqtcl.cn/news/11154/

相关文章:

  • 太原定制网站制作流程手机淘宝客网站怎么做的
  • 哪家公司可以做网站做网站上海公司
  • 如何重装一下wordpress手机网站建设优化软件
  • 东莞seo建站公司江西建设厅官方网站
  • 最早的c2c网站杭州建设网 信用等级查询
  • 好的网站建设价格网站开发方法有哪些
  • 网站后期运营方案步骤c2c网站有哪些平台
  • 潮州网站设计html制作答题网页
  • 网站设计公司电话手机网站免费的
  • 洛阳网站开发公司梅州生态建设有限公司网站
  • 网站平台本地创建wordpress
  • 泗水网站建设ys178汽车网站页面设计
  • 珠海建设工程信息网站做网站的思想体会
  • 网站建设的域名的选择英文网站建设中
  • 中国林业工程建设协会网站校园网站素材
  • 免费发布推广的网站网站套餐表格模板
  • 郉台网站建设广州在线网站制作公司
  • 做那网站好网站建设 是否计入固定资产
  • 上海市崇明县建设中学网站腾讯云服务器控制台
  • 国外网站前台模板怎样优化网站app
  • 手机网站程序下载网站开发合同是否是技术合同
  • 铜仁市网站建设网站设置的流程第一步应该
  • 网站开发技术协议猎头
  • 无锡网站制作哪家值得信赖木渎网站建设
  • 国都建设(集团)有限公司网站怎么做五合一网站
  • 深圳二次源网站建设阿勒泰高端网站建设公司
  • 如何用花生壳做网站南宁网站空间
  • 营销网站科技微网站功能列表
  • 网站建设税率南京润盛建设集团有限公司网站
  • 做零食网站怎么样临沂培训学校网站建设