|
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 #include "itk.h" |
|
18 |
|
19 #include "thaianalysis.h" |
|
20 |
|
21 #include "CLucene.h" |
|
22 |
|
23 #include <iostream> |
|
24 |
|
25 #include "testutils.h" |
|
26 |
|
27 #include "evaluationtool.h" |
|
28 #include "analysisunittest.h" |
|
29 #include "cjkanalyzer.h" |
|
30 #include "ngram.h" |
|
31 |
|
32 using namespace analysis; |
|
33 using namespace evaluationtool; |
|
34 using namespace lucene::util; |
|
35 |
|
36 using namespace lucene::analysis; |
|
37 |
|
38 template<int N> |
|
39 void KoreanNgramAnalyzerTest(Itk::TestMgr* /*testMgr*/) { |
|
40 CjkNGramAnalyzer analyzer(N); |
|
41 |
|
42 Corpus corpus(KOREAN_TEXTCORPUS); |
|
43 |
|
44 for (int i = 0; i < corpus.size(); i++) { |
|
45 printTokens(analyzer, corpus[i]); |
|
46 } |
|
47 } |
|
48 |
|
49 template<int N> |
|
50 void JamuNgramAnalyzerTest(Itk::TestMgr* /*testMgr*/) { |
|
51 JamuNGramAnalyzer analyzer(N); |
|
52 |
|
53 Corpus corpus(KOREAN_TEXTCORPUS); |
|
54 |
|
55 for (int i = 0; i < corpus.size(); i++) { |
|
56 printTokens(analyzer, corpus[i]); |
|
57 } |
|
58 } |
|
59 |
|
60 template<int N> |
|
61 void ChinesePrcNgramAnalyzerTest(Itk::TestMgr* /*testMgr*/) { |
|
62 CjkNGramAnalyzer analyzer(N); |
|
63 |
|
64 Corpus corpus(CHINESE_PRC_TEXTCORPUS); |
|
65 |
|
66 for (int i = 0; i < corpus.size(); i++) { |
|
67 printTokens(analyzer, corpus[i]); |
|
68 } |
|
69 } |
|
70 |
|
71 Itk::TesterBase * CreateNgramAnalyzerUnitTest() |
|
72 { |
|
73 using namespace Itk; |
|
74 SuiteTester |
|
75 * testSuite = |
|
76 new SuiteTester( "ngram" ); |
|
77 |
|
78 testSuite->add( "korean_1gram", KoreanNgramAnalyzerTest<1>, "korean_1gram" ); |
|
79 testSuite->add( "korean_2gram", KoreanNgramAnalyzerTest<2>, "korean_2gram" ); |
|
80 testSuite->add( "chinese_prc_1gram", ChinesePrcNgramAnalyzerTest<1>, "chinese_prc_1gram" ); |
|
81 testSuite->add( "chinese_prc_2gram", ChinesePrcNgramAnalyzerTest<2>, "chinese_prc_2gram" ); |
|
82 testSuite->add( "jamu_1gram", JamuNgramAnalyzerTest<1>, "jamu_1gram" ); |
|
83 testSuite->add( "jamu_2gram", JamuNgramAnalyzerTest<2>, "jamu_2gram" ); |
|
84 |
|
85 return testSuite; |
|
86 } |