Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <Wt/WStringUtil>
00008
00009 #include "Dictionary.h"
00010 #include <fstream>
00011 #include <iostream>
00012 #include <time.h>
00013 #include <stdlib.h>
00014
00015 std::wstring RandomWord(Dictionary dictionary)
00016 {
00017 std::ifstream dict;
00018 if(dictionary == DICT_NL) {
00019 dict.open("dict-nl.txt");
00020 } else {
00021 dict.open("dict.txt");
00022 }
00023
00024 std::string retval;
00025 int numwords = 0;
00026 while(dict) {
00027 getline(dict, retval);
00028 numwords++;
00029 }
00030 dict.clear();
00031 dict.seekg(0);
00032
00033 srand(time(0));
00034 int selection = rand() % numwords;
00035
00036 while(selection--) {
00037 getline(dict, retval);
00038 }
00039 getline(dict, retval);
00040 for(unsigned int i = 0; i < retval.size(); ++i)
00041 if(retval[i] < 'A' || retval[i] > 'Z')
00042 std::cout << "word " << retval << " contains illegal data at pos " << i << std::endl;
00043
00044 return Wt::widen(retval);
00045 }
00046