1
我有一个字符串数组即如何检查开始/结束字,长空格分隔字符串
string[] input_Text = new string[] { "i am wanting to take admission in the univeristy of the islamabad", "we are enjoying all the talent here at the city of atlanta", "what are you doing there" };
和停用词阵列即
string[] stopWords = new string[] { " are ", " am ", " all ", " at ", " here ", " i ", " in ", " of ", " take ", " the ", " there ", " to ", " what ", " we ", " you " };
我有“,以取代INPUT_TEXT禁用词“(whiteSpace),但问题是,我在stopwords数组中使用”i“,并且文本中包含”i“,意味着在”i“开始处没有空白。所以问题是文本中的开始和结束字符串与stopWords不匹配,所以无法删除这些字词。我正在使用的循环是...
for (int i = 0; i < input_Text.Count(); i++)
{
for (int j = 0; j < stopWords.Count(); j++)
{
input_Text[i] = input_Text[i].Replace(stopWords[j], " ");
}
}
任何建议将不胜感激。
一种方法是使用''“'分隔'input_Text'作为分隔符并对每个元素(=每个单词)运行测试。您的停用词列表不需要前导空格和尾随空格。最后,重新组合成1个字符串,每个字符串之间有空格。 –