/* File: Word.cc @authors: Antoine Waugh SID: 0309888 @date: 02/06/05 */ //System Includes #include #include #include #include //Other Includes #include "Node.h" #include "Word.h" #include "Hit.h" using namespace std; // constructor that takes in the word to be searched Word::Word(string searched_word) { //open word_cmp object file for searching word_cmp word_cmp_file("data/word.cmp"); //open word_pos object file for linking word_cmp to word_idx word_pos word_pos_file("data/word.pos"); //open word_idx object file to get required act,play and scene data word_idx word_idx_file("data/word.idx"); //open speeches_idx object file to get required speech start and finish lines speeches_idx speeches_idx_file("data/speeches.idx"); //open playfile_map object file to get required play name playfile_map playfile_map_file("data/playfile.map"); //to be a vector once tested vector returns; //search through word_cmp for all records where word == searched_word //iterate through all entries in word_cmp file for(int i=0; istartLine && count <=endLine+1) { speech.append(line+"\n"); } } //identify play, act and scene number from word_idx //identify play name Hit newHit(searched_word, play, act, scene, speech); returns.push_back(newHit); } } } for(int x = 0; x >::iterator i = x.begin(); //iterate through string while(i != x.end()) { //if iterator -> whitespace remove from string if(isWhitespace(*i)) i = x.erase(i); else i++; } return x; } bool Word::isWhitespace(const char& c) { //add other whitespace chars as necessary and return return (c == ' ' || c == '\t'); }