AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Piglatin translator to english3/1/2024 SentenceToTranslate = sentenceToTranslate. Var sentenceToTranslate = ask("Please enter some text for translating to pig Latin:") define some useful arrays that define the characters that are consonants or vowels The name is an intentional misnomer the Latin doesn’t have to be Latin at all, and no one’s exactly sure why the Pig couldn’t be a Donkey. Plenty have tried to understand or contextualize the etymology of the name Pig Latin to little avail. One of our student’s solutions: import AVFoundation // needed for the text-to-speech synthesis And today, there are even Pig Latin-to-English translators you can use. translation service.Pig Latin to English Translator. This template might contain the code to launch the voice synthesizer and/or provide your students some helper arrays: let consonants = PigLatin object for each string you want to translate is really a good idea. If possible, share a template with your students to get them started. This is what the “!” is in the line: var firstLetter = word.first! However, all our words will have at least one character since our array of words was constructed by splitting sentences into words, so it is fine to ‘force unwrap’ the value returned from. first property returns an optional character, however, since a string may be empty and not have a first character. In the code example below, we get the first character of a word by using the. components(separateBy: ” “) is very handy for this task. Then when they have successfully tested their algorithm with single words, guide them to create an array of single words out of the user input sentence. Have the students develop their translation code using single words at a time. Use the “Answers” template in Swift Playgrounds for this activity since you will 1) be gathering input from the user, and 2) using show() to debug and test the code by printing the translated words and phrases. Googles service, offered free of charge, instantly translates words, phrases, and web pages between English and over 100 other languages. Once a student is happy that their program is working, they can add the code to have the voice synthesizer speak the resulting Pig-Latin string. The goal at first is to turn an input string into the corresponding string in Pig-Latin. Then have the students encode the rules into a Swift program. Lesson: Have the students write down on paper or in comments in a blank playground the rules for translating English into Pig-Latin. If students already know the rules, ask them to not spoil it for others while they figure it out. Ask them to try to figure out how the language is constructed. Introductory Activity: Introduce pig-latin to students using a couple phrases. Goal: Activity to practice formulating algorithms.
0 Comments
Read More
Leave a Reply. |