Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cs_test/Program.cs2
-rw-r--r--cs_test/VowpalWabbitInterface.cs2
-rw-r--r--library/library_example.cc14
-rw-r--r--library/train.wbin347 -> 339 bytes
-rw-r--r--vowpalwabbit/autolink.cc3
-rw-r--r--vowpalwabbit/bfgs.cc1
-rw-r--r--vowpalwabbit/binary.cc1
-rw-r--r--vowpalwabbit/cb.cc1
-rw-r--r--vowpalwabbit/csoaa.cc1
-rw-r--r--vowpalwabbit/ect.cc1
-rw-r--r--vowpalwabbit/example.h4
-rw-r--r--vowpalwabbit/gd.cc1
-rw-r--r--vowpalwabbit/gd_mf.cc1
-rw-r--r--vowpalwabbit/lda_core.cc1
-rw-r--r--vowpalwabbit/main.cc97
-rw-r--r--vowpalwabbit/nn.cc1
-rw-r--r--vowpalwabbit/noop.cc1
-rw-r--r--vowpalwabbit/oaa.cc5
-rw-r--r--vowpalwabbit/parser.cc60
-rw-r--r--vowpalwabbit/parser.h23
-rw-r--r--vowpalwabbit/searn_sequencetask.cc1
-rw-r--r--vowpalwabbit/sender.cc1
-rw-r--r--vowpalwabbit/simple_label.cc1
-rw-r--r--vowpalwabbit/vw.h53
-rw-r--r--vowpalwabbit/vw.vcxproj4
-rw-r--r--vowpalwabbit/vw_static.vcxproj4
-rw-r--r--vowpalwabbit/vwdll.cpp10
-rw-r--r--vowpalwabbit/vwdll.h2
-rw-r--r--vowpalwabbit/wap.cc1
29 files changed, 220 insertions, 77 deletions
diff --git a/cs_test/Program.cs b/cs_test/Program.cs
index bda1895a..cf45cc39 100644
--- a/cs_test/Program.cs
+++ b/cs_test/Program.cs
@@ -91,7 +91,7 @@ namespace cs_test
{
count++;
int featureSpaceLen = 0;
- IntPtr featureSpacePtr = VowpalWabbitInterface.ExportExample(example, ref featureSpaceLen);
+ IntPtr featureSpacePtr = VowpalWabbitInterface.ExportExample(vw, example, ref featureSpaceLen);
VowpalWabbitInterface.FEATURE_SPACE[] featureSpace = new VowpalWabbitInterface.FEATURE_SPACE[featureSpaceLen];
int featureSpace_size = Marshal.SizeOf(typeof(VowpalWabbitInterface.FEATURE_SPACE));
diff --git a/cs_test/VowpalWabbitInterface.cs b/cs_test/VowpalWabbitInterface.cs
index 014e39b2..ee92f5f0 100644
--- a/cs_test/VowpalWabbitInterface.cs
+++ b/cs_test/VowpalWabbitInterface.cs
@@ -34,7 +34,7 @@ namespace Microsoft.Research.MachineLearning
public static extern IntPtr ImportExample(IntPtr vw, IntPtr features, int length);
[DllImport("libvw.dll", EntryPoint = "VW_ExportExample", CallingConvention = CallingConvention.StdCall)]
- public static extern IntPtr ExportExample(IntPtr example, ref int length);
+ public static extern IntPtr ExportExample(IntPtr vw, IntPtr example, ref int length);
[DllImport("libvw.dll", EntryPoint = "VW_ReleaseFeatureSpace", CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr ReleaseFeatureSpace(IntPtr fs, int length);
diff --git a/library/library_example.cc b/library/library_example.cc
index c8d6576a..0140083a 100644
--- a/library/library_example.cc
+++ b/library/library_example.cc
@@ -40,11 +40,21 @@ int main(int argc, char *argv[])
VW::finish(*model);
-
vw* model2 = VW::initialize("--hash all -q st --noconstant -i train2.vw");
- vec2 = VW::read_example(*model2, (char*)"|s p^the_man w^the w^man |t p^un_homme w^un w^homme");
+ vec2 = VW::read_example(*model2, (char*)" |s p^the_man w^the w^man |t p^un_homme w^un w^homme");
model2->learn(vec2);
cerr << "p4 = " << vec2->final_prediction << endl;
+
+ size_t len=0;
+ VW::primitive_feature_space* pfs = VW::export_example(*model2, vec2, len);
+ for (size_t i = 0; i < len; i++)
+ {
+ cout << "namespace = " << pfs[i].name;
+ for (size_t j = 0; j < pfs[i].len; j++)
+ cout << " " << pfs[i].fs[j].weight_index << ":" << pfs[i].fs[j].x << ":" << VW::get_weight(*model2, pfs[i].fs[j].weight_index);
+ cout << endl;
+ }
+
VW::finish_example(*model2, vec2);
VW::finish(*model2);
}
diff --git a/library/train.w b/library/train.w
index 688d34e4..f6f1b100 100644
--- a/library/train.w
+++ b/library/train.w
Binary files differ
diff --git a/vowpalwabbit/autolink.cc b/vowpalwabbit/autolink.cc
index 53890b87..8096d36d 100644
--- a/vowpalwabbit/autolink.cc
+++ b/vowpalwabbit/autolink.cc
@@ -1,6 +1,7 @@
#include "simple_label.h"
#include <float.h>
#include "parser.h"
+#include "vw.h"
namespace ALINK {
const int autoconstant = 524267083;
@@ -30,7 +31,7 @@ namespace ALINK {
for (size_t i = 0; i < b->d; i++)
if (base_pred != 0.)
{
- feature f = { base_pred, autoconstant + i * b->stride };
+ feature f = { base_pred, (uint32_t) (autoconstant + i * b->stride) };
ec->atomics[autolink_namespace].push_back(f);
sum_sq += base_pred*base_pred;
base_pred *= ec->final_prediction;
diff --git a/vowpalwabbit/bfgs.cc b/vowpalwabbit/bfgs.cc
index 56955350..1da7309e 100644
--- a/vowpalwabbit/bfgs.cc
+++ b/vowpalwabbit/bfgs.cc
@@ -24,6 +24,7 @@ Implementation by Miro Dudik.
#include "simple_label.h"
#include "accumulate.h"
#include <exception>
+#include "vw.h"
using namespace std;
diff --git a/vowpalwabbit/binary.cc b/vowpalwabbit/binary.cc
index d2e6108f..aa2f4856 100644
--- a/vowpalwabbit/binary.cc
+++ b/vowpalwabbit/binary.cc
@@ -1,4 +1,5 @@
#include "oaa.h"
+#include "vw.h"
namespace BINARY {
struct binary {
diff --git a/vowpalwabbit/cb.cc b/vowpalwabbit/cb.cc
index 9a60aa93..40dfd934 100644
--- a/vowpalwabbit/cb.cc
+++ b/vowpalwabbit/cb.cc
@@ -12,6 +12,7 @@ license as described in the file LICENSE.
#include "oaa.h"
#include "parse_example.h"
#include "parse_primitives.h"
+#include "vw.h"
namespace CB
{
diff --git a/vowpalwabbit/csoaa.cc b/vowpalwabbit/csoaa.cc
index 885f84b9..a15b1dcb 100644
--- a/vowpalwabbit/csoaa.cc
+++ b/vowpalwabbit/csoaa.cc
@@ -13,6 +13,7 @@ license as described in the file LICENSE.
#include "oaa.h"
#include "v_hashmap.h"
#include "parse_example.h"
+#include "vw.h"
using namespace std;
diff --git a/vowpalwabbit/ect.cc b/vowpalwabbit/ect.cc
index 35201f02..1b6116af 100644
--- a/vowpalwabbit/ect.cc
+++ b/vowpalwabbit/ect.cc
@@ -18,6 +18,7 @@ license as described in the file LICENSE.
#include "parser.h"
#include "simple_label.h"
#include "parse_args.h"
+#include "vw.h"
using namespace std;
diff --git a/vowpalwabbit/example.h b/vowpalwabbit/example.h
index 0207b80b..62a021d6 100644
--- a/vowpalwabbit/example.h
+++ b/vowpalwabbit/example.h
@@ -59,9 +59,7 @@ struct example // core example datatype.
example *alloc_example(size_t);
void dealloc_example(void(*delete_label)(void*), example&);
-namespace VW {
- void copy_example_data(example*&, example*, size_t, void(*copy_example)(void*&,void*));
-}
+
void update_example_indicies(bool audit, example* ec, uint32_t amount);
bool command_example(void*a, example* ec);
diff --git a/vowpalwabbit/gd.cc b/vowpalwabbit/gd.cc
index 9ac4e8a2..34e67522 100644
--- a/vowpalwabbit/gd.cc
+++ b/vowpalwabbit/gd.cc
@@ -27,6 +27,7 @@ license as described in the file LICENSE.
#include "simple_label.h"
#include "accumulate.h"
#include "learner.h"
+#include "vw.h"
using namespace std;
diff --git a/vowpalwabbit/gd_mf.cc b/vowpalwabbit/gd_mf.cc
index b2ebb7db..98c3454f 100644
--- a/vowpalwabbit/gd_mf.cc
+++ b/vowpalwabbit/gd_mf.cc
@@ -19,6 +19,7 @@ license as described in the file LICENSE.
#include "cache.h"
#include "simple_label.h"
#include "rand48.h"
+#include "vw.h"
using namespace std;
diff --git a/vowpalwabbit/lda_core.cc b/vowpalwabbit/lda_core.cc
index 36aa6493..6361ceb2 100644
--- a/vowpalwabbit/lda_core.cc
+++ b/vowpalwabbit/lda_core.cc
@@ -22,6 +22,7 @@ license as described in the file LICENSE.
#include "cache.h"
#include "simple_label.h"
#include "rand48.h"
+#include "vw.h"
namespace LDA {
struct lda {
diff --git a/vowpalwabbit/main.cc b/vowpalwabbit/main.cc
new file mode 100644
index 00000000..734e148b
--- /dev/null
+++ b/vowpalwabbit/main.cc
@@ -0,0 +1,97 @@
+/*
+Copyright (c) by respective owners including Yahoo!, Microsoft, and
+individual contributors. All rights reserved. Released under a BSD
+license as described in the file LICENSE.
+ */
+
+#include <math.h>
+#include <iostream>
+#include <fstream>
+#include <float.h>
+#include <time.h>
+#ifdef _WIN32
+#include <WinSock2.h>
+#else
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#endif
+#include <sys/timeb.h>
+#include "global_data.h"
+#include "parse_example.h"
+#include "parse_args.h"
+#include "accumulate.h"
+#include "vw.h"
+#include "searn.h"
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+ vw *all = parse_args(argc, argv);
+ struct timeb t_start, t_end;
+ ftime(&t_start);
+
+ if (!all->quiet && !all->bfgs && !all->searn)
+ {
+ const char * header_fmt = "%-10s %-10s %10s %11s %8s %8s %8s\n";
+ fprintf(stderr, header_fmt,
+ "average", "since", "example", "example",
+ "current", "current", "current");
+ fprintf(stderr, header_fmt,
+ "loss", "last", "counter", "weight", "label", "predict", "features");
+ cerr.precision(5);
+ }
+
+ VW::start_parser(*all);
+
+ all->l.drive(all);
+
+ VW::end_parser(*all);
+
+ ftime(&t_end);
+ double net_time = (int) (1000.0 * (t_end.time - t_start.time) + (t_end.millitm - t_start.millitm));
+ if(!all->quiet && all->span_server != "")
+ cerr<<"Net time taken by process = "<<net_time/(double)(1000)<<" seconds\n";
+
+ if(all->span_server != "") {
+ float loss = (float)all->sd->sum_loss;
+ all->sd->sum_loss = (double)accumulate_scalar(*all, all->span_server, loss);
+ float weighted_examples = (float)all->sd->weighted_examples;
+ all->sd->weighted_examples = (double)accumulate_scalar(*all, all->span_server, weighted_examples);
+ float weighted_labels = (float)all->sd->weighted_labels;
+ all->sd->weighted_labels = (double)accumulate_scalar(*all, all->span_server, weighted_labels);
+ float weighted_unlabeled_examples = (float)all->sd->weighted_unlabeled_examples;
+ all->sd->weighted_unlabeled_examples = (double)accumulate_scalar(*all, all->span_server, weighted_unlabeled_examples);
+ float example_number = (float)all->sd->example_number;
+ all->sd->example_number = (uint64_t)accumulate_scalar(*all, all->span_server, example_number);
+ float total_features = (float)all->sd->total_features;
+ all->sd->total_features = (uint64_t)accumulate_scalar(*all, all->span_server, total_features);
+ }
+
+ float weighted_labeled_examples = (float)(all->sd->weighted_examples - all->sd->weighted_unlabeled_examples);
+ float best_constant = (float)((all->sd->weighted_labels - all->initial_t) / weighted_labeled_examples);
+ float constant_loss = (best_constant*(1.0f - best_constant)*(1.0f - best_constant)
+ + (1.0f - best_constant)*best_constant*best_constant);
+
+ if (!all->quiet)
+ {
+ cerr.precision(4);
+ cerr << endl << "finished run";
+ cerr << endl << "number of examples = " << all->sd->example_number;
+ cerr << endl << "weighted example sum = " << all->sd->weighted_examples;
+ cerr << endl << "weighted label sum = " << all->sd->weighted_labels;
+ cerr << endl << "average loss = " << all->sd->sum_loss / all->sd->weighted_examples;
+ cerr << endl << "best constant = " << best_constant;
+ if (all->sd->min_label == 0. && all->sd->max_label == 1. && best_constant < 1. && best_constant > 0.)
+ cerr << endl << "best constant's loss = " << constant_loss;
+ cerr << endl << "total feature number = " << all->sd->total_features;
+ if (all->active_simulation)
+ cerr << endl << "total queries = " << all->sd->queries << endl;
+ cerr << endl;
+ }
+
+ VW::finish(*all);
+
+ return 0;
+}
+
diff --git a/vowpalwabbit/nn.cc b/vowpalwabbit/nn.cc
index 1c2be65c..e62c9b3a 100644
--- a/vowpalwabbit/nn.cc
+++ b/vowpalwabbit/nn.cc
@@ -14,6 +14,7 @@ license as described in the file LICENSE.
#include "cache.h"
#include "v_hashmap.h"
#include "rand48.h"
+#include "vw.h"
using namespace std;
diff --git a/vowpalwabbit/noop.cc b/vowpalwabbit/noop.cc
index cad748ca..96e9f314 100644
--- a/vowpalwabbit/noop.cc
+++ b/vowpalwabbit/noop.cc
@@ -9,6 +9,7 @@ license as described in the file LICENSE.
#include "parser.h"
#include "gd.h"
#include "simple_label.h"
+#include "vw.h"
namespace NOOP {
void learn(void* d, example*ec) {}
diff --git a/vowpalwabbit/oaa.cc b/vowpalwabbit/oaa.cc
index 11bf4361..cccb4f5c 100644
--- a/vowpalwabbit/oaa.cc
+++ b/vowpalwabbit/oaa.cc
@@ -12,6 +12,7 @@ license as described in the file LICENSE.
#include "simple_label.h"
#include "cache.h"
#include "v_hashmap.h"
+#include "vw.h"
using namespace std;
@@ -203,10 +204,8 @@ namespace OAA {
ec->final_prediction = prediction;
update_example_indicies(all->audit, ec, -d->total_increment);
- if (shouldOutput) {
- outputStringStream << endl;
+ if (shouldOutput)
all->print_text(all->raw_prediction, outputStringStream.str(), ec->tag);
- }
}
void learn(void* d, example* ec) {
diff --git a/vowpalwabbit/parser.cc b/vowpalwabbit/parser.cc
index 76c82958..d21b6058 100644
--- a/vowpalwabbit/parser.cc
+++ b/vowpalwabbit/parser.cc
@@ -890,44 +890,42 @@ namespace VW{
ret->atomics[index].push_back(features[i].fs[j]);
}
}
- parse_atomic_example(all,ret,false); // all.p->parsed_examples++;
+ parse_atomic_example(all,ret,false); // all.p->parsed_examples++;
setup_example(all, ret);
-
+
return ret;
}
- primitive_feature_space* export_example(void* e, size_t& len)
- {
- example* ec = (example*)e;
- len = ec->indices.size();
- primitive_feature_space* fs_ptr = new primitive_feature_space[len];
-
- int fs_count = 0;
- for (unsigned char* i = ec->indices.begin; i != ec->indices.end; i++)
- {
- fs_ptr[fs_count].name = *i;
- fs_ptr[fs_count].len = ec->atomics[*i].size();
- fs_ptr[fs_count].fs = new feature[fs_ptr[fs_count].len];
-
- int f_count = 0;
- feature *f = ec->atomics[*i].begin;
- for (; f != ec->atomics[*i].end; f++)
- {
- fs_ptr[fs_count].fs[f_count] = *f;
- f_count++;
- }
- fs_count++;
- }
- return fs_ptr;
- }
-
- void releaseFeatureSpace(primitive_feature_space* features, size_t len)
+ primitive_feature_space* export_example(vw& all, example* ec, size_t& len)
{
- for (size_t i = 0; i < len;i++)
+ len = ec->indices.size();
+ primitive_feature_space* fs_ptr = new primitive_feature_space[len];
+
+ int fs_count = 0;
+ for (unsigned char* i = ec->indices.begin; i != ec->indices.end; i++)
{
- delete features[i].fs;
+ fs_ptr[fs_count].name = *i;
+ fs_ptr[fs_count].len = ec->atomics[*i].size();
+ fs_ptr[fs_count].fs = new feature[fs_ptr[fs_count].len];
+
+ int f_count = 0;
+ for (feature *f = ec->atomics[*i].begin; f != ec->atomics[*i].end; f++)
+ {
+ feature t = *f;
+ t.weight_index /= all.reg.stride;
+ fs_ptr[fs_count].fs[f_count] = t;
+ f_count++;
+ }
+ fs_count++;
}
- delete (features);
+ return fs_ptr;
+ }
+
+ void releaseFeatureSpace(primitive_feature_space* features, size_t len)
+ {
+ for (size_t i = 0; i < len;i++)
+ delete features[i].fs;
+ delete (features);
}
void parse_example_label(vw& all, example&ec, string label) {
diff --git a/vowpalwabbit/parser.h b/vowpalwabbit/parser.h
index 11fae14b..6f6f5401 100644
--- a/vowpalwabbit/parser.h
+++ b/vowpalwabbit/parser.h
@@ -33,29 +33,6 @@ void adjust_used_index(vw& all);
//parser control
-namespace VW {
- void start_parser(vw& all, bool do_init = true);
- void end_parser(vw& all);
- example* get_example(parser* pf);
-
- // The simplest of two ways to create an example.
- example* read_example(vw& all, char* example_line);
-
- //after you create and fill feature_spaces, get an example with everything filled in.
- example* import_example(vw& all, primitive_feature_space* features, size_t len);
- example* import_example(vw& all, vector< feature_space > ec_info);
- void parse_example_label(vw&all, example&ec, string label);
- example* new_unused_example(vw& all);
- void add_constant_feature(vw& all, example*ec);
-
- void add_label(example* ec, float label, float weight = 1, float base = 0);
- //notify VW that you are done with the example.
- void finish_example(vw& all, example* ec);
-
- primitive_feature_space* export_example(void* e, size_t& len);
- void releaseFeatureSpace(primitive_feature_space* features, size_t len);
-}
-
void make_example_available();
bool parser_done(parser* p);
diff --git a/vowpalwabbit/searn_sequencetask.cc b/vowpalwabbit/searn_sequencetask.cc
index 5446b3fc..148b56c8 100644
--- a/vowpalwabbit/searn_sequencetask.cc
+++ b/vowpalwabbit/searn_sequencetask.cc
@@ -15,6 +15,7 @@ license as described in the file LICENSE.
#include "oaa.h"
#include "csoaa.h"
#include "searn_sequencetask.h"
+#include "vw.h"
namespace SequenceTask {
SearnUtil::history_info hinfo;
diff --git a/vowpalwabbit/sender.cc b/vowpalwabbit/sender.cc
index 694a60c8..eb0d61fb 100644
--- a/vowpalwabbit/sender.cc
+++ b/vowpalwabbit/sender.cc
@@ -20,6 +20,7 @@
#include "cache.h"
#include "simple_label.h"
#include "network.h"
+#include "vw.h"
using namespace std;
diff --git a/vowpalwabbit/simple_label.cc b/vowpalwabbit/simple_label.cc
index 41f13df4..f31297cd 100644
--- a/vowpalwabbit/simple_label.cc
+++ b/vowpalwabbit/simple_label.cc
@@ -5,6 +5,7 @@
#include "simple_label.h"
#include "cache.h"
#include "rand48.h"
+#include "vw.h"
using namespace std;
diff --git a/vowpalwabbit/vw.h b/vowpalwabbit/vw.h
index 9dbf4db2..6f255858 100644
--- a/vowpalwabbit/vw.h
+++ b/vowpalwabbit/vw.h
@@ -12,15 +12,60 @@ license as described in the file LICENSE.
namespace VW {
- // An example_line is the literal line in a VW-format datafile.
- // The more complex way to create an example.
+/* Caveats:
+ (1) Some commandline parameters do not make sense as a library.
+ (2) The code is not yet reentrant.
+ */
+ vw* initialize(string s);
+
+ void cmd_string_replace_value( string& cmd, string flag_to_replace, string new_value );
+
+ char** get_argv_from_string(string s, int& argc);
+
+ /*
+ Call finish() after you are done with the vw instance. This cleans up memory usage.
+ */
+ void finish(vw& all);
+
+ void start_parser(vw& all, bool do_init = true);
+ void end_parser(vw& all);
+
typedef pair< unsigned char, vector<feature> > feature_space; //just a helper definition.
struct primitive_feature_space { //just a helper definition.
unsigned char name;
feature* fs;
size_t len; };
- //First create the hash of a namespace.
+ //The next commands deal with creating examples. Caution: VW does not all allow creation of many examples at once by default. You can adjust the exact number by tweaking ring_size.
+
+ /* The simplest of two ways to create an example. An example_line is the literal line in a VW-format datafile.
+ */
+ example* read_example(vw& all, char* example_line);
+
+ //The more complex way to create an example.
+
+ //after you create and fill feature_spaces, get an example with everything filled in.
+ example* import_example(vw& all, primitive_feature_space* features, size_t len);
+ example* import_example(vw& all, vector< feature_space > ec_info);
+ void parse_example_label(vw&all, example&ec, string label);
+ example* new_unused_example(vw& all);
+ example* get_example(parser* pf);
+
+ void add_constant_feature(vw& all, example*ec);
+ void add_label(example* ec, float label, float weight = 1, float base = 0);
+ //notify VW that you are done with the example.
+ void finish_example(vw& all, example* ec);
+
+ void copy_example_data(example*&, example*, size_t, void(*copy_example)(void*&,void*));
+
+ // after export_example, must call releaseFeatureSpace to free native memory
+ primitive_feature_space* export_example(vw& all, example* e, size_t& len);
+ void releaseFeatureSpace(primitive_feature_space* features, size_t len);
+
+
+ // inlines
+
+ //First create the hash of a namespace.
inline uint32_t hash_space(vw& all, string s)
{
substring ss;
@@ -50,7 +95,7 @@ namespace VW {
inline uint32_t num_weights(vw& all)
{ return (uint32_t)all.length();}
-}
+}
#endif
diff --git a/vowpalwabbit/vw.vcxproj b/vowpalwabbit/vw.vcxproj
index cc7d6d4c..6f41110e 100644
--- a/vowpalwabbit/vw.vcxproj
+++ b/vowpalwabbit/vw.vcxproj
@@ -179,7 +179,9 @@
<IntDir>$(SolutionDir)x86\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemGroup>
- <ClCompile Include="vw_test.cc" />
+
+ <ClCompile Include="main.cc" />
+
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/vowpalwabbit/vw_static.vcxproj b/vowpalwabbit/vw_static.vcxproj
index 7b951fd3..56ab5a9c 100644
--- a/vowpalwabbit/vw_static.vcxproj
+++ b/vowpalwabbit/vw_static.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -314,4 +314,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/vowpalwabbit/vwdll.cpp b/vowpalwabbit/vwdll.cpp
index ec5f0334..b43d4016 100644
--- a/vowpalwabbit/vwdll.cpp
+++ b/vowpalwabbit/vwdll.cpp
@@ -56,19 +56,21 @@ extern "C"
delete pointer;
}
- VW_DLL_MEMBER VW_EXAMPLE VW_CALLING_CONV VW_ImportExample(VW_HANDLE handle, VW_FEATURE_SPACE * features, size_t len)
+ VW_DLL_MEMBER VW_EXAMPLE VW_CALLING_CONV VW_ImportExample(VW_HANDLE handle, VW_FEATURE_SPACE* features, size_t len)
{
vw * pointer = static_cast<vw*>(handle);
VW::primitive_feature_space * f = reinterpret_cast<VW::primitive_feature_space*>( features );
return static_cast<VW_EXAMPLE>(VW::import_example(*pointer, f, len));
}
- VW_DLL_MEMBER VW_FEATURE_SPACE VW_CALLING_CONV VW_ExportExample(VW_EXAMPLE * example, size_t& len)
+ VW_DLL_MEMBER VW_FEATURE_SPACE VW_CALLING_CONV VW_ExportExample(VW_HANDLE handle, VW_EXAMPLE e, size_t& len)
{
- return static_cast<VW_FEATURE_SPACE>(VW::export_example(example, len));
+ vw* pointer = static_cast<vw*>(handle);
+ example* ex = static_cast<example*>(e);
+ return static_cast<VW_FEATURE_SPACE>(VW::export_example(*pointer, ex, len));
}
- VW_DLL_MEMBER void VW_CALLING_CONV VW_ReleaseFeatureSpace(VW_FEATURE_SPACE * features, size_t len)
+ VW_DLL_MEMBER void VW_CALLING_CONV VW_ReleaseFeatureSpace(VW_FEATURE_SPACE* features, size_t len)
{
VW::primitive_feature_space * f = reinterpret_cast<VW::primitive_feature_space*>( features );
VW::releaseFeatureSpace(f, len);
diff --git a/vowpalwabbit/vwdll.h b/vowpalwabbit/vwdll.h
index 0f83279f..4dd1be61 100644
--- a/vowpalwabbit/vwdll.h
+++ b/vowpalwabbit/vwdll.h
@@ -32,7 +32,7 @@ extern "C"
VW_DLL_MEMBER VW_EXAMPLE VW_CALLING_CONV VW_ImportExample(VW_HANDLE handle, VW_FEATURE_SPACE * features, size_t len);
- VW_DLL_MEMBER VW_FEATURE_SPACE VW_CALLING_CONV VW_ExportExample(VW_EXAMPLE * e, size_t& len);
+ VW_DLL_MEMBER VW_FEATURE_SPACE VW_CALLING_CONV VW_ExportExample(VW_HANDLE handle, VW_EXAMPLE e, size_t& len);
VW_DLL_MEMBER void VW_CALLING_CONV VW_ReleaseFeatureSpace(VW_FEATURE_SPACE * features, size_t len);
VW_DLL_MEMBER VW_EXAMPLE VW_CALLING_CONV VW_ReadExample(VW_HANDLE handle, const char16_t * line);
diff --git a/vowpalwabbit/wap.cc b/vowpalwabbit/wap.cc
index c596b5b2..7d745a2d 100644
--- a/vowpalwabbit/wap.cc
+++ b/vowpalwabbit/wap.cc
@@ -13,6 +13,7 @@ license as described in the file LICENSE.
#include "cache.h"
#include "csoaa.h"
#include "oaa.h"
+#include "vw.h"
using namespace std;