Anslatortray
anslatortray Namespace Reference

Namespace containing functions to translate from English to Pig Latin. More...

Namespaces

 Characters
 

Functions

std::string smartWordToPig (const std::string &englishWord)
 Translates a single complex English word to pig latin. (more robust) More...
 
std::string translate (const std::string &englishText)
 Uses smartWordToPig and changeWords to perform translation from English to pig latin on every word it is given. More...
 
std::string wordToPig (const std::string &englishWord)
 Translates a single English word to pig latin. More...
 
std::string wordsToPig (const std::string &englishWords)
 Uses wordToPig and changeWords to perform dumb translation from English to pig latin on every word it is given. More...
 
std::string attemptWordToEnglish (const std::string &pig, std::uint64_t beginningVowels=1)
 Tries to translate a word in pig latin back to english. More...
 
std::string changeWords (const std::string &words, std::string wordChanger(const std::string &word))
 Helper function to perform an operation on all whitespace-seperated strings given to it. More...
 

Detailed Description

Namespace containing functions to translate from English to Pig Latin.

Function Documentation

◆ attemptWordToEnglish()

std::string anslatortray::attemptWordToEnglish ( const std::string &  pig,
std::uint64_t  beginningVowels = 1 
)
inline

Tries to translate a word in pig latin back to english.

This is hard to do because diffrent English words can be the same in Pig latin.

Parameters
pigWord in pig latin
beginningVowelsHonestly don't remember
Returns
Word in English

◆ changeWords()

std::string anslatortray::changeWords ( const std::string &  words,
std::string   wordChangerconst std::string &word 
)
inline

Helper function to perform an operation on all whitespace-seperated strings given to it.

Probably could do something better with std::transform

Parameters
wordsWords (tokens) seperated by whitespace
wordChangerFunction taking a const std::string & as a single parameter and returning a std::string
Returns
Words fed through wordChanger with spaces between them

◆ smartWordToPig()

std::string anslatortray::smartWordToPig ( const std::string &  englishWord)
inline

Translates a single complex English word to pig latin. (more robust)

Unlike wordToPig, this function also handles punctuation (not seperated by whitespace), singular possesion ('s) and capatilizes the first letter if the original english word was capatilized.

Parameters
englishWordAn English word to translate
Returns
The word in pig latin

◆ translate()

std::string anslatortray::translate ( const std::string &  englishText)
inline

Uses smartWordToPig and changeWords to perform translation from English to pig latin on every word it is given.

Replaces all whitespace with a regular space.

Parameters
englishTextThe original English text
Returns
The text translated to pig latin

◆ wordsToPig()

std::string anslatortray::wordsToPig ( const std::string &  englishWords)
inline

Uses wordToPig and changeWords to perform dumb translation from English to pig latin on every word it is given.

Replaces all whitespace with a regular space.

Parameters
englishTextThe original English text
Returns
The text "translated" to pig latin (no punctuation, uppercase, or possesion support)

◆ wordToPig()

std::string anslatortray::wordToPig ( const std::string &  englishWord)
inline

Translates a single English word to pig latin.

Moves all constanants until the first vowel to the end of the word and adds "ay". Alternativly, if the word starts with a vowel, "way" is added to the end.

Parameters
englishWordAn English word to translate
Returns
The word in pig latin