TypingErrors

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Goal

Correct typical typing errors in a Wiki page automatically.

I am pretty bad in synchronizing my left and right hand fingers, so are many others. Thus, a number of words would frequently be typed wrong, and it would be nice if there would be a way to automate corrections.

This is not a spell checker.

Solution

The extension implements an automatic replacement of strings (idea: typical typing errors) when a page is either saved or previewed.

Error corrections can either be defined in an array ($SpellWords), or by a Wiki page (SpellingCorrections), or both.

The array would be defined like:

        $SpellWords['worng']=>'wrong';
        $SpellWords['gloabl']=>'global';
        $SpellWords['Oracel']=>'Oracle';

To achieve the same by the Wiki page, simply add equivalences line by line. Blank lines and lines without a "=" are ignored (and can be used as comments). Example

        worng=wrong
        gloabl=global
        Oracel=Oracle

The values need not be complete words. Note that the script takes care NOT to apply the replacements to THIS page (it would be a short fun).

Discussion

The script intercepts the HandleEdit function, checks for save or preview and modifies the posted text by applying the substitutions defined in the $SpellWords array and read from the spelling correction page. Normal rendering is not touched, the correction page is not even read then.

Installation

Download the file Attach:spellcorrect.php and install it into your local/ directory. Include the script from local/config.php.

The Wiki page containing the replacements defaults to $Defaultgroup.SpellingCorrections. You may configure this by setting $SpellCorrectPagenameQQ either in config.php before including the script or in the script itself. Setting the pagename to blank (not null!) disables reading the page but keeps the feature (the $SpellWords@@ array is still effective).

Detailed instructions are contained in the script.

See Also

History

First version 2004-Sep-??. Tested and heavily used with pmwiki-1.0.11

Comments & Bugs

Since this is straight character string replacement, entries should be selected carefully.

Contributors

Copyright

Just the same as PmWiki, naturally.


pmwiki-2.5.9 -- Last modified by {{tpahl}}

from IP: 85.171.160.186 ip should be disabled by default for security reasons

Array
(
    [post_max_size] => 64M
    [$_POST keys] => 
    [$_REQUEST keys] => n
    [$_SERVER] => Array
        (
            [CONTEXT_DOCUMENT_ROOT] => /home/pmwiki/public_html
            [CONTEXT_PREFIX] => 
            [DOCUMENT_ROOT] => /home/pmwiki/public_html
            [GATEWAY_INTERFACE] => CGI/1.1
            [HTTPS] => on
            [HTTP_ACCEPT] => */*
            [HTTP_ACCEPT_ENCODING] => gzip, br, zstd, deflate
            [HTTP_COOKIE] => imstime=1777493278; PHPSESSID=0usmde1psu0n7ncblqiramhfk3
            [HTTP_HOST] => www.pmwiki.org
            [HTTP_USER_AGENT] => Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
            [HTTP_X_HTTPS] => 1
            [PATH] => /bin:/usr/bin
            [PHP_INI_SCAN_DIR] => /opt/cpanel/ea-php70/root/etc:/opt/cpanel/ea-php70/root/etc/php.d:.
            [QUERY_STRING] => n=Cookbook%2dV1%2fTypingErrors
            [REDIRECT_HTTPS] => on
            [REDIRECT_QUERY_STRING] => n=Cookbook%2dV1%2fTypingErrors
            [REDIRECT_SCRIPT_URI] => https://www.pmwiki.org/wiki/Cookbook-V1/TypingErrors
            [REDIRECT_SCRIPT_URL] => /wiki/Cookbook-V1/TypingErrors
            [REDIRECT_SSL_TLS_SNI] => www.pmwiki.org
            [REDIRECT_STATUS] => 200
            [REDIRECT_UNIQUE_ID] => afJlMYrAP7sqnaJdWN_ZBQAAAI0
            [REDIRECT_URL] => /wiki/Cookbook-V1/TypingErrors
            [REMOTE_ADDR] => 216.73.216.31
            [REMOTE_PORT] => 55565
            [REQUEST_METHOD] => GET
            [REQUEST_SCHEME] => https
            [REQUEST_URI] => /wiki/Cookbook-V1/TypingErrors
            [SCRIPT_FILENAME] => /home/pmwiki/public_html/index.php
            [SCRIPT_NAME] => /index.php
            [SCRIPT_URI] => https://www.pmwiki.org/wiki/Cookbook-V1/TypingErrors
            [SCRIPT_URL] => /wiki/Cookbook-V1/TypingErrors
            [SERVER_ADDR] => 23.254.203.248
            [SERVER_ADMIN] => webmaster@pmwiki.org
            [SERVER_NAME] => www.pmwiki.org
            [SERVER_PORT] => 443
            [SERVER_PROTOCOL] => HTTP/1.1
            [SERVER_SIGNATURE] => 
            [SERVER_SOFTWARE] => Apache
            [SSL_TLS_SNI] => www.pmwiki.org
            [TZ] => America/Los_Angeles
            [UNIQUE_ID] => afJlMYrAP7sqnaJdWN_ZBQAAAI0
            [PHP_SELF] => /index.php
            [REQUEST_TIME_FLOAT] => 1777493297.9006
            [REQUEST_TIME] => 1777493297
            [argv] => Array
                (
                    [0] => n=Cookbook%2dV1%2fTypingErrors
                )

            [argc] => 1
        )

)