• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

NepomukDaemons

clucenefilter.cpp

Go to the documentation of this file.
00001 /*
00002  * Modified version of StandardFilter.cpp for Nepomuk mostly to optimize for filename indexing
00003  * Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
00004  *
00005  * Based on StandardFilter.cpp from the CLucene package.
00006  * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Library General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Library General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Library General Public License
00019  * along with this library; see the file COPYING.LIB.  If not, write to
00020  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
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] && //we can compare the type directy since the type should always come from the tokenImage
00050              ( textLength >= 2 && _tcsicmp(text+textLength-2, _T("'s"))==0  ) )
00051         {
00052             // remove 's
00053             text[textLength-2]=0;
00054             t->resetTermTextLen();
00055 
00056             return true;
00057 
00058         } else if ( type == tokenImage[ACRONYM] ) {       // remove dots
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 }

NepomukDaemons

Skip menu "NepomukDaemons"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal