Source for file PSpellShell.php
Documentation is available at PSpellShell.php
* $Id: PSpellShell.php,v 1.1 2009/08/07 01:59:36 sam2kb Exp $
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
* Spellchecks an array of words.
* @param {String} $lang Language code like sv or en.
* @param {Array} $words Array of words to spellcheck.
* @return {Array} Array of misspelled words.
if ($fh =
fopen($this->_tmpfile, "w")) {
foreach($words as $key =>
$value)
fwrite($fh, "^" .
$value .
"\n");
$this->throwError("PSpell support was not found.");
$dataArr =
preg_split("/[\r\n]/", $data, -
1, PREG_SPLIT_NO_EMPTY);
foreach ($dataArr as $dstr) {
* Returns suggestions of for a specific word.
* @param {String} $lang Language code like sv or en.
* @param {String} $word Specific word to get suggestions for.
* @return {Array} Array of suggestions for the specified word.
if ($fh =
fopen($this->_tmpfile, "w")) {
$dataArr =
preg_split("/\n/", $data, -
1, PREG_SPLIT_NO_EMPTY);
foreach($dataArr as $dstr) {
if (!empty($matches[1])) {
for ($i=
0; $i<
count($words); $i++
)
$words[$i] =
trim($words[$i]);
$this->_tmpfile =
tempnam($this->_config['PSpellShell.tmp'], "tinyspell");
return $this->_config['PSpellShell.aspell'] .
" -a --lang=".
escapeshellarg($lang) .
" --encoding=utf-8 -H < " .
$this->_tmpfile .
" 2>&1";
return "cat ".
$this->_tmpfile .
" | " .
$this->_config['PSpellShell.aspell'] .
" -a --encoding=utf-8 -H --lang=".
escapeshellarg($lang);