remove stop words from text C#

后端 未结 6 1977
忘掉有多难
忘掉有多难 2020-12-21 15:41

i want to remove an array of stop words from input string, and I have the following procedure

string[] arrToCheck = new string[] { \"try \", \"yourself\", \         


        
6条回答
  •  一生所求
    2020-12-21 16:01

    shorten your code, and use LINQ

    string[] arrToCheck = new string[] { "try ", "yourself", "before " };   
    var test = new StringBuilder("Did you try this yourself before asking"); 
    
    arrToCheck.ForEach(x=> test = test.Replace(x, "")); 
    
    Console.Writeln(test.ToString());
    

提交回复
热议问题