TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MP on April 29, 2005, 05:07:29 AM

Title: Insomnia? Simple, write a typoglycemia function.
Post by: MP on April 29, 2005, 05:07:29 AM
What?

Remember this nonesence, typoglycemia?

I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg The phaonmneal pweor of the hmuan mnid Aoccdrnig to rscheearch taem at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoatnt tihng is taht the frist and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it wouthit a porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Such a cdonition is arppoiately cllaed Typoglycemia :)- Amzanig huh? Yaeh and yuo awlyas thought slpeling was ipmorantt!

Well, when you have insomnia and need something mindless and mildy interesting to keep from going mad you write crud like this --

Code: [Select]
(defun typos ( text / scramble middle rotate main )

    (defun scramble ( codes )
        (if (< (length codes) 4)
            codes
            (append
                (list (car codes))
                (rotate (middle codes))
                (list (last codes))
            )
        )
    )
   
    (defun middle ( lst )
        (cdr
            (reverse
                (cdr
                    (reverse lst)
                )
            )
        )
    )

    (defun rotate ( lst )
        (cons
            (last lst)
            (reverse
                (cdr
                    (reverse lst)
                )
            )
        )
    )

    (defun main ( text / punc codes result )

        (setq punc
            (vl-string->list
                "\".?!:-,;/()[]{}\n\r\t "
            )
        )

        (foreach code

            (reverse
                (vl-string->list
                    (vl-string-trim
                        " \t\n"
                        text
                    )
                )
            )

            (cond
                (   (member code punc)
                    (if codes
                        (setq result
                            (cons
                                (scramble codes)
                                result
                            )
                            codes nil
                        )
                    )
                    (setq result
                        (cons
                            (list code)
                            result
                        )
                    )
                )
                (   (setq codes
                        (cons
                            code
                            codes
                        )
                    )
                )
            )
        )

        (vl-list->string
            (apply 'append
                (if codes
                    (cons
                        (scramble codes)
                        result
                    )
                    result
                )
            )
        )
    )

    (main text)

)

(typos "Now, whenever you feel the need to ...")

Now, wehenevr you feel the need to aonny yuor fdriens, or jsut slpel lkie Jhon, jsut psas yuor txet tghrouh tihs slimpe rnoutie!

Edit: Distilled routine.
Title: Insomnia? Simple, write a typoglycemia function.
Post by: Kerry on April 29, 2005, 05:15:29 AM
Insomnia, take a book to bed. I have broken several pairs of glasses doing just that.

coding for typoglycemia :
You raelly firgthen me Michael

:D

Dont let John near that code ...
Title: Insomnia? Simple, write a typoglycemia function.
Post by: MP on April 29, 2005, 05:20:13 AM
Quote from: Kerry Brown
You raelly firgthen me Michael

I fhterign melysf dood! :shock:

Quote from: Kerry Brown
Dont let John near that code ...

Good one, it wulod rdeenr his slinpelg erorr fere. :lol:
Title: Insomnia? Simple, write a typoglycemia function.
Post by: MickD on April 29, 2005, 05:38:52 AM
What's Typoglycemia??? :lol:

Seriously though, I had no trouble reading that post, is that a good thing?
Title: Insomnia? Simple, write a typoglycemia function.
Post by: CAB on April 29, 2005, 07:44:46 AM
Oh my, if you can read that you have a case of it too.
I recommend bourbon, and lot's of it. :)
Title: Insomnia? Simple, write a typoglycemia function.
Post by: daron on April 29, 2005, 07:51:23 AM
That is cool.
Title: Insomnia? Simple, write a typoglycemia function.
Post by: David Hall on April 29, 2005, 09:18:05 AM
MP - D@MN, thats cool
MickD - Good to see you here
CAB - Whose pouring?
Title: Insomnia? Simple, write a typoglycemia function.
Post by: MP on April 29, 2005, 10:10:12 AM
Burbon (most alcohol) gives me terrible heartburn.

:(

Thanks anyway guys. I think I'll just get a large mallet to put beside the bed; could double for caveman foreplay.
Title: Insomnia? Simple, write a typoglycemia function.
Post by: SMadsen on April 29, 2005, 05:33:05 PM
Now the real task: scramble the code above and write a program that teaches the computer to deal with typoglycemia as well as humans deal with it.
Title: Insomnia? Simple, write a typoglycemia function.
Post by: CAB on April 29, 2005, 06:04:18 PM
How about some pseudo code?

Code: [Select]
First have a dictionary sorted by first letter then by length then by last letter.
The dictionary is made of list grouped as sorted,

Convert the string into words, individual strings using space as the delimiter.
Loop through the list of strings.
If strings less than 4 letters
  add to reconstruct list plus space
Else
  Find the Dictionary list with the match of first char, last char & length match.
  Loop through the dictionary sub list
  Find the match for any word using the interior letters.
  add to reconstruct list plus space
Done.


Some words will not be processed correctly but you could restruct your dictionary
to push the high percentage words to the top.

Well never as good as the human computer. But it will give something for Michael to
do the next sleepless night. :)
Title: Insomnia? Simple, write a typoglycemia function.
Post by: MP on April 29, 2005, 09:28:37 PM
Fnuny sftuf gyus, lol.

