Public Member Functions | Protected Attributes

CStreamingStringFeatures< T > Class Template Reference


Detailed Description

template<class T>
class shogun::CStreamingStringFeatures< T >

This class implements streaming features as strings.

Definition at line 27 of file StreamingStringFeatures.h.

Inheritance diagram for CStreamingStringFeatures< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CStreamingStringFeatures ()
 CStreamingStringFeatures (CStreamingFile *file, bool is_labelled, int32_t size)
virtual ~CStreamingStringFeatures ()
virtual void set_vector_reader ()
virtual void set_vector_and_label_reader ()
void use_alphabet (EAlphabet alpha)
void use_alphabet (CAlphabet *alpha)
void set_remap (CAlphabet *ascii_alphabet, CAlphabet *binary_alphabet)
void set_remap (EAlphabet ascii_alphabet=DNA, EAlphabet binary_alphabet=RAWDNA)
CAlphabetget_alphabet ()
floatmax_t get_num_symbols ()
virtual void start_parser ()
virtual void end_parser ()
virtual bool get_next_example ()
SGString< T > get_vector ()
virtual float64_t get_label ()
virtual void release_example ()
virtual int32_t get_vector_length ()
virtual EFeatureType get_feature_type ()
virtual EFeatureClass get_feature_class ()
virtual CFeaturesduplicate () const
virtual const char * get_name () const
virtual int32_t get_num_vectors () const
virtual int32_t get_size ()
virtual int32_t get_num_features ()

Protected Attributes

CInputParser< T > parser
 The parser object, which reads from input and returns parsed example objects.
CAlphabetalphabet
 Alphabet to use.
CAlphabetalpha_ascii
 If remapping is enabled, this is the source alphabet.
CAlphabetalpha_bin
 If remapping is enabled, this is the target alphabet.
CStreamingFileworking_file
 The StreamingFile object to read from.
SGString< T > current_sgstring
 The current example's string as an SGString<T>
T * current_string
 The current example's string as a T*.
int32_t current_length
 The length of the current string.
float64_t current_label
 The label of the current example, if applicable.
bool has_labels
 Whether examples are labelled or not.
bool remap_to_bin
 Whether remapping must be done.
int32_t num_symbols
 Number of symbols.

Constructor & Destructor Documentation

Default constructor.

Sets the reading functions to be CStreamingFile::get_*_vector and get_*_vector_and_label depending on the type T.

Definition at line 38 of file StreamingStringFeatures.h.

CStreamingStringFeatures ( CStreamingFile file,
bool  is_labelled,
int32_t  size 
)

Constructor taking args. Initializes the parser with the given args.

Parameters:
file StreamingFile object, input file.
is_labelled Whether examples are labelled or not.
size Number of example objects to be stored in the parser at a time.

Definition at line 54 of file StreamingStringFeatures.h.

virtual ~CStreamingStringFeatures (  )  [virtual]

Destructor.

Ends the parsing thread. (Waits for pthread_join to complete)

Definition at line 69 of file StreamingStringFeatures.h.


Member Function Documentation

virtual CFeatures* duplicate (  )  const [virtual]

Duplicate the object.

Returns:
a duplicate object as CFeatures*

Implements CFeatures.

Definition at line 250 of file StreamingStringFeatures.h.

void end_parser (  )  [virtual]

Ends the parsing thread.

Waits for the thread to join.

Implements CStreamingFeatures.

Definition at line 413 of file StreamingStringFeatures.h.

CAlphabet* get_alphabet (  ) 

Return the alphabet being used as a CAlphabet*

Returns:

Definition at line 159 of file StreamingStringFeatures.h.

EFeatureClass get_feature_class (  )  [virtual]

Return the feature class

Returns:
C_STREAMING_STRING

Implements CFeatures.

Definition at line 494 of file StreamingStringFeatures.h.

virtual EFeatureType get_feature_type (  )  [virtual]

Return the feature type, depending on T.

Returns:
Feature type as EFeatureType

Implements CFeatures.

float64_t get_label (  )  [virtual]

Return the label of the current example as a float.

Examples must be labelled, otherwise an error occurs.

Returns:
The label as a float64_t.

Implements CStreamingFeatures.

Definition at line 474 of file StreamingStringFeatures.h.

virtual const char* get_name ( void   )  const [virtual]

Return the name.

Returns:
StreamingSparseFeatures

Implements CSGObject.

Definition at line 260 of file StreamingStringFeatures.h.

bool get_next_example (  )  [virtual]

Instructs the parser to return the next example.

This example is stored as the current_example in this object.

Returns:
True on success, false if there are no more examples, or an error occurred.

Implements CStreamingFeatures.

Definition at line 419 of file StreamingStringFeatures.h.

virtual int32_t get_num_features (  )  [virtual]

Return the number of features in the current vector.

Returns:
length of the vector

Implements CStreamingFeatures.

Definition at line 286 of file StreamingStringFeatures.h.

floatmax_t get_num_symbols (  ) 

