-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatastructure.h
124 lines (84 loc) · 2.11 KB
/
datastructure.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
// datastructure.h
// Perceptron GLM NLP Tasks
//
// Created by husnu sensoy on 19/02/14.
// Copyright (c) 2014 husnu sensoy. All rights reserved.
//
#ifndef Perceptron_GLM_NLP_Tasks_datastructure_h
#define Perceptron_GLM_NLP_Tasks_datastructure_h
#include <stdbool.h>
#include "vector.h"
#include "hashmap.h"
#include "mkl.h"
struct IntegerIndexedFeatures{
Hashmap *map;
uint32_t feature_id;
};
typedef struct IntegerIndexedFeatures* IntegerIndexedFeatures;
struct FeatureVector {
DArray *discrete_v;
vector continous_v;
};
typedef struct FeatureVector* FeatureVector;
struct FeatureMatrix{
FeatureVector** matrix_data;
uint16_t size;
uint32_t embedding_length;
bool has_discrete_features;
};
typedef struct FeatureMatrix* FeatureMatrix;
struct FeaturedSentence {
uint8_t section;
DArray* words;
int length;
//DArray* postags;
//DArray* embedding;
//DArray* parents;
//DArray ***feature_matrix; // For each potential link from-->to you have a set of features.
//FeatureVector **feature_matrix;
/**
* This is simply a reference to actual one used in CoNLLCorpus structure.
* This allows us to remote
*/
FeatureMatrix feature_matrix_ref;
float **adjacency_matrix; // Score of each potential link between words
};
typedef struct FeaturedSentence* FeaturedSentence;
typedef struct {
uint32_t sentence_idx;
uint16_t from;
uint16_t to;
} alpha_key_t;
typedef struct alpha{
UT_hash_handle hh;
int idx;
uint32_t sentence_idx;
uint16_t from;
uint16_t to;
} alpha_t;
enum Kernel{
KLINEAR,
KPOLYNOMIAL,
KRBF
};
struct KernelPerceptron{
float bias;
float rbf_lambda;
int power;
size_t M;
float* alpha;
float* alpha_avg;
float* kernel_matrix;
enum Kernel kernel;
size_t N;
float* beta;
int c;
float* best_alpha_avg;
int best_numit;
float* best_kernel_matrix;
size_t best_m;
alpha_t *arch_to_index_map;
};
typedef struct KernelPerceptron* KernelPerceptron;
#endif