|
1 /** |
|
2 * Copyright 2002-2004 The Apache Software Foundation |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #ifndef _lucene_search_highlight_simplefragmenter_ |
|
18 #define _lucene_search_highlight_simplefragmenter_ |
|
19 |
|
20 #if defined(_LUCENE_PRAGMA_ONCE) |
|
21 # pragma once |
|
22 #endif |
|
23 |
|
24 #include "CLucene/analysis/AnalysisHeader.h" |
|
25 #include "CLucene/highlighter/Fragmenter.h" |
|
26 |
|
27 CL_NS_DEF2(search,highlight) |
|
28 |
|
29 /** |
|
30 * {@link Fragmenter} implementation which breaks text up into same-size |
|
31 * fragments with no concerns over spotting sentence boundaries. |
|
32 */ |
|
33 |
|
34 class SimpleFragmenter:public Fragmenter |
|
35 { |
|
36 private: |
|
37 LUCENE_STATIC_CONSTANT(int32_t, DEFAULT_FRAGMENT_SIZE =100 ); |
|
38 int32_t _currentNumFrags; |
|
39 int32_t _fragmentSize; |
|
40 |
|
41 public: |
|
42 /** |
|
43 * |
|
44 * @param fragmentSize size in bytes of each fragment |
|
45 */ |
|
46 SimpleFragmenter(int32_t fragmentSize = DEFAULT_FRAGMENT_SIZE); |
|
47 |
|
48 ~SimpleFragmenter(); |
|
49 |
|
50 /* (non-Javadoc) |
|
51 * @see org.apache.lucene.search.highlight.TextFragmenter#start(const TCHAR*) |
|
52 */ |
|
53 void start(const TCHAR* originalText); |
|
54 |
|
55 /* (non-Javadoc) |
|
56 * @see org.apache.lucene.search.highlight.TextFragmenter#isNewFragment(org.apache.lucene.analysis.Token) |
|
57 */ |
|
58 bool isNewFragment(const CL_NS(analysis)::Token * token); |
|
59 |
|
60 /** |
|
61 * @return size in bytes of each fragment |
|
62 */ |
|
63 int32_t getFragmentSize() const; |
|
64 |
|
65 /** |
|
66 * @param size size in bytes of each fragment |
|
67 */ |
|
68 void setFragmentSize(int32_t size); |
|
69 |
|
70 }; |
|
71 |
|
72 CL_NS_END2 |
|
73 |
|
74 #endif |