get number of symbols

Note: floatmax_t sounds weird, but LONG is not long enough

Returns:
number of symbols

Definition at line 171 of file StreamingStringFeatures.h.

virtual int32_t get_num_vectors (  )  const [virtual]

Return the number of vectors stored in this object.

Returns:
1 if current_vector exists, else 0.

Implements CFeatures.

Definition at line 267 of file StreamingStringFeatures.h.

virtual int32_t get_size (  )  [virtual]

Return the size of one T object.

Returns:
Size of T.

Implements CFeatures.

Definition at line 279 of file StreamingStringFeatures.h.

SGString< T > get_vector (  ) 

Return the current feature vector as an SGString<T>.

Returns:
The vector as SGString<T>

Definition at line 465 of file StreamingStringFeatures.h.

int32_t get_vector_length (  )  [virtual]

Return the length of the current vector.

Returns:
current vector length as int32_t

Definition at line 488 of file StreamingStringFeatures.h.

void release_example (  )  [virtual]

Release the current example, indicating to the parser that it has been processed by the learning algorithm.

The parser is then free to throw away that example.

Implements CStreamingFeatures.

Definition at line 482 of file StreamingStringFeatures.h.

void set_remap ( EAlphabet  ascii_alphabet = DNA,
EAlphabet  binary_alphabet = RAWDNA 
)

Set whether remapping to another alphabet is required.

Call before parsing.

Parameters:
ascii_alphabet the alphabet to convert from, EAlphabet
binary_alphabet the alphabet to convert to, EAlphabet

Definition at line 148 of file StreamingStringFeatures.h.

void set_remap ( CAlphabet ascii_alphabet,
CAlphabet binary_alphabet 
)

Set whether remapping to another alphabet is required.

Call before parsing.

Parameters:
ascii_alphabet the alphabet to convert from, CAlphabet*
binary_alphabet the alphabet to convert to, CAlphabet*

Definition at line 134 of file StreamingStringFeatures.h.

void set_vector_and_label_reader (  )  [virtual]

Sets the read function (in case the examples are labelled) to get_*_vector_and_label from CStreamingFile.

The exact function depends on type T.

The parser uses the function set by this while reading labelled examples.

Implements CStreamingFeatures.

Definition at line 349 of file StreamingStringFeatures.h.

void set_vector_reader (  )  [virtual]

Sets the read function (in case the examples are unlabelled) to get_*_vector() from CStreamingFile.

The exact function depends on type T.

The parser uses the function set by this while reading unlabelled examples.

Implements CStreamingFeatures.

Definition at line 344 of file StreamingStringFeatures.h.

void start_parser (  )  [virtual]

Starts the parsing thread.

To be called before trying to use any feature vectors from this object.

Implements CStreamingFeatures.

Definition at line 403 of file StreamingStringFeatures.h.

void use_alphabet ( CAlphabet alpha  ) 

Set the alphabet to be used. Call before parsing.

Parameters:
alpha alphabet as a pointer to a CAlphabet object.

Definition at line 118 of file StreamingStringFeatures.h.

void use_alphabet ( EAlphabet  alpha  ) 

Set the alphabet to be used. Call before parsing.

Parameters:
alpha alphabet as an EAlphabet enum.

Definition at line 103 of file StreamingStringFeatures.h.


Member Data Documentation

CAlphabet* alpha_ascii [protected]

If remapping is enabled, this is the source alphabet.

Definition at line 314 of file StreamingStringFeatures.h.

CAlphabet* alpha_bin [protected]

If remapping is enabled, this is the target alphabet.

Definition at line 317 of file StreamingStringFeatures.h.

CAlphabet* alphabet [protected]

Alphabet to use.

Definition at line 311 of file StreamingStringFeatures.h.

float64_t current_label [protected]

The label of the current example, if applicable.

Definition at line 332 of file StreamingStringFeatures.h.

int32_t current_length [protected]

The length of the current string.

Definition at line 329 of file StreamingStringFeatures.h.

SGString<T> current_sgstring [protected]

The current example's string as an SGString<T>

Definition at line 323 of file StreamingStringFeatures.h.

T* current_string [protected]

The current example's string as a T*.

Definition at line 326 of file StreamingStringFeatures.h.

bool has_labels [protected]

Whether examples are labelled or not.

Reimplemented from CStreamingFeatures.

Definition at line 335 of file StreamingStringFeatures.h.

int32_t num_symbols [protected]

Number of symbols.

Definition at line 341 of file StreamingStringFeatures.h.

CInputParser<T> parser [protected]

The parser object, which reads from input and returns parsed example objects.

Definition at line 308 of file StreamingStringFeatures.h.

bool remap_to_bin [protected]

Whether remapping must be done.

Definition at line 338 of file StreamingStringFeatures.h.

The StreamingFile object to read from.

Reimplemented from CStreamingFeatures.

Definition at line 320 of file StreamingStringFeatures.h.


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

SHOGUN Machine Learning Toolbox - Documentation