static int tagger_set(crfsuite_tagger_t* tagger, crfsuite_instance_t *inst) { crf1dt_t* crf1dt = (crf1dt_t*)tagger->internal; crf1d_context_t* ctx = crf1dt->ctx; crf1dc_set_num_items(ctx, inst->num_items); crf1dc_reset(crf1dt->ctx, RF_STATE); crf1dt_state_score(crf1dt, inst); crf1dt->level = LEVEL_SET; return 0; }
crf1d_context_t* crf1dc_new(int flag, int L, int T) { int ret = 0; crf1d_context_t* ctx = NULL; ctx = (crf1d_context_t*)calloc(1, sizeof(crf1d_context_t)); if (ctx != NULL) { ctx->flag = flag; ctx->num_labels = L; ctx->trans = (floatval_t*)calloc(L * L, sizeof(floatval_t)); if (ctx->trans == NULL) goto error_exit; if (ctx->flag & CTXF_MARGINALS) { ctx->exp_trans = (floatval_t*)_aligned_malloc((L * L + 4) * sizeof(floatval_t), 16); if (ctx->exp_trans == NULL) { goto error_exit; } ctx->mexp_trans = (floatval_t*)calloc(L * L, sizeof(floatval_t)); if (ctx->mexp_trans == NULL) { goto error_exit; } ctx->partial_mexp_trans = (floatval_t*)calloc(L * L, sizeof(floatval_t)); if (ctx->partial_mexp_trans == NULL) { goto error_exit; } } if (ret = crf1dc_set_num_items(ctx, T)) { goto error_exit; } /* T gives the 'hint' for maximum length of items. */ ctx->num_items = 0; } return ctx; error_exit: crf1dc_delete(ctx); return NULL; }