For example, 'which' is translated into 'ichwhay'. If it begins with a consonant, then we take all consonants before the first vowel and we put them on the end of the word. For example, 'out' is translated into 'outyay'. Its a fairly simple concept but Im struggling to find a way to translate the word if the word begins with a consonant, here is my code so far: def pigLatin (word): for l in vowels: if word 0 l: word word + 'ay' for L in consonants: if word 0 L: for i in vowels: for s in word: if s i: this is where im completely lost. txt file is free by clicking on the export iconĬite as source (bibliography): Pig Latin on dCode. The rules used by Pig Latin are as follows: If a word begins with a vowel, just as 'yay' to the end. The copy-paste of the page "Pig Latin" or any of its results, is allowed (even for commercial purposes) as long as you cite dCode!Įxporting results as a. And then write an extra function that uses that single word function to translate a whole sentence: def translatesentence (sentence): words sentence.split () pigged for word in words: piggedword translate (word) pigged.append (piggedword) Turn it back into a single string result ' '.join (pigged) return result. Except explicit open source licence (indicated Creative Commons / free), the "Pig Latin" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Pig Latin" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Pig Latin" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app! The language is often used by children who want to hide, for example. Ask a new question Source codeĭCode retains ownership of the "Pig Latin" source code. The Pig Latin translator translates text in the English secret language Pig Latin. This suggest you that if you get a word like 'allway' you can't give a unique translation in English, but (at least) two. ![]() For example, imagine to have 2 English words like 'all' and 'wall', the corresponding Pig Latin words will be always 'allway'. This English to Pig Latin translation program performs a (near-) perfect translation of any English text to Pig Latin. Pig Latin involves moving letters to the end of words, while verlan involves reversing the order of syllables in each word. The problem is that Pig Latin/English translation is not a bijective function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |