我無法創建從字符串中刪除停用詞的代碼。這裏是我的代碼:從asp.net中的字符串中刪除停用詞c#
String Review="The portfolio is fine except for the fact that the last movement of sonata #6 is missing. What should one expect?";
string[] arrStopword = new string[] {"a", "i", "it", "am", "at", "on", "in", "to", "too", "very","of", "from", "here", "even", "the", "but", "and", "is","my","them", "then", "this", "that", "than", "though", "so", "are"};
StringBuilder sbReview = new StringBuilder(Review);
foreach (string word in arrStopword){
sbReview.Replace(word, "");}
Label1.Text = sbReview.ToString();
運行
Label1.Text = "The portfolo s fne except for fct tht lst movement st #6 s mssng. Wht should e expect? "
我希望它必須返回"portofolio fine except for fact last movement sonata #6 is missing. what should one expect?"
有人知道如何解決這個問題時
?
這是一個辛辣的肉丸。不會想到「Except」。 – LocEngineer
可愛,優雅的解決方案。使用Except超載例如忽略大小寫增強.Except(arrStopword,StringComparer.InvariantCultureIgnoreCase) – getsetcode