/* * Copyright (c) 2002 by Cliff Green. All rights reserved. Individual files * may be covered by other copyrights (as noted in the file itself). * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all such * copies. * * This software is provided "as is" and without any expressed or implied * warranties, including, without limitation, the implied warranties of * merchantibility and fitness for any particular purpose. */ //---------------------------------------------------------------------- // Source file: tstdict.cpp // Written by: Cliff Green, 2002 // Compiler: Metrowerks CodeWarrior Pro 6, g++ 3.0.4 // History: // Modified: Mar. 5, 2002 // By: Cliff Green // Comments: Dictionary class test application. //---------------------------------------------------------------------- // This commentheader supports documentation tools such as Doc++ and // Doxygen: http://www.doxygen.org/ //---------------------------------------------------------------------- /// Simple test harness for Dictionary class. /** * */ #include "dict.h" #include #include #include int main(int argc, char* argv[]) { Dictionary dict; if (argc <= 2) { std::cout << "Two command arguments required (both file names)." << std::endl; return 0; } std::cout << std::endl; std::string workStr; std::ifstream fs1(argv[1]); while (fs1 >> workStr) { Word w(workStr.c_str()); std::cout << "Word: " << w << " insert result: " << ( dict.insert(w) ? "true" : "false" ) << std::endl; } std::cout << std::endl; std::cout << std::endl; std::ifstream fs2(argv[2]); while (fs2 >> workStr) { Word w(workStr.c_str()); std::cout << "Word: " << w << " search result: " << ( dict.search(w) ?"true" : "false" ); WordVec const words (dict.getSameSdx(w)); if (words.empty()) { std::cout << " no similar sounding words" << std::endl; } else { std::cout << " sound alike words: "; for (WordVecSizeType i (0); i != words.size(); ++i) { std::cout << words[i]; } std::cout << std::endl; } } std::cout << "\nHave a nice day!" << std::endl; return 0; }