PHP Classes

PHP Spell Checker: Check spelling of text and get fix suggestions

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 63%Total: 1,690 This week: 2All time: 2,328 This week: 84Up
Version License PHP version Categories
phpspellchecker 1.1GNU Lesser Genera...5.0PHP 5, Text processing
Description 

Author

This package can be used to check the spelling of text and get fix suggestions.

There is a base class that defines functions for spell checking.

There are also two classes for checking the spelling of text using either PHP scripts that contain arrays of valid words and grammar definitions, or using the hunspell program.

If the classes determine that there are misspelled words, they may return suggestions for eventual fixes.

Picture of Protung Dragos
Name: Protung Dragos is available for providing paid consulting. Contact Protung Dragos .
Classes: 10 packages by
Country: Romania Romania
Age: 40
All time rank: 281 in Romania Romania
Week rank: 50 Down1 in Romania Romania Equal
Innovation award
Innovation award
Nominee: 3x

Details

___________________________________________________________ PHP Spell Checker & Spell Suggestion - Version 1.1 February 2010 ___________________________________________________________ Copyright (c) 2010 Dragos Protung _______________________ CONTENTS _______________________ 1. Description 2. System Requirements 3. How to use 4. Contact _______________________ 1. Product Description _______________________ This class can be used to check the spelling of texts and also provide suggestions in case some words are spelled wrong. _______________________ 2. System Requirements _______________________ PHP 5.x - required hunspell - optional: if you don't have it then you can use the pure PHP based version or Google 'Did you mean' version ______________ 3. How to use ______________ 3.1 - Installation this class uses affix dictionaries. This means that you can use the dictionaries from OpenOffice or Mozilla products. Just go to https://addons.mozilla.org/en-US/firefox/browse/type:3 and download the dictionaries that you want. Unpack the *.xpi files and extract the *.aff and *.dic files into dictionaries/hunspell/ folder. This class also works with MySpell dictionaries. There is nothing more you have to do, just start using the class. Please read further and then take a look at the examples. 3.2 - HunSpell version The hunspell version of this class is preferred. It uses less memory for complex languages or with a very big dictionary (over 150.000 words) and the word suggestion is excellent. You can get the binaries from http://sourceforge.net/projects/hunspell/files/Hunspell/1.2.8/ When using this version of the class you need to specify where hunspell is installed by calling the setHunspellPath() method or add hunspell to the system path. 3.3 - PHP version In case you can not install hunspell on your server you can use a pure PHP version. The words suggestions is not as good as the HunSpell version (will implement a new algorithm soon). Also the PHP version can use a lot of memory for complex languages or with a very big dictionary (over 150.000 words). As an example, for German languages the script can use over 100Mb. On the other hand for simple languages it only uses about 10Mb. The affix dictionaries can not be used as it is. They need to be converted to PHP code. This can be done manuall by calling the compileHunAffixDictionary() method. If the dictionary is not compiled yet, the first time you use it it will try to compile it from hunspell. For complex languages this file can be over 15Mb. 3.4 - Google 'Did you mean' You can use this version to use google's 'Did you mean' function The class sends a query to google website and checks for any misspelled words. 3.5 - Known bugs, accuracy and performance concerns There are several known bugs: - initially if a word has the suffix doubled (misspell) the spell checker reports it as a correct word. (pure PHP version only) There is a fix implmented that will rezolve the issue but if a word is correctly spelled with the doubled sufix it will be reported ar wrong. You can remove the fix by commenting the 93-95 lines in PHPSpellChecker.class.php - in some languages there is a need for a special encoding and this is not yet supported (will be soon) Accuracy: (pure PHP version) - Word suggestion is not very smart. It's just a simple "algorithm". I plan on improveing this (maybe you can help out) Performance: - For very complex languages, or with a very big dictionary (over 150.000 words) (pure PHP version only) the script can use alot of memmory (100Mb) 3.6 - Conclusion The PHP version can be used very efficient for simple languages or with small dictionary (ex. english) This is just the first release and it will be greatlly improved. If you use Google 'Did you mean' you might get banned by Google for using this service. If you want to participate on this project please contact me. ______________ 4. Contact ______________ Please send your suggestions, bug reports and general feedback to dragos@protung.ro Also visit http://www.protung.ro Out for now ;)

Screenshots  
  • phpspellchecker.jpg
  Files folder image Files  
File Role Description
Files folder imagedictionaries (3 directories)
Files folder imageexamples (4 files)
Plain text file GDYMSpellChecker.class.php Class Check spelling using Google 'Did you mean' version
Plain text file HunSpellChecker.class.php Class Check spelling using HunSpell
Accessible without login Plain text file license.txt Lic. License
Plain text file PHPSpellChecker.class.php Class Check spelling in pure PHP
Accessible without login Plain text file readme.txt Doc. Read me text
Plain text file SpellChecker.class.php Class Abstract spell checker class

  Files folder image Files  /  dictionaries  
File Role Description
Files folder imagecustom (1 file)
Files folder imagehunspell (1 file)
Files folder imagephp (1 file)

  Files folder image Files  /  dictionaries  /  custom  
File Role Description
  Accessible without login Plain text file en-US.php Aux. Custom dictionary for en-US

  Files folder image Files  /  dictionaries  /  hunspell  
File Role Description
  Accessible without login Plain text file empty.txt Data Dummy file

  Files folder image Files  /  dictionaries  /  php  
File Role Description
  Accessible without login Plain text file empty.txt Data Dummy file

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file gdymBased.php Example Example script for google 'Did you mean' version
  Accessible without login Plain text file hunspellBased.php Example Example script for HunSpell version
  Accessible without login Plain text file interactiveForm.php Example Example script with interface
  Accessible without login Plain text file phpBased.php Example Example script for pure PHP version

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,690
This week:2
All time:2,328
This week:84Up
 User Ratings  
 
 All time
Utility:81%StarStarStarStarStar
Consistency:87%StarStarStarStarStar
Documentation:81%StarStarStarStarStar
Examples:56%StarStarStar
Tests:-
Videos:-
Overall:63%StarStarStarStar
Rank:848