SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
CVwParser Class Reference

Detailed Description

CVwParser is the object which provides the functions to parse examples from buffered input.

An instance of this class can be created in CStreamingVwFile and the appropriate read_*_features function called to parse examples from different formats.

It also encapsulates a CVwCacheWriter object which may be used in case a cache file is to be generated simultaneously with parsing.

Definition at line 46 of file VwParser.h.

Inheritance diagram for CVwParser:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CVwParser ()
 CVwParser (CVwEnvironment *env_to_use)
virtual ~CVwParser ()
CVwEnvironmentget_env ()
void set_env (CVwEnvironment *env_to_use)
void set_cache_parameters (char *fname, EVwCacheType type=C_NATIVE)
EVwCacheType get_cache_type ()
void set_write_cache (bool wr_cache)
bool get_write_cache ()
void set_mm (float64_t label)
void noop_mm (float64_t label)
void set_minmax (float64_t label)
int32_t read_features (CIOBuffer *buf, VwExample *&ex)
int32_t read_svmlight_features (CIOBuffer *buf, VwExample *&ae)
int32_t read_dense_features (CIOBuffer *buf, VwExample *&ae)
virtual const char * get_name () const

Public Attributes

hash_func_t hasher
 Hash function to use, of type hash_func_t.

Protected Member Functions

void init_cache (char *fname, EVwCacheType type=C_NATIVE)
void feature_value (substring &s, v_array< substring > &name, float32_t &v)
void tokenize (char delim, substring s, v_array< substring > &ret)
char * safe_index (char *start, char v, char *max)

Protected Attributes

CVwEnvironmentenv
 Environment of VW - used by parser.
CVwCacheWritercache_writer
 Object which will be used for writing cache.
EVwCacheType cache_type
 Type of cache.
bool write_cache
 Whether to write cache or not.

Constructor & Destructor Documentation

CVwParser ( )

Default constructor

Definition at line 21 of file VwParser.cpp.

CVwParser ( CVwEnvironment env_to_use)

Constructor taking environment as parameter.

Parameters:
env_to_useCVwEnvironment to use

Definition at line 30 of file VwParser.cpp.

~CVwParser ( ) [virtual]

Destructor

Definition at line 42 of file VwParser.cpp.


Member Function Documentation

void feature_value ( substring s,
v_array< substring > &  name,
float32_t v 
) [protected]

Get value of feature from a given substring. A default of 1 is assumed if no explicit value is specified.

Parameters:
ssubstring, usually a feature:value string
namereturned array of substrings, split into name and value
vvalue of feature, set by reference

Definition at line 278 of file VwParser.cpp.

Return the type of cache

Returns:
cache type as EVwCacheType

Definition at line 104 of file VwParser.h.

Get the environment

Returns:
environment as CVwEnvironment*

Definition at line 71 of file VwParser.h.

virtual const char* get_name ( ) const [virtual]

Return the name of the object

Returns:
VwParser

Implements CSGObject.

Definition at line 200 of file VwParser.h.

bool get_write_cache ( )

Return whether cache will be written or not

Returns:
will cache be written?

Definition at line 129 of file VwParser.h.

void init_cache ( char *  fname,
EVwCacheType  type = C_NATIVE 
) [protected]

Initialize the cache writer

Parameters:
fnamecache file name
typecache type as EVwCacheType, default is C_NATIVE

Definition at line 255 of file VwParser.cpp.

void noop_mm ( float64_t  label)

A dummy function performing no operation in case training is not to be performed.

Parameters:
labellabel

Definition at line 152 of file VwParser.h.

int32_t read_dense_features ( CIOBuffer buf,
VwExample *&  ae 
)

Read an example from a file with dense vectors

Parameters:
bufIOBuffer which contains input
aeparsed example
Returns:
number of characters read for this example

Definition at line 213 of file VwParser.cpp.

int32_t read_features ( CIOBuffer buf,
VwExample *&  ex 
)

Reads input from the buffer and parses it into a VwExample

Parameters:
bufIOBuffer which contains input
exparsed example
Returns:
number of characters read for this example

Definition at line 55 of file VwParser.cpp.

int32_t read_svmlight_features ( CIOBuffer buf,
VwExample *&  ae 
)

Read an example from an SVMLight file

Parameters:
bufIOBuffer which contains input
aeparsed example
Returns:
number of characters read for this example

Definition at line 171 of file VwParser.cpp.

char* safe_index ( char *  start,
char  v,
char *  max 
) [protected]

Get the index of a character in a memory location taking care not to go beyond the max pointer.

Parameters:
startstart memory location, char*
vcharacter to search for
maxlast location to look in
Returns:
index of found location as char*

Definition at line 241 of file VwParser.h.

void set_cache_parameters ( char *  fname,
EVwCacheType  type = C_NATIVE 
)

Set the cache parameters

Parameters:
fnamename of the cache file
typetype of cache as one in EVwCacheType

Definition at line 94 of file VwParser.h.

void set_env ( CVwEnvironment env_to_use)

Set the environment

Parameters:
env_to_useenvironment as CVwEnvironment*

Definition at line 82 of file VwParser.h.

void set_minmax ( float64_t  label)

Function which is actually called to update min and max labels Should be set to one of the functions implemented for this.

Parameters:
labellabel based on which to update

Definition at line 160 of file VwParser.h.

void set_mm ( float64_t  label)

Update min and max labels seen in the environment

Parameters:
labelcurrent label based on which to update

Definition at line 139 of file VwParser.h.

void set_write_cache ( bool  wr_cache)

Set whether to write cache file or not

Parameters:
wr_cachewrite cache or not

Definition at line 114 of file VwParser.h.

void tokenize ( char  delim,
substring  s,
v_array< substring > &  ret 
) [protected]

Split a given substring into an array of substrings based on a specified delimiter

Parameters:
delimdelimiter to use
ssubstring to tokenize
retarray of substrings, returned

Definition at line 302 of file VwParser.cpp.


Member Data Documentation

EVwCacheType cache_type [protected]

Type of cache.

Definition at line 258 of file VwParser.h.

Object which will be used for writing cache.

Definition at line 256 of file VwParser.h.

CVwEnvironment* env [protected]

Environment of VW - used by parser.

Definition at line 254 of file VwParser.h.

Hash function to use, of type hash_func_t.

Definition at line 250 of file VwParser.h.

bool write_cache [protected]

Whether to write cache or not.

Definition at line 260 of file VwParser.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation