#include <stdio.h>#include <stdlib.h>#include <string.h>#include <dlfcn.h>#include "plugin.h"#include "sparsevector.h"Go to the source code of this file.
Functions | |
| void | empty_function (char *a) |
| void | plugin_init (char *plugin_file) |
| void | plugin_exit () |
| void * | plugin_null (void) |
| void * | plugin_copy_constructor (void *words) |
| void * | plugin_parse_document (char *line, double *alphay, long int *queryid, long int *slackid, double *costfactor, long int *highest_feature, long int max_words, char **comment) |
| double | plugin_kernel (void *a, void *b) |
| void | plugin_write (FILE *fl, void *words) |
| void | plugin_destructor (void *words) |
| void | plugin_clip (void *words, int maxwords) |
| void | plugin_kernel_setparm (char *kernel_parm) |
Variables | |
| static void * | dl_library = NULL |
| static void *(*) | plugin_null_fcn (void) = NULL |
| static void *(*) | plugin_copy_constructor_fcn (void *) = NULL |
| static void *(*) | plugin_parse_document_fcn (char *, double *, long *, long *, double *, long *, long, char **) = NULL |
| static double(*) | plugin_kernel_fcn (void *, void *) = NULL |
| static void(*) | plugin_write_fcn (FILE *, void *) = NULL |
| static void(*) | plugin_destructor_fcn (void *) = NULL |
| static void(*) | plugin_clip_fcn (void *, int) = NULL |
| static void(*) | plugin_kernel_setparm_fcn (char *) = NULL |
| void empty_function | ( | char * | a | ) |
| void plugin_clip | ( | void * | words, | |
| int | maxwords | |||
| ) |
This is not likely to be useful. Some kernels have an associated explicit feature space, allowing to calculate W from the support vectors, a trick that can speed up significantly the calculation of f(x). During test your object could have some feature index that goes bejond those observed during training so here you are supposed to clip extra features that do not have an associated component of W. In the default sparsevector module, this function just removes any word having index above totwords, the size of the training dictionary.
Definition at line 169 of file plugin.c.
References plugin_clip_fcn.
| void* plugin_copy_constructor | ( | void * | words | ) |
This function should make a copy of an instance and return the pointer It receives the memory address where the source object lives
Definition at line 137 of file plugin.c.
References plugin_copy_constructor_fcn, and datum::x.
| void plugin_destructor | ( | void * | words | ) |
Free memory associated with your object.
Definition at line 165 of file plugin.c.
References plugin_destructor_fcn.
| void plugin_exit | ( | ) |
Definition at line 117 of file plugin.c.
References dl_library, plugin_clip_fcn, plugin_copy_constructor_fcn, plugin_destructor_fcn, plugin_kernel_fcn, plugin_null_fcn, plugin_parse_document_fcn, and plugin_write_fcn.
Referenced by plugin_init().
| void plugin_init | ( | char * | plugin_file | ) |
Definition at line 35 of file plugin.c.
References dl_library, empty_function(), plugin_clip_fcn, plugin_copy_constructor_fcn, plugin_destructor_fcn, plugin_exit(), plugin_kernel_fcn, plugin_kernel_setparm_fcn, plugin_null_fcn, plugin_parse_document_fcn, and plugin_write_fcn.
Referenced by main().
| double plugin_kernel | ( | void * | a, | |
| void * | b | |||
| ) |
This function receives two pointers to SVECTOR data structures. In SVECTOR there may be some additional info besides the object itself (e.g. a weight). To access the object cast the pointers to SVECTOR* and access the void pointer words inside the struct. Then calculate whatever defines a kernel on your data type.
Definition at line 157 of file plugin.c.
References min_or_mult, MULTK, plugin_kernel_fcn, and svector::words.
| void plugin_kernel_setparm | ( | char * | kernel_parm | ) |
Use this function to pass extra parameters to the kernel plugin
Definition at line 174 of file plugin.c.
References min_or_mult, MINK, MULTK, and plugin_kernel_setparm_fcn.
| void* plugin_null | ( | void | ) |
This function should return a pointer to an object that is mapped into the null vector in feature space. For example it might be an empty graph or an object with no features. It is used to calculate the smallest enclosing hypersphere in svm_learn.c
Definition at line 133 of file plugin.c.
References plugin_null_fcn, and datum::x.
| void* plugin_parse_document | ( | char * | line, | |
| double * | alphay, | |||
| long int * | queryid, | |||
| long int * | slackid, | |||
| double * | costfactor, | |||
| long int * | highest_feature, | |||
| long int | max_words, | |||
| char ** | comment | |||
| ) |
| void plugin_write | ( | FILE * | fl, | |
| void * | words | |||
| ) |
Write an instance in a format that is compatible with the above reading function. Thus function is used to save support vectors in the model file.
Definition at line 161 of file plugin.c.
References plugin_write_fcn.
void* dl_library = NULL [static] |
void(*) plugin_clip_fcn(void *, int) = NULL [static] |
Definition at line 28 of file plugin.c.
Referenced by plugin_clip(), plugin_exit(), and plugin_init().
void*(*) plugin_copy_constructor_fcn(void *) = NULL [static] |
Definition at line 22 of file plugin.c.
Referenced by plugin_copy_constructor(), plugin_exit(), and plugin_init().
void(*) plugin_destructor_fcn(void *) = NULL [static] |
Definition at line 27 of file plugin.c.
Referenced by plugin_destructor(), plugin_exit(), and plugin_init().
double(*) plugin_kernel_fcn(void *, void *) = NULL [static] |
Definition at line 25 of file plugin.c.
Referenced by plugin_exit(), plugin_init(), and plugin_kernel().
void(*) plugin_kernel_setparm_fcn(char *) = NULL [static] |
void*(*) plugin_null_fcn(void) = NULL [static] |
Definition at line 21 of file plugin.c.
Referenced by plugin_exit(), plugin_init(), and plugin_null().
void*(*) plugin_parse_document_fcn(char *, double *, long *, long *, double *, long *, long, char **) = NULL [static] |
Definition at line 24 of file plugin.c.
Referenced by plugin_exit(), plugin_init(), and plugin_parse_document().
void(*) plugin_write_fcn(FILE *, void *) = NULL [static] |
Definition at line 26 of file plugin.c.
Referenced by plugin_exit(), plugin_init(), and plugin_write().
1.5.1