PHP pspell

  • Dorky
  • Novice
  • Novice
  • Dorky
  • Posts: 15

Post 3+ Months Ago

Issue :not sure why it is not including any charactures after an apostrophe.

if you find any of this useful please put it to use, i will be posting the final draft as well. any suggestions at all are welcome weather they are in regards to the str_replace issue or just that it could be done better or more efficiently please post reply.


Code: [ Select ]
 
 
 
<?php
 
$pspell_link = pspell_new("en");
$words = $_GET['text'] ;
echo  "<form method='get' action='spell.php'>";
 
 
if (isset($_GET['0']))
 {
foreach($_GET  as $key => $marker)  
  {
   $value = split('[ ]', $marker ); echo "Value : |0| $value[0] |1|  $value[1] |Key| $key0 <hr>";
   $value0[] = $value[0] ; $value1[] = $value[1] ;
   echo "Print Value Stage 1:";    print_r($value0); print_r($value1); echo "<hr>";
  }
 $print = str_replace( $value0 , $value1 , $words );
 }
 
 
if(!isset($_GET['0']))
 {
  $print = $words ;
 }
 
 
if (isset($_GET['check']))
 { echo "<b><i> $words </i></b><hr>";
  $words = $_GET['text'] ; $string = split('[ ]', $words); foreach($string as $key1 => $word)  
if (!pspell_check($pspell_link, $word))
  {
   echo "<hr><b><i>$word</i></b><br>"; $suggestions = pspell_suggest($pspell_link, $word);
foreach($suggestions as $key2 => $suggestion)
   {  
    $send = "$word $suggestion";   echo "<input type='checkbox' name='$key1' value='$send'>$suggestion<br>";
   }
  }
 }  
 
 
echo "<hr><textarea name='text'class='textarea' type='text/plain' rows='15' cols='40'>$print</textarea><hr>";
if(!isset($_GET['check'])) { echo "<button name='check' value='check check' type='submit'>Check Spelling</button>"; }
if(isset($_GET['check'])) { echo "<button name='done' value='done done' type='submit'>Done</button>"; }
echo "</form>";
 
 
?>
 
 
 
  1.  
  2.  
  3.  
  4. <?php
  5.  
  6. $pspell_link = pspell_new("en");
  7. $words = $_GET['text'] ;
  8. echo  "<form method='get' action='spell.php'>";
  9.  
  10.  
  11. if (isset($_GET['0']))
  12.  {
  13. foreach($_GET  as $key => $marker)  
  14.   {
  15.    $value = split('[ ]', $marker ); echo "Value : |0| $value[0] |1|  $value[1] |Key| $key0 <hr>";
  16.    $value0[] = $value[0] ; $value1[] = $value[1] ;
  17.    echo "Print Value Stage 1:";    print_r($value0); print_r($value1); echo "<hr>";
  18.   }
  19.  $print = str_replace( $value0 , $value1 , $words );
  20.  }
  21.  
  22.  
  23. if(!isset($_GET['0']))
  24.  {
  25.   $print = $words ;
  26.  }
  27.  
  28.  
  29. if (isset($_GET['check']))
  30.  { echo "<b><i> $words </i></b><hr>";
  31.   $words = $_GET['text'] ; $string = split('[ ]', $words); foreach($string as $key1 => $word)  
  32. if (!pspell_check($pspell_link, $word))
  33.   {
  34.    echo "<hr><b><i>$word</i></b><br>"; $suggestions = pspell_suggest($pspell_link, $word);
  35. foreach($suggestions as $key2 => $suggestion)
  36.    {  
  37.     $send = "$word $suggestion";   echo "<input type='checkbox' name='$key1' value='$send'>$suggestion<br>";
  38.    }
  39.   }
  40.  }  
  41.  
  42.  
  43. echo "<hr><textarea name='text'class='textarea' type='text/plain' rows='15' cols='40'>$print</textarea><hr>";
  44. if(!isset($_GET['check'])) { echo "<button name='check' value='check check' type='submit'>Check Spelling</button>"; }
  45. if(isset($_GET['check'])) { echo "<button name='done' value='done done' type='submit'>Done</button>"; }
  46. echo "</form>";
  47.  
  48.  
  49. ?>
  50.  
  51.  
  52.  
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

When str_replace fails, go preg_replace. Regex gives you all the control you need.
  • Dorky
  • Novice
  • Novice
  • Dorky
  • Posts: 15

Post 3+ Months Ago

well preg replace added a slash to each word and then gave an error about that same slash it added. i dont understand how it was added since the condition to replace had not been met, so why did it have any effect? i tested the condition by echoing the condition value and the slash was added before the echoing of the value for the condition.

this has a long way to go before completion so any help would be furthered by reading all the code and maybe even running it to see the output. thx for any help. like i said it will benefit all involved to have an acurate spell check added to their toolbox.
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

preg_replace doesn't add characters unless improperly used. I've used the function many times and it always results as expected. However, it would be difficult to diagnose your cause of the slashes without seeing that piece of code.

As for your current script, I don't have access to aspell lib (nor would I want to go through installation) until much later this evening, do you not have a live example somewhere that we can view?
  • Dorky
  • Novice
  • Novice
  • Dorky
  • Posts: 15

Post 3+ Months Ago

why yes, yes i do thank you so much.

http://www.studio378d.com/spell.php

also if you run it a second time without selecting a new word it will replace each word one at a time in reverse order.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Quote:
Issue :not sure why it is not including any charactures after an apostrophe.


Might be something to do with -- http://aspell.net/man-html/Words-With-S ... -Them.html
  • Dorky
  • Novice
  • Novice
  • Dorky
  • Posts: 15

Post 3+ Months Ago

well it didnt mention punctuation in words returned by pspell but it gave me the idea that i need to make exception for the apostrophe. i think at this point the apostrophe is being seen as a command so i will need to learn how to make exception for it as it runs the loop so it stops getting cut off. does that make sense? am i way off? thanks so much you guys for helping. i will stay on it. stay tuned, this will be a great freebee. oh and if you know of any place i could submit the final draft for credit. not copyright or anything as uncool as that. just credit WE could bost about. trying to get into web design. thx again for helping guys.
  • Dorky
  • Novice
  • Novice
  • Dorky
  • Posts: 15

Post 3+ Months Ago

can someone tell me why this is cutting off words with an apostrophe and why continue; is not preventing ['check'] and ['done'] from entering the loop. ??????????????

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 56 guests
  • 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 post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.