00001 /*========================================================================== 00002 * Copyright (c) 2004 Carnegie Mellon University. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.lemurproject.org/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 00012 // tnt - 6/2004 00013 00014 #ifndef _STRINGQUERY_HPP 00015 #define _STRINGQUERY_HPP 00016 00017 #include "TermQuery.hpp" 00018 #include "TextHandler.hpp" 00019 #include "common_headers.hpp" 00020 00021 namespace lemur 00022 { 00023 namespace parse 00024 { 00025 00031 00032 class StringQuery: public lemur::api::TermQuery, public lemur::api::TextHandler { 00033 public: 00034 StringQuery(); 00035 StringQuery(const char* query, const char* qid=NULL); 00036 StringQuery(const string& query, const string& qid=""); 00037 ~StringQuery(); 00038 00040 void startTermIteration() const{iter = 0;} 00041 bool hasMore() const{ return iter < tokens.size();} 00042 const lemur::api::Term* nextTerm() const; 00043 00044 void addTerm(const string& token); 00045 void addTerm(const char* token); 00046 void parse(const string& token); 00047 00049 char* handleWord(char* word); 00050 char* handleSymbol(char* sym); 00051 00052 protected: 00053 vector<string> tokens; 00054 mutable int iter; 00055 mutable lemur::api::Term tt; 00056 }; 00057 00058 } 00059 } 00060 00061 #endif