If one wree to tkae tihs on sleriosuy the way to do it wloud be taht if run tcwie it wloud rretun the oariginl txet, saimilr to a slimpe xnorig eoncryptin smchee.
Title: Insomnia? Simple, write a typoglycemia function.
Post by: pmvliet on May 05, 2005, 10:53:49 AM
In a way reversing this is doable.
Text messaging in a Cell Phone has predictive text.
If there was s text database, the computer can identify the first and last letter, it can figure out how many character's long the word is
and compare that to the database...
How many words start with T, end with T and is 4 character's long...

ok... it's the middle of the day and not night time.  :D

Pieter
Title: Insomnia? Simple, write a typoglycemia function.
Post by: MP on May 05, 2005, 12:02:26 PM
As stated, the easiest thing to imlement is a scheme, analagous to simple xoring bit twiddling, that results in the original string being generated if the routine is run twice.

This variant will do that:

Code: [Select]
(defun typos ( text / scramble middle group flip main )

    (defun scramble ( codes )
        (if (< (length codes) 4)
            codes
            (append
                (list (car codes))
                (flip (middle codes))
                (list (last codes))
            )
        )
    )

    (defun middle ( lst )
        (cdr
            (reverse
                (cdr
                    (reverse lst)
                )
            )
        )
    )

    (defun group ( lst len / group result )
        (foreach item lst
            (if
                (eq len
                    (length
                        (setq group
                            (cons item group)
                        )
                    )
                )
                (setq
                    result (cons group result)
                    group  nil
                )
            )
        )
        (reverse
            (mapcar 'reverse
                (if group
                    (cons group result)
                    result
                )
            )
        )
    )

    (defun flip ( lst )
        (apply 'append
            (mapcar 'reverse
                (group lst 2)
            )
        )
    )

    (defun main ( text / punc codes result )

        (setq punc
            (vl-string->list
                "\".?!:-,;/()[]{}\n\r\t "
            )
        )

        (foreach code

            (reverse
                (vl-string->list
                    (vl-string-trim
                        " \t\n"
                        text
                    )
                )
            )

            (cond
                (   (member code punc)
                    (if codes
                        (setq result
                            (cons
                                (scramble codes)
                                result
                            )
                            codes nil
                        )
                    )
                    (setq result
                        (cons
                            (list code)
                            result
                        )
                    )
                )
                (   (setq codes
                        (cons
                            code
                            codes
                        )
                    )
                )
            )
        )

        (vl-list->string
            (apply 'append
                (if codes
                    (cons
                        (scramble codes)
                        result
                    )
                    result
                )
            )
        )
    )

    (main text)

)

Example:

Code: [Select]
(setq JohnSpeak
    (typos
        (strcat
            "Admittedly, I am a hopeless nerd. "
            "I'm ok with that assessment."
        )
    )
)

=> "Amdtietldy, I am a hpoleses nred. I'm ok wtih taht asssemsnet."

(typos JohnSpeak)

=> "Admittedly, I am a hopeless nerd. I'm ok with that assessment."

:cheesy:
Title: Re: Insomnia? Simple, write a typoglycemia function.
Post by: jonesy on May 09, 2005, 07:01:26 AM
Quote from: MP
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg The phaonmneal pweor of the hmuan mnid Aoccdrnig to rscheearch taem at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoatnt tihng is taht the frist and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it wouthit a porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Such a cdonition is arppoiately cllaed Typoglycemia :)- Amzanig huh? Yaeh and yuo awlyas thought slpeling was ipmorantt

If this is true how do dyslexic people read?
Title: Insomnia? Simple, write a typoglycemia function.
Post by: MP on May 09, 2005, 07:39:38 AM
?siht ekil ti t'nsi tub ,sklof hcus fo thgil ekam ot hsiw t'nod I
Title: Insomnia? Simple, write a typoglycemia function.
Post by: jonesy on May 09, 2005, 07:50:20 AM
Now that one took me a while to work out!

The only reason I asked is cos my twins are quite severly dyslexic and if I could find a way to help them read I would (short of paying the £60 per week for extra tuition the various people want to charge!)
Title: Insomnia? Simple, write a typoglycemia function.
Post by: MP on May 09, 2005, 08:16:37 AM
My ignorance on this topic is vastly worse than any other I fear. :(

I hope and pray the twins get the help they need and their other gifts and talents make the dyslexia trivial in comparison.

(http://www.theswamp.org/screens/mp/thumbsup.gif)
Title: Insomnia? Simple, write a typoglycemia function.
Post by: hyposmurf on May 09, 2005, 08:20:49 AM
Quote from: jonesy
Now that one took me a while to work out!

The only reason I asked is cos my twins are quite severly dyslexic and if I could find a way to help them read I would (short of paying the £60 per week for extra tuition the various people want to charge!)


£60 per week!Couldnt he visit a qualified dislexic specialist for that amount?Do the NHS offer any help?
Title: Insomnia? Simple, write a typoglycemia function.
Post by: jonesy on May 09, 2005, 08:47:25 AM
Quote from: hyposmurf

£60 per week!Couldnt he visit a qualified dislexic specialist for that amount?Do the NHS offer any help?


That is broken down to £30 per 1/2 hour lesson per child (x2 for the twins). That is with qualified dyslexic specialists. As it is not recognised as a disability, only a learning difficulty, there is no NHS available to my knowledge.

Rant on :
Now, if I were a single mum, living off the social system, I would probably get the lessons paid for.  :x
Rant off