Changeset 926 for trunk/gsdl/src/mgpp/text/Queryer.cpp
- Timestamp:
- 2000-02-16T11:38:28+13:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/mgpp/text/Queryer.cpp
r879 r926 33 33 int main (int argc, char **argv) { 34 34 int ch; 35 char *filename = ""; 35 char *textfilename = ""; 36 char *indexfilename = ""; 36 37 char *basePath = ""; 37 38 … … 40 41 41 42 // process the command line arguments 42 while ((ch = getopt (argc, argv, "f: d:h")) != -1) {43 while ((ch = getopt (argc, argv, "f:t:d:h")) != -1) { 43 44 switch (ch) { 44 45 case 'f': /* input file */ 45 filename = optarg; 46 indexfilename = optarg; 47 break; 48 case 't': 49 textfilename = optarg; 46 50 break; 47 51 case 'd': … … 56 60 } 57 61 58 if ( filename[0] == '\0') {59 FatalError (1, "A file name must be specified with -f \n");62 if (textfilename[0] == '\0' || indexfilename[0] == '\0') { 63 FatalError (1, "A file name must be specified with -f and -t \n"); 60 64 } 61 65 62 66 // init the text system 63 67 TextData textData; 64 if (!textData.LoadData ( filename)) {65 FatalError (1, "Couldn't load text information for \"%s\"", filename);68 if (!textData.LoadData (textfilename)) { 69 FatalError (1, "Couldn't load text information for \"%s\"", textfilename); 66 70 } 67 71 68 72 // init the query system 69 73 IndexData indexData; 70 if (!indexData.LoadData (basePath, filename)) {71 FatalError (1, "Couldn't load index information for \"%s\"", filename);74 if (!indexData.LoadData (basePath, indexfilename)) { 75 FatalError (1, "Couldn't load index information for \"%s\"", indexfilename); 72 76 } 73 77 74 78 // do querying 75 79 QueryInfo queryInfo; 76 SetCStr (queryInfo.docLevel, " Chapter");77 queryInfo.maxDocs = 10;80 SetCStr (queryInfo.docLevel, "Document"); 81 queryInfo.maxDocs = 50; 78 82 queryInfo.sortByRank = true; 79 83 queryInfo.exactWeights = false; … … 81 85 queryInfo.needTermFreqs = true; 82 86 83 QueryResult queryResult;87 ExtQueryResult queryResult; 84 88 char query[2048]; 85 89 UCArray queryArray; 86 90 QueryNode *queryTree = NULL; 91 92 UCArray level; 93 level.clear(); 94 //SetCStr(level, ""); 95 87 96 88 97 while (true) { … … 95 104 if (queryArray.size() >= 2 && queryArray[0] == '.') { 96 105 if (queryArray[1] == 'q') break; // quit 106 97 107 98 if (queryArray[1] == 'p') { 108 if (queryArray[1] == 'i') { 109 cout << "current index="<< queryInfo.docLevel << "\nchange to index:"; 110 cin >> query; 111 queryInfo.docLevel.clear(); 112 SetCStr(queryInfo.docLevel, query); 113 cout << "index set to " << queryInfo.docLevel <<"\n"; 114 cin.getline(query, 2048, '\n'); 115 } 116 if (queryArray[1] == 'l') { 117 cout << "current level="<< level << "\nchange to level:"; 118 cin >> query; 119 level.clear(); 120 SetCStr(level, query); 121 cout << "level set to " << level <<"\n"; 122 cin.getline(query, 2048, '\n'); 123 } 124 125 126 else if (queryArray[1] == 'p') { 99 127 // print 100 128 UCArray docText; … … 117 145 PrintNode (cout, queryTree); 118 146 119 MGQuery (indexData, queryInfo, queryTree, queryResult );147 MGQuery (indexData, queryInfo, queryTree, queryResult, level); 120 148 cout << queryResult; 121 149 cout << "\n";
Note:
See TracChangeset
for help on using the changeset viewer.