LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-19-2009, 12:47 AM   #1
dnyaneshwari.chandarana
LQ Newbie
 
Registered: Jan 2009
Posts: 2

Rep: Reputation: 0
Post 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;

}
 
Old 01-19-2009, 12:59 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
I'm not a C++ programmer so probably can not help you, but two comments

1) post the code that you have problems with and tell us what the exact problem is
2) use code tags around your code
 
  


Reply

Tags
c++, query, removal


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Synaptic: "removal" vs. "complete removal" newbiesforever Linux - Software 2 08-24-2008 08:31 PM
interesting MySQL query/view query :s mjh Programming 3 03-25-2008 07:30 AM
mysql use output of one query in another query secretlydead Programming 2 11-19-2007 01:25 AM
help with mysql query: return nth rows in query hawarden Programming 2 07-31-2006 06:36 PM
removal invinciblegod Linux - Laptop and Netbook 3 06-06-2005 03:47 PM


All times are GMT -5. The time now is 08:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration