Anslatortray
anslatortray Namespace Reference

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

Namespaces

 Characters
 Arrays of diffrent characters (internal use)
 

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 numBeginningConosoants=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 words (tokens) given to it. More...
 

Variables

constexpr char VOWEL_START_STYLE [] = {"way"}
 Ending to use if word to translate starts with a vowel. 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  numBeginningConosoants = 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.
Disabled by defining ANSLATORTRAY_TINY_TRANSLATOR

Parameters
pigWord in Pig Latin
numBeginningConosoantsThe number of conosonants before the first vowel in the original word. Default 1 (most common)
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 words (tokens) given to it.

See Characters::WHITESPACE for the types

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 creates similar capatilization to the original english word (unless disabled by defining ANSLATORTRAY_IGNORE_CAPS).
Imperfect results with plural words (ending in "s") and words with mutiple possesion (ending in "s'")

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.
Disabled by defining ANSLATORTRAY_TINY_TRANSLATOR

Parameters
englishWordsThe 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

Variable Documentation

◆ VOWEL_START_STYLE

constexpr char anslatortray::VOWEL_START_STYLE[] = {"way"}

Ending to use if word to translate starts with a vowel.