[fix] labels in averaged perceptron trainer
This commit is contained in:
@@ -377,11 +377,13 @@ bool averaged_perceptron_trainer_train_example(averaged_perceptron_trainer_t *se
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
prev = cstring_array_get_string(labels, prev_id);
|
||||
prev = cstring_array_get_string(self->class_strings, prev_id);
|
||||
}
|
||||
|
||||
if (i > 1) {
|
||||
prev2 = cstring_array_get_string(labels, prev2_id);
|
||||
prev2 = cstring_array_get_string(self->class_strings, prev2_id);
|
||||
} else if (i == 1) {
|
||||
prev2 = START;
|
||||
}
|
||||
|
||||
if (!feature_function(tagger, context, tokenized, i, prev, prev2)) {
|
||||
@@ -426,6 +428,7 @@ averaged_perceptron_trainer_t *averaged_perceptron_trainer_new(void) {
|
||||
self->num_classes = 0;
|
||||
self->num_updates = 0;
|
||||
self->num_errors = 0;
|
||||
self->iterations = 0;
|
||||
|
||||
self->features = kh_init(str_uint32);
|
||||
if (self->features == NULL) {
|
||||
|
||||
@@ -48,6 +48,9 @@ typedef struct class_weight {
|
||||
|
||||
#define NULL_WEIGHT (class_weight_t){0.0, 0.0, 0}
|
||||
|
||||
#define SEPARATOR_LABEL "sep"
|
||||
#define FIELD_SEPARATOR_LABEL "fsep"
|
||||
|
||||
KHASH_MAP_INIT_INT(class_weights, class_weight_t)
|
||||
|
||||
KHASH_MAP_INIT_INT(feature_class_weights, khash_t(class_weights) *)
|
||||
@@ -57,6 +60,7 @@ typedef struct averaged_perceptron_trainer {
|
||||
uint32_t num_classes;
|
||||
uint64_t num_updates;
|
||||
uint64_t num_errors;
|
||||
uint32_t iterations;
|
||||
khash_t(str_uint32) *features;
|
||||
khash_t(str_uint32) *classes;
|
||||
cstring_array *class_strings;
|
||||
|
||||
Reference in New Issue
Block a user