00001 /****************************************************************************** 00002 IrstLM: IRST Language Model Toolkit 00003 Copyright (C) 2006 Marcello Federico, ITC-irst Trento, Italy 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 ******************************************************************************/ 00020 00021 #ifndef MF_NORMCACHE_H 00022 #define MF_NORMCACHE_H 00023 00024 #include "dictionary.h" 00025 #include "ngramtable.h" 00026 00027 // Normalization factors cache 00028 00029 class normcache 00030 { 00031 dictionary* dict; 00032 ngramtable *ngt; 00033 double* cache[2]; 00034 int cachesize[2]; 00035 int maxcache[2]; 00036 int hit; 00037 int miss; 00038 00039 public: 00040 normcache(dictionary* d); 00041 ~normcache() { 00042 delete [] cache[0]; 00043 delete [] cache[1]; 00044 delete ngt; 00045 } 00046 00047 void expand(int i); 00048 double get(ngram ng,int size,double& value); 00049 double put(ngram ng,int size,double value); 00050 void stat(); 00051 }; 00052 00053 #endif 00054