我想從我的文本文件中刪除停止的話,我寫了下面的代碼用於此目的刪除停用詞從文本文件
TextWriter tw = new StreamWriter("D:\\output.txt");
private void button1_Click(object sender, EventArgs e)
{
StreamReader reader = new StreamReader("D:\\input1.txt");
string line;
while ((line = reader.ReadLine()) != null)
{
string[] parts = line.Split(' ');
string[] stopWord = new string[] { "is", "are", "am","could","will" };
foreach (string word in stopWord)
{
line = line.Replace(word, "");
tw.Write("+"+line);
}
tw.Write("\r\n");
}
,但它並沒有在輸出文件顯示結果和輸出文件保持空白。
檢查了這一點:-http://stackoverflow.com/questions/10447980/remove-stop-words-from-text-c-sharp – 2013-03-14 18:22:03
你關閉輸出文件StreamWriter? – 2013-03-14 18:22:04
什麼是「零件」? – 2013-03-14 18:22:35