如何获得两个arraylists之间不匹配段最长的后续不匹配

编程入门 行业动态 更新时间:2024-10-18 01:28:08
本文介绍了如何获得两个arraylists之间不匹配段最长的后续不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Hi Team,

Hi Team,

我们怎样才能得到两个字符串列表中不匹配段落最长的子序列不匹配

How can we get the mismatch paragraph longest sub-sequence mismatch between two arraylists of strings

这里我有两个word文档,并转换为每个文档的arraylist。从两个文档中获取添加,删除和不匹配的内容。

Here i am having two word documents , and convert into arraylist of each document.Required the added , deleted and mismatch things from the two documents.

我已经得到两个arraylists之间的不匹配,但需要添加,删除字符串,如下所示。

I already get the mismatches between two arraylists , but need to get added, deleted strings as below scenario.

如下截图所示,需要获得两个字符串结构列表中最长子序列不匹配的错误段落

As below screenshot , need to get themismatch paragraph longest sub-sequence mismatch between two arraylists of strings

推荐答案

尝试以下代码 List<string> list1 = new List<string>(); list1.Add("Video provides a powerful way to help you prove your points"); list1.Add("When you click here"); list1.Add("You can also type a keyword to search online for the video"); List<string> list2 = new List<string>(); list2.Add("Video provides a powerful way to help you prove your points"); list2.Add("When"); list2.Add("You can also type a keyword to search online for the video"); var minCount = Math.Min(list1.Count, list2.Count); int position = -1; int totalCharacters = 0; for (int i = 0; i < minCount; i++) { var text1 = list1[i]; var text2 = list2[i]; var str = text1.Except(text2).Union(text2.Except(text1)); if (str.Count() > totalCharacters) { totalCharacters = str.Count(); position = i + 1; } } if (position > -1) { MessageBox.Show("Item at position " + position + " has " + totalCharacters + " unmatched characters"); } else { MessageBox.Show("All data matched"); }

更多推荐

如何获得两个arraylists之间不匹配段最长的后续不匹配

本文发布于:2023-10-26 18:37:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531014.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不匹配   如何获得   最长   两个   arraylists

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!