ModErn Text Analysis
META Enumerates Textual Applications
Classes | Typedefs | Functions
meta::io::libsvm_parser Namespace Reference

Parser specifically for libsvm-formatted files. More...

Classes

class  libsvm_parser_exception
 Exception class for this parser. More...
 

Typedefs

using counts_t = const std::vector< std::pair< term_id, double >>
 Collection of (term_id, double)
 

Functions

class_label label (const std::string &text)
 Extracts a class_label from a string in libsvm format. More...
 
counts_t counts (const std::string &text, bool contains_label=true)
 
void throw_exception (const std::string &text)
 

Detailed Description

Parser specifically for libsvm-formatted files.

Function Documentation

§ label()

class_label meta::io::libsvm_parser::label ( const std::string &  text)

Extracts a class_label from a string in libsvm format.

Parameters
textA libsvm-formatted string; throws an exception if it can't be parsed correctly
Returns
the class_label

§ counts()

counts_t meta::io::libsvm_parser::counts ( const std::string &  text,
bool  contains_label = true 
)
Parameters
textA libsvm-formatted string; throws an exception if it can't be parsed correctly
contains_labelWhether this string's first token is the class_label
Returns
(feature, count) pairs of the libsvm data