[language_classification] Runtime language classifier can now use dense or sparse weights, with a different header signature for the sparse version (using old signature for the dense version, so backward-compatible)

This commit is contained in:
Al
2017-04-02 23:51:54 -04:00
parent 835d851310
commit 5dfdd4b7eb
2 changed files with 53 additions and 16 deletions

View File

@@ -9,19 +9,24 @@
#include "collections.h"
#include "language_features.h"
#include "logistic_regression.h"
#include "matrix.h"
#include "tokens.h"
#include "sparse_matrix.h"
#include "string_utils.h"
#include "trie.h"
#define LANGUAGE_CLASSIFIER_FILENAME "language_classifier.dat"
#define LANGUAGE_CLASSIFIER_COUNTRY_FILENAME "language_classifier_country.dat"
typedef struct language_classifier {
size_t num_labels;
size_t num_features;
trie_t *features;
cstring_array *labels;
double_matrix_t *weights;
matrix_type_t weights_type;
union {
double_matrix_t *dense;
sparse_matrix_t *sparse;
} weights;
} language_classifier_t;