Defines

StreamingAsciiFile.cpp File Reference

Go to the source code of this file.

Defines

#define GET_VECTOR(fname, conv, sg_type)
#define GET_FLOAT_VECTOR(sg_type)
#define GET_VECTOR_AND_LABEL(fname, conv, sg_type)
#define GET_FLOAT_VECTOR_AND_LABEL(sg_type)
#define GET_STRING(fname, conv, sg_type)
#define GET_STRING_AND_LABEL(fname, conv, sg_type)
#define GET_SPARSE_VECTOR(fname, conv, sg_type)
#define GET_SPARSE_VECTOR_AND_LABEL(fname, conv, sg_type)

Define Documentation

#define GET_FLOAT_VECTOR (   sg_type  ) 
Value:
void CStreamingAsciiFile::get_vector(sg_type*& vector, int32_t& len)\
        {                                                                   \
                char *line=NULL;                                            \
                int32_t num_chars = buf->read_line(line);                   \
                int32_t old_len = len;                                      \
                                                                            \
                if (num_chars == 0)                                         \
                {                                                           \
                        len = -1;                                           \
                        return;                                             \
                }                                                           \
                                                                            \
                substring example_string = {line, line + num_chars};        \
                                                                            \
                CAsciiFile::tokenize(' ', example_string, words);           \
                                                                            \
                len = words.index();                                        \
                substring* feature_start = &words[0];                       \
                                                                            \
                if (len > old_len)                                          \
                        vector = SG_REALLOC(sg_type, vector, len);          \
                                                                            \
                int32_t j=0;                                                \
                for (substring* i = feature_start; i != words.end; i++)     \
                {                                                           \
                        vector[j++] = float_of_substring(*i);               \
                }                                                           \
        }

Definition at line 116 of file StreamingAsciiFile.cpp.

#define GET_FLOAT_VECTOR_AND_LABEL (   sg_type  ) 
Value:
void CStreamingAsciiFile::get_vector_and_label(sg_type*& vector, int32_t& len, float64_t& label) \
        {                                                               \
                char *line=NULL;                                        \
                int32_t num_chars = buf->read_line(line);               \
                int32_t old_len = len;                                  \
                                                                        \
                if (num_chars == 0)                                     \
                {                                                       \
                        len = -1;                                       \
                        return;                                         \
                }                                                       \
                                                                        \
                substring example_string = {line, line + num_chars};    \
                                                                        \
                CAsciiFile::tokenize(' ', example_string, words);       \
                                                                        \
                label = float_of_substring(words[0]);                   \
                                                                        \
                len = words.index() - 1;                                \
                substring* feature_start = &words[1];                   \
                                                                        \
                if (len > old_len)                                      \
                        vector = SG_REALLOC(sg_type, vector, len);      \
                                                                        \
                int32_t j=0;                                            \
                for (substring* i = feature_start; i != words.end; i++) \
                {                                                       \
                        vector[j++] = float_of_substring(*i);           \
                }                                                       \
        }

Definition at line 235 of file StreamingAsciiFile.cpp.

#define GET_SPARSE_VECTOR (   fname,
  conv,
  sg_type 
)

Definition at line 381 of file StreamingAsciiFile.cpp.

#define GET_SPARSE_VECTOR_AND_LABEL (   fname,
  conv,
  sg_type 
)

Definition at line 471 of file StreamingAsciiFile.cpp.

#define GET_STRING (   fname,
  conv,
  sg_type 
)
Value:
void CStreamingAsciiFile::get_string(sg_type*& vector, int32_t& len)    \
{                                                                       \
        char* buffer = NULL;                                            \
        ssize_t bytes_read;                                             \
                                                                        \
        bytes_read = buf->read_line(buffer);                            \
                                                                        \
        if (bytes_read<=1)                                              \
        {                                                               \
                vector=NULL;                                            \
                len=-1;                                                 \
                return;                                                 \
        }                                                               \
                                                                        \
        SG_DEBUG("Line read from the file:\n%s\n", buffer);             \
        /* Remove the terminating \n */                                 \
        if (buffer[bytes_read-1]=='\n')                                 \
        {                                                               \
                len=bytes_read-1;                                       \
                buffer[bytes_read-1]='\0';                              \
        }                                                               \
        else                                                            \
                len=bytes_read;                                         \
        vector=(sg_type *) buffer;                                      \
}

Definition at line 273 of file StreamingAsciiFile.cpp.

#define GET_STRING_AND_LABEL (   fname,
  conv,
  sg_type 
)

Definition at line 317 of file StreamingAsciiFile.cpp.

#define GET_VECTOR (   fname,
  conv,
  sg_type 
)

Definition at line 35 of file StreamingAsciiFile.cpp.

#define GET_VECTOR_AND_LABEL (   fname,
  conv,
  sg_type 
)

Definition at line 152 of file StreamingAsciiFile.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation