1
Good evening guys, I need help. I am doing pre-word processing and for that I need to remove from a book in format . txt all stopwords
found in a text file also "stopwords_br.txt". I found a program I think a little bit like what I’m looking for. However this in C++ and I do not understand the commands.
Help me if possible. Thank you.
string line, deleteline;
ifstream stopword;
stopword.open("example.txt");
if (stopword.is_open())
{
while ( getline (stopword,line) )
{
cout << line << endl;
}
stopword.close();
}
else cout << "Unable to open file";
ofstream temp;
temp.open("temp.txt");
cout << "Please input the stop-word you want to delete..\n ";
cin >> deleteline;
while (getline(stopword,line))
{
if (line != deleteline)
{
temp << line << endl;
}
}
temp.close();
stopword.close();
remove("example.txt");
rename("temp.txt","example.txt");
cout <<endl<<endl<<endl;
system("pause");
return 0;
The general idea is good but (1) only treats a stopword; (2) for example being "a" a stopword, would not remove all "a" from all words in the text?
– JJoao