equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "testutils.h" |
|
19 |
|
20 #include <iostream> |
|
21 |
|
22 using namespace lucene::util; |
|
23 |
|
24 bool readLine(Reader& reader, wchar_t* buf, int buflen) |
|
25 { |
|
26 int i = 0; |
|
27 while (i < buflen-1) |
|
28 { |
|
29 int c = reader.read(); |
|
30 if (c == -1 && i == 0) return false; // EOF |
|
31 if (c == '\r' || c == '\n' || c == -1) break; |
|
32 buf[i++] = c; |
|
33 } |
|
34 buf[i] = '\0'; |
|
35 return true; |
|
36 } |
|
37 |
|
38 void printTokens(lucene::analysis::Analyzer& analyzer, const wchar_t* text) |
|
39 { |
|
40 std::auto_ptr<lucene::analysis::TokenStream> stream( |
|
41 analyzer.tokenStream( L"", new StringReader( text ) ) ); |
|
42 |
|
43 lucene::analysis::Token token; |
|
44 while (stream->next(&token)) { |
|
45 int pos = token.getPositionIncrement(); |
|
46 if (pos == 0) { |
|
47 printf("|"); |
|
48 } else { |
|
49 for (int i = 0; i < pos; i++) printf(" "); |
|
50 } |
|
51 printf("'%S'", token.termText()); |
|
52 fflush(stdout); |
|
53 } |
|
54 printf("\n"); |
|
55 |
|
56 } |