3
0
Fork 0

+ able now to retrieve suggestions

small_fixes
kelson42 12 years ago
parent 7c52bceb4b
commit 730c5db384

@ -37,7 +37,7 @@ int main(int argc, char **argv) {
/* Init the variables */ /* Init the variables */
const char *filePath = NULL; const char *filePath = NULL;
const char *suggestion = NULL; const char *pattern = NULL;
int option_index = 0; int option_index = 0;
int c = 0; int c = 0;
@ -48,15 +48,19 @@ int main(int argc, char **argv) {
static struct option long_options[] = { static struct option long_options[] = {
{"verbose", no_argument, 0, 'v'}, {"verbose", no_argument, 0, 'v'},
{"suggest", required_argument, 0, 's'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
if (c != -1) { if (c != -1) {
c = getopt_long(argc, argv, "v", long_options, &option_index); c = getopt_long(argc, argv, "vs:", long_options, &option_index);
switch (c) { switch (c) {
case 'v': case 'v':
break; break;
case 's':
pattern = optarg;
break;
} }
} else { } else {
if (optind < argc) { if (optind < argc) {
@ -85,6 +89,16 @@ int main(int argc, char **argv) {
string content; string content;
string contentType; string contentType;
unsigned int contentLength = 0; unsigned int contentLength = 0;
string suggestion;
if (pattern != NULL) {
std::cout << "Searching suggestions for: " << pattern << std::endl;
reader->searchSuggestionsSmart(pattern, 10);
while (reader->getNextSuggestion(suggestion)) {
std::cout << suggestion << std::endl;
}
}
/* /*
if (reader->getContentByUrl(mainPageUrl, content, contentLength, contentType)) { if (reader->getContentByUrl(mainPageUrl, content, contentLength, contentType)) {
@ -92,8 +106,8 @@ int main(int argc, char **argv) {
} }
*/ */
tree< pair<string, unsigned> > tree; // tree< pair<string, unsigned> > tree;
updateSuggestionTree(tree, string(suggestion)); //updateSuggestionTree(tree, string(suggestion));
delete reader; delete reader;
} else { } else {

Loading…
Cancel
Save