Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TermCache.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2003 University of Massachusetts.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010  */
00011 
00012 
00013 //
00014 // TermCache
00015 //
00016 // 19 September 2003 - tds
00017 //
00018 
00019 #ifndef _LEMUR_TERMCACHE_HPP
00020 #define _LEMUR_TERMCACHE_HPP
00021 namespace lemur 
00022 {
00023   namespace utility 
00024   {
00025     
00026 #define TERMCACHE_MAX_TERM_LENGTH 12
00027 #define TERMCACHE_SIZE    (64 * 1024 * 1024)
00028 #define TERMCACHE_BUCKETS (TERMCACHE_SIZE/16)
00031     class TermCache {
00032     public:
00033       TermCache();
00035       void add( const char* term, int termID );
00037       int find( const char* term ) const;
00039       void clear();
00040 
00041     private:
00042       int _hashFunction( const char* term ) const;
00043 
00044       struct cache_entry {
00045         char term[TERMCACHE_MAX_TERM_LENGTH];
00046         int id;
00047       };
00048 
00049       struct cache_entry _termCache[ TERMCACHE_SIZE / sizeof (struct cache_entry) ];
00050     };
00051   }
00052 }
00053 
00054 #endif // _LEMUR_TERMCACHE_HPP

Generated on Tue Jun 15 11:02:56 2010 for Lemur by doxygen 1.3.4