0
$\begingroup$

Pig-Latin, and other similair argots, were quite popular when i was young (but since i grew up in Sweden the biggest was Rövarspråket). These language games almost always consist of a given set of rules from which letters and words are translated into something else. For example in Pig-Latin the rules are the following (source):

For words that begin with consonant sounds, all letters before the initial vowel are placed at the end of the word sequence. Then, "ay" is added, as in the following examples:[10]

  • "pig" = "igpay"
  • "latin" = "atinlay"

When words begin with consonant clusters (multiple consonants that form one sound), the whole sound is added to the end when speaking or writing.[11]

  • "cheers" = "eerschay"
  • "shesh" = "eshshay"

For words that begin with vowel sounds, one just adds "way" or "yay" to the end (or just "ay"). Examples are:

  • "eat" = "eatway" or "eatay"
  • "omelet" = "omeletway" or "omeletay"

An alternative convention for words beginning with vowel sounds, one removes the initial vowel(s) along with the first consonant or consonant cluster. This usually only works for words with more than one syllable and offers a more unique variant of the words in keeping with the mysterious, unrecognizable sounds of the converted words. Examples are:

  • "every" = "eryevay"
  • "omelet" = "eletomay"

My question is if there are any Machine Learening algorithms that is suitable to be able to learn to translate a sentence to Pig-Latin by training on a large set of "english"="pig_latin"-pairs without explicity knowing anything about the rules? Or if anybody can motivate and point me to the right direction.

My goal is to be able to input an arbitrary word, which might not even be a real word, and get the "Pig-Latin"-translated word.

My initial idea was to set up a Neural Network (mainly because thats what I know best) where the input neurons should take the ASCII-code for each letter and the output should be the ASCII-code for each letter (always capital letters), i.e.

Input (for PIG):
080 073 071

Output (for IGPAY)):
073 071 080 065 089

A neural network can be trained to map for example 080 to 073, but how do i for example handle the aribtrary length of the input and output (if Neural Networks ar applicable to this problem).

$\endgroup$
  • $\begingroup$ A RNN (LSTM) would be suited to this problem, for dealing with the arbitrary input and output lengths. Also, you'll want to one-hot-encode the letters (as opposed to deal directly in ascii codes as numeric input and output). There is absolutely no point in using ML on this problem though, other than as a toy problem in order to learn ML. Also RNNs are moderately advanced NN types, so this isn't necessarily the first toy problem you'd want to tackle. $\endgroup$ – Neil Slater Nov 13 '17 at 7:58
  • $\begingroup$ I am familiar with both NN, RNN and LSTM so this is not my first "toy problem", but yes, you can see it as a toy problem in the form of "look what machine learning can learn" (even though i know there are better ways to solve my specific problem. My goal is to be able to input an arbitrary word, which might not even be a real word, and get the "Pig-Latin"-translated word. And when you say one-hot-endode the letters, do you mean for example is_vowel? $\endgroup$ – Cleared Nov 13 '17 at 8:05
  • $\begingroup$ By one-hot-encode I mean define a vector of same length as number of allowed characters, and for each letter setting it to 0 everywhere except for one element that equals 1, different for each type of character. This is sometimes called an "indicator" vector or "binarization". E.g. "A" might be [1,0,0,0,0,0,0,0,0,0,0,0...] and "B" might be [0,1,0,0,0,0,0,0,0,0,0...] $\endgroup$ – Neil Slater Nov 13 '17 at 8:19
  • $\begingroup$ Thanks, make sense since A is no more similair to B than to Z. $\endgroup$ – Cleared Nov 13 '17 at 8:23
  • 1
    $\begingroup$ You could also add things like is_vowel set to 0 or 1, and they would probably improve the performance in this case. However, if your goal is to see whether ML can learn just from the examples, there is no need to give the algorithm any of this kind of help. $\endgroup$ – Neil Slater Nov 13 '17 at 8:31
1
$\begingroup$

Look at Neural Machine Translation models, you could either 'cheat' and tokenize both the English and the Pig-Latin words or you could make it character based which I think is more interesting and it allows to generalize for words out of dictionary. These models are called sequence to sequence models and there are plenty of implementations that can take pairs of sequences to translate. I think this task can be solved with accuracy close to 100%.

Here is an implementation in Keras: https://github.com/farizrahman4u/seq2seq

Here is an official TensorFlow tutorial: https://github.com/tensorflow/nmt

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.