0

I have a problem with my program, which is used to segment a text file to display keywords and store them in another file,


assume that "my_text.txt" file contains all the words of my text, separated with a newline, and "empty_words.txt" file containing all the empty words like (to, they, as well, .. etc..), my problem is that i want to compare the words of the two files to extract the words that are not empty(keywords).


when I run my program, it shows me only the first word repeated several times.

thanks so much for helping me to solve this problem and this is a little code I wrote


string newContent;
string emptyWordsContent;
ifstream newText("my_text.txt",ios::in);
ifstream emptyWords("empty_words.txt", ios::in);
ofstream finalText("final_text.txt",ios::out);
 
 
while ( std::getline(newText, newContent)){
    while(std::getline(emptyWords, emptyWordsContent)){
        if(newContent!=emptyWordsContent){
            finalText<<newContent<<endl;
        }
    }
 
    }
aminoo
  • 59
  • 4
  • what do you mean by "empty"? what are you expecting as output? Maybe a short example could help. – tinkertime Dec 30 '13 at 21:01
  • i mean stopwords like( A..Z,0..9,hello,you,maybe,than,many,with,...etc) all the words could not be keywords – aminoo Dec 30 '13 at 21:32
  • so, when i tap hello mister yankee i am aminoo the program returns: mister yankee aminoo – aminoo Dec 30 '13 at 21:35

0 Answers0