stopword removal c++ query
Hi,
I have written a code for removal of stopwords from a string but the problem is I want to remove stopwords from a text file which contains a huge amount of text.I want my code to read the text file line by line and then remove the stopwords from each line. I tried using fstream but I couldnt succeed in doing so.Plz I need help to do so.This is something tht I have done so far.
Thankyou
code snippet
#include <iostream>
#include <string>
using namespace std;
int main ()
{ string arr[3]={" a","an","the"};
string base_str;
size_t i;
int ans=0;
cout<<"\n enter a string::";
getline(cin,base_str);
for(int j=0;j<3;j++)
{
i = base_str.find(arr[j]);
while(i != string::npos)
{
base_str.compare(arr[j]);
base_str.replace(i,arr[j].length(),"");
i = base_str.find(arr[j]);
}
cout<<base_str<<endl;
}
return 0;
}
|