diff options
author | niruc <niruc@NIRUC1.redmond.corp.microsoft.com> | 2013-04-09 07:02:33 +0400 |
---|---|---|
committer | niruc <niruc@NIRUC1.redmond.corp.microsoft.com> | 2013-04-09 07:02:33 +0400 |
commit | c0e215ecec7eddf689283271968bcdfca8984e71 (patch) | |
tree | d1a91ac39bc2df27296f872a12155cc41014b3cd /vowpalwabbit/vw.h | |
parent | 8528dcdf6f19feb83eacb36b279711c82dc68135 (diff) |
move all definitions in namespace VW to vw.h
Diffstat (limited to 'vowpalwabbit/vw.h')
-rw-r--r-- | vowpalwabbit/vw.h | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/vowpalwabbit/vw.h b/vowpalwabbit/vw.h index 65c45b52..ddea10ad 100644 --- a/vowpalwabbit/vw.h +++ b/vowpalwabbit/vw.h @@ -29,20 +29,46 @@ namespace VW { */ void finish(vw& all); - //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. + void start_parser(vw& all, bool do_init = true); + void end_parser(vw& all); + - /* 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 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 more complex way to create an example. 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 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; @@ -67,25 +93,12 @@ namespace VW { return (uint32_t)(all.p->hasher(ss,u) & all.parse_mask); } - //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(vw& all, example* e, size_t& len); - void releaseFeatureSpace(primitive_feature_space* features, size_t len); - inline float get_weight(vw& all, uint32_t index) { return all.reg.weight_vector[(index * all.reg.stride) & all.reg.weight_mask];} inline uint32_t num_weights(vw& all) { return (uint32_t)all.length();} + } #endif |