return ret == 0;
}
+ bool remove(phrase_token_t index){
+ if ( !m_db )
+ return false;
+
+ DBT db_key;
+ memset(&db_key, 0, sizeof(DBT));
+ db_key.data = &index;
+ db_key.size = sizeof(phrase_token_t);
+
+ int ret = m_db->del(m_db, NULL, &db_key, 0);
+ return ret == 0;
+ }
+
/* array of phrase_token_t items, for parameter estimation. */
bool get_all_items(GArray * items){
g_array_set_size(items, 0);
GArray * items = g_array_new(FALSE, FALSE, sizeof(phrase_token_t));
bigram.get_all_items(items);
- printf("-----------------------train----------------------------\n");
+ printf("-----------------------items----------------------------\n");
for ( size_t i = 0; i < items->len; ++i ){
phrase_token_t * token = &g_array_index(items, phrase_token_t, i);
printf("item:%d\n", *token);
delete train_gram;
}
+ assert(bigram.remove(1));
+
+ bigram.get_all_items(items);
+ printf("-----------------------items----------------------------\n");
+ for ( size_t i = 0; i < items->len; ++i ){
+ phrase_token_t * token = &g_array_index(items, phrase_token_t, i);
+ printf("item:%d\n", *token);
+ }
+
+ g_array_free(items, TRUE);
g_array_free(array, TRUE);
return 0;
}
parameter_t lambda = 0, next_lambda = 0.6;
parameter_t epsilon = 0.001;
- while ( fabs(lambda - next_lambda) > epsilon){
+ while (fabs(lambda - next_lambda) > epsilon){
lambda = next_lambda;
next_lambda = 0;
parameter_t numerator = 0;
}
KMixtureModelArrayHeader header;
assert(deleted_bigram->get_array_header(header));
+ assert(0 != header.m_WC);
next_lambda /= header.m_WC;
g_array_free(array, TRUE);