本文整理汇总了C++中TokenStream::next方法的典型用法代码示例。如果您正苦于以下问题:C++ TokenStream::next方法的具体用法?C++ TokenStream::next怎么用?C++ TokenStream::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenStream
的用法示例。
在下文中一共展示了TokenStream::next方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]){
if (argc != 2){
cout << "Usage: " << argv[0] << " <filename>" << endl;
exit (1);
}
else {
try {
FileReader *reader = _CLNEW FileReader(argv[1],"UTF-8");
Analyzer *analyzer = new StandardAnalyzer();
TokenStream *tokenStream = analyzer->tokenStream(_T("iets"), reader);
Token token;
while (tokenStream->next(&token)){
char buffer[1000];
STRCPY_TtoA(buffer, token.termText(), 1000);
cout << "\t token: " << buffer;
STRCPY_TtoA(buffer, token.type(), 1000);
cout << " type: " << buffer << endl;
}
tokenStream->close();
delete tokenStream;
//reader->close();
delete reader;
delete analyzer;
} catch (CLuceneError &e){
cerr << e.what() << endl;
}
}
}
示例2: print_remaining_tokens
void print_remaining_tokens(std::ostream& out, TokenStream& tokens)
{
for (int i=0; i < tokens.remaining(); i++) {
if (i != 0) out << " ";
out << get_token_text(tokens.next(i).match);
out << "(" << tokens.nextStr(i) << ")";
}
}
示例3: dump_remaining_tokens
void dump_remaining_tokens(TokenStream& tokens)
{
for (int i=0; i < tokens.remaining(); i++) {
if (i != 0)
printf(" ");
Value nextStr;
tokens.getNextStr(&nextStr, i);
printf("%s(%s)", get_token_text(tokens.next(i).match), as_cstring(&nextStr));
}
printf("\n");
}
示例4: getAnalyzedString
void getAnalyzedString(const wchar_t* input, wchar_t* output)
{
CL_NS_USE(index)
CL_NS_USE(util)
CL_NS_USE(store)
CL_NS_USE(search)
CL_NS_USE(document)
CL_NS_USE(queryParser)
CL_NS_USE(analysis)
CL_NS_USE2(analysis,standard)
/*
* StandardAnalyzer sAnalyser;
* Used before but this but this includes stopwords filters
*/
CustomAnalyzer sAnalyser((const wchar_t*)L"stdtokens>stdfilter>lowercase");
Reader* reader = _CLNEW StringReader(input);
TokenStream* ts = sAnalyser.tokenStream(_T("dummy"), reader );
Token t;
while(ts->next(&t))
{
wcscat(output,t.termText());
wcscat(output,L"* ");
}
size_t len = wcslen(output);
if(len == 0)
wcscpy(output,L"*");
else
{
if(output[len-1] == L' ')
output[len-1] = L'\0';
}
ts->close();
_CLDELETE(ts);
_CLDELETE(reader);
}