// file: $isip/class/search/NGramCache/NGramCache.h // version: $Id: NGramCache.h 9101 2003-04-19 20:52:59Z parihar $ // make sure definitions are only made once // #ifndef ISIP_NGRAM_CACHE #define ISIP_NGRAM_CACHE #ifndef ISIP_FLOAT #include #endif #ifndef ISIP_HASH_TABLE #include #endif #ifndef ISIP_CONTEXT #include #endif #ifndef ISIP_NGRAM_MODEL #include #endif // NGramCache: A class to cache n-gram probabilities // class NGramCache { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; //---------------------------------------- // // other important constants // //---------------------------------------- //---------------------------------------- // // default values and arguments // //---------------------------------------- // default values // static const int32 DEF_CAPACITY = 12000; //--------------------------------------- // // error codes // //--------------------------------------- //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // define the main cache data structure // HashTable cache_d; // define a static debug level // static Integral::DEBUG debug_level_d; // define a static memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // method: diagnose // static bool8 diagnose(Integral::DEBUG debug_level); // method: debug // bool8 debug(const unichar* message) const; // method: setDebug // static bool8 setDebug(Integral::DEBUG debug_level) { debug_level_d = debug_level; return true; } // method: destructor // ~NGramCache() { clear(); } // constructor(s) // NGramCache(); NGramCache(const NGramCache& arg); // assign methods // bool8 assign(const NGramCache& arg); // method: sofSize // int32 sofSize() const { return Error::handle(name(), L"sofSize", Error::ARG, __FILE__, __LINE__); } // method: read // bool8 read(Sof& sof, int32 tag, const String& cname = CLASS_NAME) { return Error::handle(name(), L"read", Error::ARG, __FILE__, __LINE__); } // method: write // bool8 write(Sof& sof, int32 tag, const String& cname = CLASS_NAME) const { return Error::handle(name(), L"write", Error::ARG, __FILE__, __LINE__); } // method: readData // bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false) { return Error::handle(name(), L"readData", Error::ARG, __FILE__, __LINE__); } // method: writeData // bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const { return Error::handle(name(), L"writeData", Error::ARG, __FILE__, __LINE__); } // equality method // bool8 eq(const NGramCache& arg) const; // method: new // static void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // clear methods // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // method: length // int32 length() const { return cache_d.getNumItems(); } // method to determine the n-gram score of the context // float32 getScore(NGramModel& model, Context& context); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // end of include file // #endif