|
Tigger Novice
Joined: 07 Oct 2002 Posts: 46 Location: USA
|
Posted: Mon Dec 30, 2002 2:54 am
Pig Latin |
Has anyone made a pig latin code for different chans on a mud?
Just incase someone doesn't know what pig latin is. Pig Latin is a simple code where you remove the first letters from a word till you get a a vowel (if it starts with a vowel you remove none), then you add the letters you took off the beging of the word and add "ay". So Pig Latin = Igpay Atinlay
I hope someone has this, but if noone does I think I can figre out everything but the checking for a vowel. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Dec 30, 2002 4:12 am |
quote:
Has anyone made a pig latin code for different chans on a mud?
Just incase someone doesn't know what pig latin is. Pig Latin is a simple code where you remove the first letters from a word till you get a a vowel (if it starts with a vowel you remove none), then you add the letters you took off the beging of the word and add "ay". So Pig Latin = Igpay Atinlay
I hope someone has this, but if noone does I think I can figre out everything but the checking for a vowel.
The checking for vowels would be the easiest part:
#alias piglatin {
#variable Words %replace(%-1," ","|")
#variable CurWord %item(@Words,1)
#variable Consonents ""
#NOOP check for consonents
#forall @Words {#if (%begins(@CurWord,"a") or %begins(@CurWord,"e") or %begins(@CurWord,"i") or %begins(@CurWord,"o") or %begins(@CurWord,"u")) {#noop it starts with a vowel, so do nothing} {#noop starts with a consonent}}
Doing the consonents will be a bit more involved, but should be easily figured out. As for the appending, you can use this:
#variable CurWord %concat(@CurWord,@Consonents,"ay")
li'l shmoe of Dragon's Gate MUD |
|
|
|
Tigger Novice
Joined: 07 Oct 2002 Posts: 46 Location: USA
|
Posted: Tue Dec 31, 2002 3:00 am |
man I need help on this one....if anyone can help me with this pig latin thing I would realy appericate it.
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Dec 31, 2002 6:21 am |
I forgot to say in my initial post that I didn't test this or verify the correctness of my syntax. One should always check this if unsure.
quote:
man I need help on this one....if anyone can help me with this pig latin thing I would realy appericate it.
What have you tried so far? To extract the consonents here's what you can do:
1)we already know the first letter is a consonent, so immediately copy %left(@CurWord,1) to the @Consonents variable
Ex. #variable Consonents %left(@CurWord,1)
2)begin a loop to check each leftmost character of the current word. If a consonent, use %concat() to append the leftmost character to @Consonents. If a vowel, exit out of the loop.
ex. #while !(%left(@CurWord,1) ~= "a|e|i|o|u") {#variable Consonents %concat(@Consonents,%left(@CurWord,1));#variable CurWord %rightback(@Curword,2)}
3)assemble the new word and replace the old word. You can use %concat() and %replaceitem for this (%i is the counter from the #forall command in my initial reply):
Words = %replaceitem(@Words,%i,%concat(@CurWord, @Consonents,"ay"))
li'l shmoe of Dragon's Gate MUD |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Tue Dec 31, 2002 2:05 pm |
There you go:
#ALIAS piglatin {#VARIABLE message "";#FORALL %replace( "%-1", " ", "|") {#VARIABLE vowelpos {%concat( %pos( "a", %lower( %i)), "|", %pos( "e", %lower( %i)), "|", %pos( "i", %lower( %i)), "|", %pos( "o", %lower( %i)), "|", %pos( "u", %lower( %i)))};#VARIABLE vowelpos %sort( @vowelpos);#IF ((%number( %item( @vowelpos, 5)) < 2) or (%ismember("1", @vowelpos))) {#VARIABLE message {%concat( @message, %i, "ay ")}} {#DELITEM vowelpos 0;#VARIABLE message {%concat( @message, %if( %ascii( %left( %i, 1)) < 91, %proper( %right( %i, %number( %item( @vowelpos, 1)) - 1)), %right( %i, %number( %item( @vowelpos, 1)) - 1)), %lower( %left( %i, %number( %item( @vowelpos, 1)) - 1)), "ay ")}}};#VARIABLE message %trim( @message);say @message}
It tries to handle proper case as best as it can, but it will not always be perfect. Also, punctuation will produce funny results as it will be considered part of the word if it is not separated by a space.
Kjata |
|
|
|
Tigger Novice
Joined: 07 Oct 2002 Posts: 46 Location: USA
|
Posted: Wed Jan 01, 2003 4:58 am |
thank you so much....it works better than anything I have done
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|