Simple PHP script?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BryanA

    Simple PHP script?

    Here is what I want to do. I want to be able to load a list of
    correctly spelled words in and then the script will come up with
    misspelled versions of that word and insert it into a mysql db. My
    question is, where would I start?

    Thanks,
    Bryan
  • Gremnebulin

    #2
    Re: Simple PHP script?

    On 3 Oct, 01:47, BryanA <Bryan.Andr...@ gmail.comwrote:
    Here is what I want to do. I want to be able to load a list of
    correctly spelled words in and then the script will come up with
    misspelled versions of that word and insert it into a mysql db. My
    question is, where would I start?
    >
    Thanks,
    Bryan
    Are you having problems with the basic loading and saving, or with the
    "generating mispelled" bit (which looks vaguely-defined to me) ?

    Comment

    • Geoff Berrow

      #3
      Re: Simple PHP script?

      Message-ID:
      <2051eca3-d689-4bbc-9f63-1128a4ee2d10@u6 5g2000hsc.googl egroups.comfrom
      BryanA contained the following:
      >Here is what I want to do. I want to be able to load a list of
      >correctly spelled words in and then the script will come up with
      >misspelled versions of that word and insert it into a mysql db. My
      >question is, where would I start?
      What for?
      --
      Geoff Berrow 011000100110110 0010000000110
      001101101011011 001000110111101 100111001011
      100110001101101 111001011100111 010101101011
      http://slipperyhill.co.uk - http://4theweb.co.uk

      Comment

      • C. (http://symcbean.blogspot.com/)

        #4
        Re: Simple PHP script?

        On 3 Oct, 01:47, BryanA <Bryan.Andr...@ gmail.comwrote:
        Here is what I want to do. I want to be able to load a list of
        correctly spelled words in and then the script will come up with
        misspelled versions of that word and insert it into a mysql db. My
        question is, where would I start?
        >
        Thanks,
        Bryan
        Work out an algorithm, implement the algorithm in PHP then test it.

        C.

        Comment

        • Lee Hanken

          #5
          Re: Simple PHP script?

          BryanA wrote:
          Here is what I want to do. I want to be able to load a list of
          correctly spelled words in and then the script will come up with
          misspelled versions of that word and insert it into a mysql db. My
          question is, where would I start?
          >
          Thanks,
          Bryan
          An algorithm such as the one used in:



          can be re-written in php as in the following:

          $word = "Spelling";

          $word = strtolower($wor d);

          $length = strlen($word);

          // deletion
          for ($i=0;$i<$lengt h;$i++)
          $variants[] = substr($word,0, $i) .
          substr($word,$i +1,$length-$i-1);

          // transposition
          for ($i=0;$i<$lengt h-1;$i++)
          $variants[] = substr($word,0, $i) .
          substr($word,$i +1,1) .
          substr($word,$i ,1) .
          substr($word,$i +2,$length-$i-2);

          // alteration
          for ($i=0;$i<$lengt h;$i++)
          for ($c=ord('a'); $c <= ord('z'); $c++)
          $variants[] = substr($word,0, $i) .
          chr($c) .
          substr($word,$i +1,$length-$i-1);
          // insertion
          for ($i=0;$i<$lengt h+1;$i++)
          for ($c=ord('a'); $c <= ord('z'); $c++)
          $variants[] = substr($word,0, $i) .
          chr($c) .
          substr($word,$i ,$length-$i);
          // remove identical variants
          foreach ($variants as $n =$variant)
          if ($variant == $word)
          unset($variants[$n]);

          print_r($varian ts);

          -Lee

          Comment

          • -Lost

            #6
            Re: Simple PHP script?

            Response to BryanA <Bryan.Andreas@ gmail.com>:
            Here is what I want to do. I want to be able to load a list of
            correctly spelled words in and then the script will come up with
            misspelled versions of that word and insert it into a mysql db. My
            question is, where would I start?
            Unit tests are an ideal place to start. Look for the functionality
            you desire.

            --
            -Lost
            Remove the extra words to reply by e-mail. Don't e-mail me. I am
            kidding. No I am not.

            Comment

            Working...