quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_stat.a #include <NGramModel.h> ~NGramModel(); NGramModel(); NGramModel(const NGramModel& copy_sym); boolean load(Sof& sof, const long& tag, const Vector& symbol_table, const String& name = CLASS_NAME); boolean getScore(const VectorLong& index_a, float& score_a); boolean setOrder(long order);
description:#include <NGramModel.h> // configure ngram object and load a trigram file // NGramModel ngrm; ngrm.setOrder(3); ngrm.load(sof, 1, symbol_table); sof.close(); // test getScore // String symb1(L"ONE"), symb2(L"TWO"), symb3(L"FOUR"); VectorLong index(2); // get a bigram (ONE TWO) probability // index(0) = *symbol_hash.get(symb1); index(1) = *symbol_hash.get(symb2); float score = ngrm.getScore(index);
static const String CLASS_NAME = L"NGramModel";
static const String NGramModel::PARAM_ORDER = L"order";
static const String NGramModel::PARAM_KEYS = L"keys";
static const String NGramModel::PARAM_VALUES = L"values";
static const String NGramModel::PARAM_GRAM_HASH = L"gram_hash_table";
static const String DEF_PARAM = L"";
static const Long DEF_ORDER = 0;
static const Float DEF_ORDER = 0.0;
static const ulong DEF_REF_INCR = (ulong)1;
static const ulong DEF_REF_DECR = (ulong)1;
static const long ERR = 00060600;
Long order_d;
HashTablegram_hash_d;
SiVectorsymbol_table_d;
static Integral::DEBUG debug_level_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
static boolean setDebug(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~NGramModel();
NGramModel(Long order = DEF_ORDER);
boolean assign(const NGramModel& copy_arg);
Histogram& operator= (const NGramModel& arg);
long sofSize() const;
boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);
boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
boolean eq(const NGramModel& arg) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);
boolean setOrder(long order);
long getOrder() const;
HashTable<Long, NGramNode> getGramHash();
boolean load(Sof& sof, const long& tag, const Vector& symbol_table, const String& name = CLASS_NAME);
boolean store(Sof& sof, const long& tag, const String& name = CLASS_NAME) const;
float getScore(const VectorLong& symbol_indices);
boolean getScore(const VectorLong& index_a, float& score_a);