如何获得两个arraylists之间不匹配段最长的后续不匹配 [英] How to get the mismatch paragraph longest subsequence mismatch between two arraylists

查看:67
本文介绍了如何获得两个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 the  mismatch 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之间不匹配段最长的后续不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