// StopWord.cpp
// Figures out stop words

#include "stopword.h"
#include <fstream.h>
#include <iostream.h>

// Constructor, sets stopword file name and reads from that file into words
StopWord::StopWord( string fileName ) : words("") {
		//cout << "\nStopWord List: \n	";
		ifstream infile(fileName.c_str(), ios::in);
		if (!infile) {
			cout << "\n!Error reading StopWord file (" << fileName <<")\n\nApplication terminated\n\n";
			exit(1);
		}
		string stopword;
		while (infile >> stopword) {
			//cout << "\nStopfile adding: " << stopword << "\nNew List: ";
			words.add(stopword);
			//words.testList();
			//cin.get();
		}
		infile.close();
		//words.testList(); // print out stopwords to make sure we succeeded
		//cout << "\nStopWord Initialization succesful!";
}

// return true if checkWord is in words, false otherwise
bool StopWord::isStopWord( string checkWord) {
		//cout << "\n StopWord called on " << checkWord <<"\n";
		if (words.get(checkWord) != NULL) {
			//cout << checkWord << " is a stop word\n";
			return true;
		}
		else {
			//cout << checkWord << " is not a stopword\n";
			//cout << "\n StopWords are: ";
			//words.testList();
			//cin.get();
			return false;
		}
}
