forked from VowpalWabbit/vowpal_wabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.c
43 lines (27 loc) · 871 Bytes
/
sample.c
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
#include <stdio.h>
#ifndef OMIT_MS // a gcc sample would omit these two defines
#define MS_CONV // use Microsoft libraray convention
#define USE_CODECVT // enable wide character converesion enabled API
#endif
/*
To compile with gcc use this command
LD_LIBRARY_PATH=../vowpalwabbit/.libs ; gcc sample_gcc.c -I./../vowpalwabbit/ -L./../vowpalwabbit/.libs -lvw -lvw_c_wrapper -lallreduce -o sample_gcc
*/
typedef short char16_t;
#define bool int
#define true (1)
#define false (0)
#include "vwdll.h"
int main()
{
VW_HANDLE vw;
VW_EXAMPLE example;
float score;
printf("this is a native c program calling vw\n");
vw = VW_InitializeA("-q st --noconstant --quiet");
example = VW_ReadExampleA(vw, "1 |s p^the_man w^the w^man |t p^un_homme w^un w^homme");
score = VW_Learn(vw, example);
VW_Finish(vw);
printf("Score = %f\n", score);
return 0;
}