PHP Classes

No pspell

Recommend this page to a friend!

      Word Solver  >  All threads  >  No pspell  >  (Un) Subscribe thread alerts  
Subject:No pspell
Summary:Using .txt dictionaries
Messages:13
Author:Beldar
Date:2012-03-16 17:16:19
Update:2012-05-16 16:32:34
 
  1 - 10   11 - 13  

  11. Re: No pspell   Reply   Report abuse  
Picture of Patrick Patrick - 2012-05-14 19:19:39 - In reply to message 10 from Arturs Sosins
It works!
Thank you so much for fixing this for me. You're the best!

  12. Re: No pspell   Reply   Report abuse  
Picture of Patrick Patrick - 2012-05-14 23:14:25 - In reply to message 11 from Patrick
Hey Arturs,

Again, the script is working beautifully. On some searches, however, it is rather slow, taking up to a minute to return results.
In an effort to speed it up, I'd like to have the user enter the number of letters the word they are searching for is - this way, if the they enter 5 letters, I only have to create possible words of 5 letters and compare them against words in my dictionary of 5 words.

I don't expect you to create the script for me, but if you could give me a pointer on how this might be implemented, I'd really appreciate it.

Also, if you have a Paypal donation system set up I'd be happy to donate a bit for your time and help. I don't expect you to help for free ;)

Hope to hear from you.

Thank you!

  13. Re: No pspell   Reply   Report abuse  
Picture of Arturs Sosins Arturs Sosins - 2012-05-16 16:32:34 - In reply to message 12 from Patrick
Yes, I know generating string could be quite slow, although I've optimized it as much as I could.

I don't think that dividing dictionaries (in your example to 3, 4 or 5 word letters) will speed it up, because the generation process is self is what most time consuming, not checking it in dictionary.

What could improve the performance is another method that class have, but I haven't override it in custom example, because I wanted to make it simple.

This method is called dictionary_test, basically word_solver passes strings, which are in generating process to this function, and if this function returns true, it means, there is a string which starts with provided substring, if it return false, it means, there is no string which starts with this substring and word_solver discards it and tries to generate other string.

It speeds up the process, because it drops generating strings if it sees, that there can't be any word starting with it. For example if there are no words in dictionary, that starts with "x", then once word_solver tries "x" and gets false, no more strings starting with "x" will be generated, which drops out large quantity of possibilities and increases performance.

So what you can try to do, is to override dictionary_test method inside custom_word_solver.php file and implement some kind of logic, which would determine if there is any word starting with provided string, something like this:

protected function dictionary_test($string){
$ret = false;
if(checking_if_word_can_start_with($string))
{
$ret = true;
}
return $ret;
}

I can't come up with efficient way to check if word starts with string right now, but most easy way would be to iterate through all words and check if(strpos($word, $string) === 0), but again with a lot of word in dictionary it would become inefficient to do it like this.

This is where you may want to try to separate dictionaries by first letter, or combining by first, second and maybe even third letters in word.

For this case Trie structure should be most efficient.
en.wikipedia.org/wiki/Trie

I've found one implementation for PHP, but haven't tried it:
code.google.com/p/phptrie/

 
  1 - 10   11 - 13