hi everyone ... first of all, i let you guyz know what i am doing here... and will list the problem tat i got....
well i want to performs a search for the seqence of words finding files containing all of the search words...
in my implememntation (.cpp)
and the main isCode:#include "inverted_index.h" #include "osdir.h" // InvertedIndex::tally // Pre: a word and file pair as strings // Post: adds the file to the index under word void InvertedIndex::tally(string word, string file) { inputType input(word, file); list.push_back( input ); } // InvertedIndex::search // Pre: a vector of strings as search terms // Post: a vector of strings being the files that all of the // input words occur in in the index. StringSet InvertedIndex::search(vector <string> words) { for(int i = 0; i < list.size(); i++) { if(list.word[i] == words) return list.file[i]; } }
can someone check my code for the red font.... please//Code:#include "inverted_index.h" int main() { // test the InvertedIndex InvertedIndex idx; idx.tally("cat", "cats.txt"); idx.tally("cat", "animals.txt"); idx.tally("cat", "everything.txt"); idx.tally("dog", "dogs.txt"); // searching idx for cat should give us three files vector <string> query; query.push_back("cat"); StringSet si = idx.search(query); if (si.contains("cats.txt") && si.contains("animals.txt") && si.contains("everything.txt") ) cout << "ok - search('cat')\n"; else cout << "fail - search('cat')\n"; if (si.contains("dogs.txt")) cout << "fail - search('cat') -- dogs.txt found\n"; else cout << "ok - search('cat') no dogs\n"; system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks


