00001 // $Id: ngramcache.h 383 2010-04-23 15:29:28Z nicolabertoldi $ 00002 00003 /****************************************************************************** 00004 IrstLM: IRST Language Model Toolkit 00005 Copyright (C) 2006 Marcello Federico, ITC-irst Trento, Italy 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 00021 ******************************************************************************/ 00022 00023 #ifndef MF_NGRAMCACHE_H 00024 #define MF_NGRAMCACHE_H 00025 00026 #include "mempool.h" 00027 #include "htable.h" 00028 00029 class ngramcache{ 00030 private: 00031 htable* ht; 00032 mempool *mp; 00033 int maxn; 00034 int ngsize; 00035 int infosize; 00036 int accesses; 00037 int hits; 00038 int entries; 00039 00040 public: 00041 00042 int cursize(){return entries;} 00043 int maxsize(){return maxn;} 00044 ngramcache(int n,int size,int maxentries); 00045 char* get(const int* ngp,char* info=NULL); 00046 ~ngramcache(); 00047 void reset(int n=0); 00048 int add(const int* ngp,const char* info); 00049 int isfull(){return (entries >= maxn);} 00050 void stat(); 00051 }; 00052 00053 #endif 00054
1.5.9