Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Ignored Words List #8

Open
wants to merge 2 commits into from

2 participants

@ericmann

Allow users/applications to define a custom dictionary of ignored word by adding a space-delimited list to $config['general.ignored_words'] in config.php.

As an example, I've added both "WordPress" and "TinyMCE" to the list of ignored words in the configuration file since both are inaccurately flagged as misspellings. Making this a configurable option allows other users to add their own application/product/exotic names so that they aren't constantly flagged by the software.

@ericmann ericmann Add Ignore List
Allow users/applications to define a custom dictionary of ignored word by adding a space-delimited list to `$config['general.ignored_words']` in `config.php`.
ebe8e60
@nacin

Rather than array_splice(), use unset( $words[ $index ] ); This ensures the right index is always removed, regardless of how $words is indexed.

@nacin

The other issue is that $index could be 0. So you'd want to do false !== $index = array_search( $ignore, $words ).

@ericmann ericmann Use unset()
Use a faster, more reliable method for removing items from the word search array.
1a0dd47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 7, 2012
  1. @ericmann

    Add Ignore List

    ericmann authored
    Allow users/applications to define a custom dictionary of ignored word by adding a space-delimited list to `$config['general.ignored_words']` in `config.php`.
  2. @ericmann

    Use unset()

    ericmann authored
    Use a faster, more reliable method for removing items from the word search array.
This page is out of date. Refresh to see the latest.
View
5 classes/EnchantSpell.php
@@ -18,6 +18,11 @@ class EnchantSpell extends SpellChecker {
* @return Array of misspelled words.
*/
function &checkWords($lang, $words) {
+ foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
+ if ( false !== $index = array_search( $ignore, $words ) ) {
+ unset( $words[ $index ] );
+ }
+ }
$r = enchant_broker_init();
if (enchant_broker_dict_exists($r,$lang)) {
View
5 classes/GoogleSpell.php
@@ -16,6 +16,11 @@ class GoogleSpell extends SpellChecker {
* @return {Array} Array of misspelled words.
*/
function &checkWords($lang, $words) {
+ foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
+ if ( false !== $index = array_search( $ignore, $words ) ) {
+ unset( $words[ $index ] );
+ }
+ }
$wordstr = implode(' ', $words);
$matches = $this->_getMatches($lang, $wordstr);
$words = array();
View
5 classes/PSpell.php
@@ -16,6 +16,11 @@ class PSpell extends SpellChecker {
* @return {Array} Array of misspelled words.
*/
function &checkWords($lang, $words) {
+ foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
+ if ( false !== $index = array_search( $ignore, $words ) ) {
+ unset( $words[ $index ] );
+ }
+ }
$plink = $this->_getPLink($lang);
$outWords = array();
View
5 classes/PSpellShell.php
@@ -16,6 +16,11 @@ class PSpellShell extends SpellChecker {
* @return {Array} Array of misspelled words.
*/
function &checkWords($lang, $words) {
+ foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
+ if ( false !== $index = array_search( $ignore, $words ) ) {
+ unset( $words[ $index ] );
+ }
+ }
$cmd = $this->_getCMD($lang);
if ($fh = fopen($this->_tmpfile, "w")) {
View
1  config.php
@@ -9,6 +9,7 @@
//$config['general.engine'] = 'PSpell';
//$config['general.engine'] = 'PSpellShell';
//$config['general.remote_rpc_url'] = 'http://some.other.site/some/url/rpc.php';
+ $config['general.ignored_words'] = 'TinyMCE WordPress';
// PSpell settings
$config['PSpell.mode'] = PSPELL_FAST;
Something went wrong with that request. Please try again.