NepomukDaemons
clucenefilter.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <CLucene/StdHeader.h>
00025 #include "clucenefilter.h"
00026 #include "clucenetokenizerconstants.h"
00027
00028 CL_NS_USE(analysis)
00029 CL_NS_USE(util)
00030
00031 namespace Nepomuk {
00032
00033 CLuceneFilter::CLuceneFilter(TokenStream* in, bool deleteTokenStream)
00034 : TokenFilter(in, deleteTokenStream)
00035 {
00036 }
00037
00038 CLuceneFilter::~CLuceneFilter(){
00039 }
00040
00041 bool CLuceneFilter::next(Token* t) {
00042 if (!input->next(t))
00043 return false;
00044
00045 TCHAR* text = t->_termText;
00046 const int32_t textLength = t->termTextLength();
00047 const TCHAR* type = t->type();
00048
00049 if ( type == tokenImage[APOSTROPHE] &&
00050 ( textLength >= 2 && _tcsicmp(text+textLength-2, _T("'s"))==0 ) )
00051 {
00052
00053 text[textLength-2]=0;
00054 t->resetTermTextLen();
00055
00056 return true;
00057
00058 } else if ( type == tokenImage[ACRONYM] ) {
00059 int32_t j = 0;
00060 for ( int32_t i=0;i<textLength;i++ ){
00061 if ( text[i] != '.' )
00062 text[j++]=text[i];
00063 }
00064 text[j]=0;
00065 return true;
00066
00067 } else {
00068 return true;
00069 }
00070 }
00071 }