Public Member Functions | Private Member Functions | Private Attributes | List of all members
CVocFile Class Reference

Vocabulary File class. More...

#include <vocfile.H>

Public Member Functions

 CVocFile (char *filename)
 Constructor.
void AppendVocabulary (std::vector< SWord > &vocabulary, const bool &bSynonym, const enVocLang &enLang)
 Append Vocabulary function.

Private Member Functions

void trim (std::string &str)
 Helper function.
size_t checkLine (std::string &line)
 Helper function.
void seperateWords (std::string str, std::vector< std::string > &words)
 Helper function.
void addWordToVocabulary (const SWord &word, std::vector< SWord > &vocabulary, const bool &bSynonym, const enVocLang &enLang)
 Helper function.

Private Attributes

std::string m_strFilename
 vocabulary filename

Detailed Description

Vocabulary File class.

This class reads a vocabulary file and appends the words to a vector.

Constructor & Destructor Documentation

CVocFile::CVocFile ( char *  filename)

Constructor.

This constructor initializes the vocabulary filename.

Parameters
filenamevocabulary filename

Member Function Documentation

void CVocFile::addWordToVocabulary ( const SWord word,
std::vector< SWord > &  vocabulary,
const bool &  bSynonym,
const enVocLang &  enLang 
)
private

Helper function.

This function adds a word to a vocabulary vector. If the synonym mode is enabled, it will also split one vocabulary word into n-lang-synonym vocabulary items.

Parameters
wordThis word will be added to a vocabulary vector.
vocabularyWord will be appended to this vocabulary vector.
bSynonymsynonym mode
enLanginquiry language

References SWord::lang1, SWord::lang2, and SWord::numPasses.

Referenced by AppendVocabulary().

void CVocFile::AppendVocabulary ( std::vector< SWord > &  vocabulary,
const bool &  bSynonym,
const enVocLang &  enLang 
)

Append Vocabulary function.

This function reads a vocabulary file and appends the words to a vector. A error message will be written to the stderr if a line is incorrect. If the synonym mode is enabled, it will also split one vocabulary word resp. one line into n-lang-synonym items.

Parameters
vocabularyWords will be appended to this vector.
bSynonymsynonym mode
enLanginquiry language

References addWordToVocabulary(), checkLine(), CVocatraInfo::GetName(), SWord::lang1, SWord::lang2, m_strFilename, SWord::numPasses, and seperateWords().

Referenced by CVocTrainer::Init().

size_t CVocFile::checkLine ( std::string &  line)
private

Helper function.

This function trims a line and checks if this line is in the correct format.

Parameters
lineThis string will be checked.
Returns
Returns the position from the equal sign. If the return value is 0 the line is commented out or empty. If the return value is string::npos the line is incorrect.
See Also
trim

References trim().

Referenced by AppendVocabulary().

void CVocFile::seperateWords ( std::string  str,
std::vector< std::string > &  words 
)
private

Helper function.

This function separates a string into words. The separation sign is a comma.

Parameters
strThis string will be separated.
wordsWords will be assigned to this vector.

References trim().

Referenced by AppendVocabulary().

void CVocFile::trim ( std::string &  str)
private

Helper function.

This function trims spaces and tabulators from a string.

Parameters
strThis string will be trimmed.

Referenced by checkLine(), and seperateWords().


The documentation for this class was generated from the following files:

Get Vocatra at SourceForge.net. Fast, secure and Free Open Source software downloads Generated for Vocatra by doxygen