I am having trouble creating code which removes stop words from a string. Here is my code:
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();
when running Label1.Text = "The portfolo s fne except for fct tht lst movement st #6 s mssng. Wht should e expect? "
I expect it must return "portofolio fine except for fact last movement sonata #6 is missing. what should one expect?"
Anybody know how to solve this?
You could use " a ", " I ", etc to make sure the program only removes those words if they're used as a word (so with spaces around them). Just replace them with a space to keep the formatting as it is.