簡體   English   中英

單復數問題

[英]issue with singular and plural

比較兩個字符串時,我從第一個字符串中找到丟失的單詞

運行時我輸入句子:

  • 第一句話:這是我對匹配算法的測試
  • 第二句:這是我對網站申請的匹配算法的測試

現在我刪除了第二句中我的關鍵字的運行時間,現在看起來像(這是測試網站應用程序的匹配算法),然后按下顯示可移動按鈕

電流輸出

Missing Word Finds:用於匹配算法

我想

我的

.aspx:

 <asp:TextBox ID="ftextbox" runat="server" TextMode="MultiLine" Width="500px" Height="200px"></asp:TextBox>

<asp:TextBox ID="stextbox" runat="server" TextMode="MultiLine" Width="500px" Height="200px"></asp:TextBox>

<asp:Button ID="Button2" runat="server" Text="Show Removable Text" OnClick="Button2_Click"/><br />

.aspx.cs

        protected void Button2_Click(object sender, EventArgs e)
        {
            int i = 0;
            string tests;

            if (IsPostBack)
            {
                Label4.Text = "";
            }
            var string1 = ftextbox.Text.Split(' ');
            var string2 = stextbox.Text.Split(' ');

            //var result = string1.Except(string2);                 // means if want which is in first not in 2nd 

            foreach (var word in string1)
            {
                if (word == string2[i] || word + "ing" == string2[i] || word + "es" == string2[i] || word + "ies" == string2[i] || word.Replace("oo", "ee") == string2[i])
                {
                    string1[i] = "";
                    i++;
                }
            }

            tests = String.Join(" ", string1);

            Label4.Text += "Missing Word Finds: " + string.Join(" ", tests) + "<br/><br/>";

        }

輸出圖像

https://www.ef.com/in/english-resources/english-grammar/singular-and-plural-nouns/ - 單數和復數鏈接

請幫忙

如果有任何疑問或誤解,請告訴我:

我是在 C# 控制台上做的,你只需要調整一些簡單的變量。

            string textBox1 = "This is my testing for matching algoritham";
            string textBox2 = "This is testing for matchings algoritham for application by website";

            var string1 = textBox1.Split(' ');
            var string2 = textBox2.Split(' ');

            List<string> string2List = textBox2.Split(' ').ToList();

            string tests;

            List<string> missingWords = new List<string>();

            foreach (var word in string1)
            {
                if (!string2List.Contains(word) && !word.EndsWith("ing") && !word.EndsWith("es") && !word.EndsWith("ies"))
                {
                    missingWords.Add(word);
                }

                //if (word == string2[i] || word + "ing" == string2[i] || word + "es" == string2[i] || word + "ies" == string2[i] || word.Replace("oo", "ee") == string2[i])
                //{
                //    string1[i] = "";
                //    i++;
                //}
            }

            tests = String.Join(" ", missingWords);

            Console.Write("Missing Word Finds: " + string.Join(" ", tests));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM