Qbasicnews.com

QbasicNews.Com => Challenges => Topic started by: whitetiger0990 on May 22, 2003, 09:20:10 PM



Title: Piglatin
Post by: whitetiger0990 on May 22, 2003, 09:20:10 PM
Make a program that turns and inputed string to pig latin.
You should know what pig latin is but if you don't this is pig latin...

String: Cat
Piglatin: atcay

or

String: Igloo
Piglatin: Iglooway

Go!

Etlay eesay owhay oodgay ouyay areway!


Title: Piglatin
Post by: seph on May 22, 2003, 09:39:23 PM
I could do it, but it would take too much work for this simple little program... like, I mean, a ridiculous amount of work.


Title: Piglatin
Post by: whitetiger0990 on May 22, 2003, 10:16:24 PM
and your point. i dont see the trouble


Title: Piglatin
Post by: seph on May 22, 2003, 10:19:31 PM
Unless you really need this program very badly, I can't be bothered to spend that much time on it ;) Too much other stuff going on for meh... :(


Title: Piglatin
Post by: Ninkazu on May 22, 2003, 10:39:15 PM
I only made it take the first letter. The other kinds I couldn't bother with.

Code:
DEFINT A-Z
DECLARE FUNCTION Parse$ (Word$, Sep$, Word%)
CLS
INPUT "Sentence to Tranlate?", trans$
m = 1
FOR n = 1 TO LEN(trans$)
 l = INSTR(m, trans$, " ")
 IF l THEN m = m + l: k = k + 1
NEXT
FOR o = 1 TO k + 1
 daword$ = Parse$(trans$, " ", o)
 endin$ = LEFT$(daword$, 1)
 wordout$ = RIGHT$(daword$, LEN(daword$) - 1) + endin$ + "ay"
 PRINT wordout$ + " ";
NEXT

DEFSNG A-Z
FUNCTION Parse$ (Word$, Sep$, Word%)
l% = 1: S% = 1
W$ = Sep$ + Word$ + Sep$
DO
 S% = INSTR(S% + 1, W$, Sep$): IF S% = 0 THEN EXIT DO
 SELECT CASE S%
  CASE 0: EXIT FUNCTION
  CASE IS > 1: Wd% = Wd% + 1
   IF Wd% = Word% THEN Parse$ = MID$(W$, l% + LEN(Sep$), S% - l% - LEN(Sep$)): EXIT DO
 END SELECT
 l% = S%
LOOP
END FUNCTION


Title: Piglatin
Post by: whitetiger0990 on May 22, 2003, 11:24:09 PM
Ninkazu: The first letter!
Igloo is "iglooway" not "glooiay"
chop is "opchay" not "hopcay"
Close but not quite an all english - pig latin word converter.
Mine is kinda mess up but it works. But it only does a word at a time. Not setences like yours. Nice.

Ninkazu - 4 points

If it worked with all words you would have gotten higher.


Title: Piglatin
Post by: Dav on May 22, 2003, 11:25:51 PM
Not sure exactly how pig latin works.  All I know about it is from an old 3 stooges clip.

Anyway, here's a quick, throw-together...

Code:

In$ = "david"
Out$ = ""
SELECT CASE UCASE$(LEFT$(In$, 1))
  CASE IS = "A", "E", "I", "O", "U"
    Out$ = In$ + "-way"
  CASE ELSE
    Out$ = RIGHT$(In$, LEN(In$) - 1)
    Out$ = Out$ + "-" + LEFT$(In$, 1) + "ay"
END SELECT
PRINT Out$


Title: Piglatin
Post by: DrV on May 22, 2003, 11:27:42 PM
This is insanely difficult... you'd have to write some sort of natural language engine to figure out how stuff should be pronounced, then write rules to move certain characters certain places, etc, etc... it's not really worth it.  But if you have working code, I'd like to give it a whirl, just to see if I could make it break.   :D   Good luck on your programming endeavours, anyhow.  Maybe you'll write the next Google!  :)


Title: Piglatin
Post by: whitetiger0990 on May 22, 2003, 11:36:40 PM
Quote from: "Dav"
Not sure exactly how pig latin works.  All I know about it is from an old 3 stooges clip.

Anyway, here's a quick, throw-together...

Code:

In$ = "david"
Out$ = ""
SELECT CASE UCASE$(LEFT$(In$, 1))
  CASE IS = "A", "E", "I", "O", "U"
    Out$ = In$ + "-way"
  CASE ELSE
    Out$ = RIGHT$(In$, LEN(In$) - 1)
    Out$ = Out$ + "-" + LEFT$(In$, 1) + "ay"
END SELECT
PRINT Out$


Short. cool. But I changed "david" to "chop" it printed

hop-cay

Not what is was looking for. But since it is short... 10 points!


Title: Piglatin
Post by: Dav on May 22, 2003, 11:42:35 PM
Oh, I see now.  Ok.  I'll try it again, but I'll have to wait for tommorrow.  I'm out of time tonight.  Bye.

- Dav


Title: Piglatin
Post by: Ninkazu on May 22, 2003, 11:55:03 PM
Quote from: "whitetiger0990"
Not what is was looking for. But since it is short... 10 points!


But... mine can convert a whole sentence... :'(
The Parse function is a super awesome routine that I think superghost created.


Title: Piglatin
Post by: DrV on May 23, 2003, 12:03:08 AM
That Parse routine is almost like C's strtok... I've got one just like it that I wrote a while back.  But interesting code, nonetheless... I can go alktay to my riendsfay in igpay atinlay now...  wait... I don't have any friends...  :(  
j/k


Title: Piglatin
Post by: Ninkazu on May 23, 2003, 12:09:50 AM
I have two friends :) (no, not my computer and porn)


Title: Piglatin
Post by: Dav on May 23, 2003, 12:09:58 AM
Last try for tonight.  (Getting sloppy, I know)

Code:

In$ = "chop"
Out$ = ""
SELECT CASE UCASE$(LEFT$(In$, 1))
  CASE IS = "A", "E", "I", "O", "U"
    Out$ = In$ + "-way"
  CASE ELSE
    FOR x% = 2 TO LEN(In$)
      SELECT CASE UCASE$(MID$(In$, x%, 1))
        CASE IS = "A", "E", "I", "O", "U": EXIT FOR
      END SELECT
    NEXT
    L$ = LEFT$(In$, x% - 1)
    R$ = MID$(In$, x%, LEN(In$))
    Out$ = R$ + "-" + L$ + "ay"
END SELECT
PRINT Out$


- Dav


Title: Piglatin
Post by: Hexadecimal Disaster on May 23, 2003, 02:41:08 AM
Pig latin?? Spucatum tauri! (http://www.handykult.de/plaudersmilies.de/eek6.gif)


Title: Piglatin
Post by: Neo on May 23, 2003, 10:37:45 AM
wtf is piglatin?


Title: Piglatin
Post by: Dav on May 23, 2003, 11:01:12 AM
It's a silly but popular english language game.  Words beginning with vowels have "WAY" attached to it ('igloo' becomes 'igloo-way').  If a word has constants at the beginning, they're move to the end with "AY" at the end. ('string' becomes ing-stray).  Words beginning with QU are done like this. ('quest' becomes 'est-quay')

It's worthless talk, but became very popular in the US among both kids and adults.

Here's my last try.  This one parses, but periods, question marks, etc,  are not handled.  

Code:

DECLARE FUNCTION Piggy$ (In$)

PRINT Piggy$("what is pig latin that is the question")
PRINT Piggy$("hello my name is dave and i'm a pig")
PRINT
INPUT "What do you say, pig"; A$
PRINT Piggy$(A$)

FUNCTION Piggy$ (In$)

Out$ = ""

DO UNTIL w >= LEN(In$)
    '=== Parse a word...
    temp$ = ""
    WHILE MID$(In$, w + 1, 1) <> " " AND MID$(In$, w + 1, 1) <> ""
        temp$ = temp$ + MID$(In$, w + 1, 1)
        w = w + 1
    WEND
    '====== piggy it ====
    FOR x% = 1 TO LEN(temp$)
      SELECT CASE UCASE$(MID$(temp$, x%, 1))
        CASE IS = "A", "E", "I", "O", "U", "Y": EXIT FOR
      END SELECT
    NEXT
    '=== If vowel first...
    IF x% = 1 THEN
       Out$ = Out$ + temp$ + "-way "
    '=== If starts with "qu"...
    ELSEIF UCASE$(LEFT$(temp$, 2)) = "QU" THEN
       Out$ = Out$ + RIGHT$(temp$, LEN(temp$) - 2)
       Out$ = Out$ + "-" + LEFT$(temp$, 2) + "ay "
    '=== else...
    ELSE
       L$ = LEFT$(temp$, x% - 1)
       R$ = MID$(temp$, x%, LEN(temp$))
       Out$ = Out$ + R$ + "-" + L$ + "ay "
    END IF
    '====================
    w = w + 1
LOOP

Piggy$ = Out$

END FUNCTION



- Dav