本文整理汇总了PHP中pspell_check函数的典型用法代码示例。如果您正苦于以下问题:PHP pspell_check函数的具体用法?PHP pspell_check怎么用?PHP pspell_check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pspell_check函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: check
function check($word)
{
//pspell
if ($this->pspell) {
if ($this->lang == 'ru') {
$word = convertCharsetInKOI8($word);
}
return pspell_check($this->pspell_link, $word);
//custom
} elseif ($this->custom_spell) {
if ($this->lang == 'ru') {
$word = convertCharsetInWIN1251($word);
}
if (strlen($word) <= $this->skip_len) {
return true;
}
$first_let = $this->codeLetter(string_lower($word[0]));
if (!isset($this->dic[$first_let])) {
$this->loadDic($first_let);
}
//check if word exist in array
if (isset($this->dic[$first_let][string_lower($word)])) {
return true;
}
return false;
}
}
开发者ID:k-kalashnikov,项目名称:geekcon.local,代码行数:27,代码来源:fileman_spellChecker.php
示例2: obtainData
function obtainData($objDb, $id)
{
$aRes = $objDb->GetDetails($id);
$sText = $objDb->GetRawText($id);
if ($aRes === FALSE || $sText === FALSE) {
// No such record!
return FALSE;
}
// Clean up list of words
$aWords = array_filter(array_unique(str_word_count($sText, 1)), "filter_words");
// Split words into likely and unlikely (based on spelling)
$aLikely = array();
$aUnlikely = array();
$hSpell = pspell_new("en");
if ($hSpell !== FALSE) {
foreach ($aWords as $sWord) {
// Make a spellcheck on it
if (pspell_check($hSpell, $sWord)) {
array_push($aLikely, $sWord);
} else {
array_push($aUnlikely, $sWord);
}
}
} else {
$aLikely = $aWords;
}
return array("likely" => $aLikely, "unlikely" => $aUnlikely);
}
开发者ID:neerumsr,项目名称:lagerdox,代码行数:28,代码来源:create_category.php
示例3: check
/**
* Check a word for spelling errors, add to $this->miss_spelled_words
* array if miss spelled
*
* @param string $word
* @return void
*/
function check($word)
{
global $atmail;
$word = preg_replace('/[^a-zA-Z\\-]/', '', $word);
// if the word is in the personal_words array
// or the ignore list then it is OK. If it is already
// in the $suggestions array then ignore it
if (in_array($word, $this->personal_words) || $atmail->isset_chk($this->suggestions[$word]) || in_array($word, $_SESSION['spellcheck_ignore'])) {
return;
}
// if word is OK ignore it
if ($this->use_pspell) {
if (pspell_check($this->dict, $word)) {
return;
}
$this->suggestions[$word] = pspell_suggest($this->dict, $word);
} else {
fwrite($this->aspell_input, "{$word}\n");
$result = fgets($this->aspell_output);
// remove trash from stream
$trash = fgets($this->aspell_output);
unset($trash);
if (preg_match('/.+?\\d:(.+)/', $result, $m)) {
$this->suggestions[$word] = explode(', ', $m[1]);
} else {
return;
}
}
}
开发者ID:BigBlueHat,项目名称:atmailopen,代码行数:36,代码来源:spellChecker.php
示例4: __invoke
/**
* Checks spelling.
*
* @since 150424 Adding password strength.
*
* @param string $word Input word to check.
* @param int $flags Dictionary flags.
*
* @return bool True if spelled correctly.
*/
public function __invoke(string $word, int $flags = PSPELL_NORMAL) : bool
{
if (is_null($dictionary =& $this->cacheKey(__FUNCTION__, $flags))) {
$dictionary = pspell_new('en', '', '', 'utf-8', $flags);
}
return pspell_check($dictionary, $word);
}
开发者ID:websharks,项目名称:core,代码行数:17,代码来源:SpellCheck.php
示例5: spellCheckWord
function spellCheckWord($word)
{
global $pspell, $bad;
$autocorrect = TRUE;
$ignore_words = array("wikihows", "blog", "online", "ipod", "nano");
// Take the string match from preg_replace_callback's array
$word = $word[0];
// Ignore ALL CAPS, and numbers
if (preg_match('/^[A-Z]*$/', $word)) {
return;
}
if (preg_match('/^[0-9]*$/', $word)) {
return;
}
if (in_array(strtolower($word), $ignore_words)) {
return;
}
// Return dictionary words
if (pspell_check($pspell, $word)) {
// this word is OK
return;
}
echo "Bad word {$word} - ";
$bad++;
$suggestions = pspell_suggest($pspell, $word);
if (sizeof($suggestions) > 0) {
if (sizeof($suggestions) > 5) {
echo implode(",", array_splice($suggestions, 0, 5)) . "\n";
} else {
echo implode(",", $suggestions) . "\n";
}
} else {
echo "no suggestions\n";
}
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:35,代码来源:aspell_demo.php
示例6: getSuggestions
/**
* Spellchecks an array of words.
*
* @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
* @param Array $words Array of words to check.
* @return Name/value object with arrays of suggestions.
*/
public function getSuggestions($lang, $words)
{
$config = $this->getConfig();
switch ($config['PSpell.mode']) {
case "fast":
$mode = PSPELL_FAST;
break;
case "slow":
$mode = PSPELL_SLOW;
break;
default:
$mode = PSPELL_NORMAL;
}
// Setup PSpell link
$plink = pspell_new($lang, $config['pspell.spelling'], $config['pspell.jargon'], $config['pspell.encoding'], $mode);
if (!$plink) {
throw new Exception("No PSpell link found opened.");
}
$outWords = array();
foreach ($words as $word) {
if (!pspell_check($plink, trim($word))) {
$outWords[] = utf8_encode($word);
}
}
return $outWords;
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:33,代码来源:PSpellEngine.php
示例7: check
function check($word)
{
$word = trim($word);
$ret = pspell_check($this->resid, $word);
$this->lastword = $word;
return $ret;
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:7,代码来源:pspell.class.php
示例8: pspell
private function pspell()
{
foreach ($_REQUEST as $key => $value) {
${$key} = html_entity_decode(urldecode(stripslashes(trim($value))));
}
// load the dictionary
$pspell_link = pspell_new_personal($this->pspell_personal_dictionary, $this->lang);
// return suggestions
if (isset($suggest)) {
exit(json_encode(pspell_suggest($pspell_link, urldecode($suggest))));
} elseif (isset($text)) {
$words = array();
foreach ($text = explode(' ', urldecode($text)) as $word) {
if (!pspell_check($pspell_link, $word) and !in_array($word, $words)) {
$words[] = $word;
}
}
exit(json_encode($words));
} elseif (isset($addtodictionary)) {
$pspell_config = pspell_config_create('en');
@pspell_config_personal($pspell_config, $this->pspell_personal_dictionary) or die('can\'t find pspell dictionary');
$pspell_link = pspell_new_config($pspell_config);
@pspell_add_to_personal($pspell_link, strtolower($addtodictionary)) or die('You can\'t add a word to the dictionary that contains any punctuation.');
pspell_save_wordlist($pspell_link);
exit(array());
}
}
开发者ID:muratozden,项目名称:jquery-spellchecker,代码行数:27,代码来源:checkspelling.php
示例9: checkWord
public function checkWord($word)
{
//pspell
if ($this->pspell) {
return pspell_check($this->pspell_link, $word);
}
//custom
// elseif($this->custom_spell)
// {
// if ($this->lang == 'ru')
// {
// $word = $APPLICATION->ConvertCharset($word, "UTF-8", "Windows-1251");
// }
//
// if (strlen($word) <= $this->skip_len)
// {
// return true;
// }
//
// $first_let = $this->codeLetter(strtolower($word{0}));
//
// if (!isset($this->dic[$first_let]))
// {
// $this->loadDic($first_let);
// }
// //check if word exist in array
// if (isset($this->dic[$first_let][strtolower($word)]))
// {
// return true;
// }
// return false;
// }
}
开发者ID:rasuldev,项目名称:torino,代码行数:33,代码来源:spellchecker.php
示例10: suggest
/**
* Use pspell to get word suggestions
* @param string $word
* @return array
*/
public function suggest($word)
{
if (!pspell_check($this->pSpell, $word)) {
return pspell_suggest($this->pSpell, $word);
} else {
return [$word];
}
}
开发者ID:WHATNEXTLIMITED,项目名称:php-text-analysis,代码行数:13,代码来源:PspellAdapter.php
示例11: valid
/**
* Validates word first in cache then in pspell
* @param string $word
* @return boolean
*/
public function valid($word)
{
$wordLower = mb_strtolower($word, 'UTF-8');
$this->parseCache();
if (!isset($this->words[$wordLower])) {
$this->words[$wordLower] = pspell_check($this->getPspell(), $word);
}
return $this->words[$wordLower];
}
开发者ID:unknown-opensource,项目名称:spelling-bundle,代码行数:14,代码来源:WordChecker.php
示例12: check
/**
* Checks a word against the dictionary.
*
* @param boolean Returns true if word is in dictionary, false if not.
*/
public function check($word) {
$this->word = $word;
if ($this->handle !== false && pspell_check($this->handle, $word) == true) {
return true;
}
else {
return false;
}
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:14,代码来源:class.Spellcheck.php
示例13: array
/**
* 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.
*/
function &checkWords($lang, $words)
{
$plink = $this->_getPLink($lang);
$outWords = array();
foreach ($words as $word) {
if (!pspell_check($plink, trim($word))) {
$outWords[] = utf8_encode($word);
}
}
return $outWords;
}
开发者ID:grff-alpha,项目名称:grff-alpha-web,代码行数:18,代码来源:PSpell.php
示例14: check
function check($data)
{
$recognized = array();
if (is_string($data)) {
$data = array($data);
}
foreach ($data as $word) {
if (pspell_check($this->_ps, $word)) {
$recognized[] = $word;
}
}
return $recognized;
}
开发者ID:rtoews,项目名称:meocracy,代码行数:13,代码来源:class.spellcheck.php
示例15: ewiki_spellcheck_list
function ewiki_spellcheck_list($ws)
{
global $spell_bin, $pspell_h;
#-- every word once only
$words = array();
foreach (array_unique($ws) as $word) {
if (!empty($word)) {
$words[] = $word;
}
}
#print_r($words);
#-- PHP internal pspell
if ($pspell_h) {
#-- build ispell like check list
$results = array();
foreach ($words as $w) {
if (pspell_check($pspell_h, $w)) {
$results[$word] = "*";
} else {
$results[$word] = "& " . implode(", ", pspell_suggest($pspell_h, $w));
}
}
} elseif ($spell_bin) {
#-- pipe word list through ispell
$r = implode(" ", $words);
$results = explode("\n", $r = `echo {$r} | {$spell_bin}`);
$results = array_slice($results, 1);
}
#print_r($results);
#-- build replacement html hash from results
$r = array();
foreach ($words as $n => $word) {
if ($repl = $results[$n]) {
switch ($repl[0]) {
case "-":
case "+":
case "*":
$repl = $word;
break;
default:
$repl = '<s title="' . htmlentities($repl) . '" style="color:#ff5555;" class="wrong">' . $word . '</s>';
}
} else {
$repl = $word;
}
$r[$word] = $repl;
}
#print_r($r);
return $r;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:50,代码来源:pspell.php
示例16: checkWords
function checkWords($wordArray)
{
if (!$this->plink) {
$this->errorMsg[] = "No PSpell link found for checkWords.";
return array();
}
$wordError = array();
foreach ($wordArray as $word) {
if (!pspell_check($this->plink, trim($word))) {
$wordError[] = $word;
}
}
return $wordError;
}
开发者ID:aydancoskun,项目名称:octobercms,代码行数:14,代码来源:TinyPspell.class.php
示例17: get_incorrect_words
public function get_incorrect_words()
{
$texts = (array) $_POST['text'];
$response = array();
foreach ($texts as $text) {
$words = explode(' ', $text);
$incorrect_words = array();
foreach ($words as $word) {
if (!pspell_check($this->pspell_link, $word)) {
$incorrect_words[] = $word;
}
}
$response[] = $incorrect_words;
}
$this->send_data('success', $response);
}
开发者ID:ThemeHouse-XF,项目名称:SpellCheckerb,代码行数:16,代码来源:PSpell.php
示例18: getCorrections
public function getCorrections()
{
$wordMatcher = "/\\w+/u";
preg_match_all($wordMatcher, $this->rawInput, $words);
if (count($words[0]) == 0) {
return array();
}
foreach ($words[0] as $k => $word) {
if (!pspell_check($this->pspell, $word)) {
$suggestions = pspell_suggest($this->pspell, $word);
$this->corrections[$word]['offset'] = $k;
$this->corrections[$word]['suggestions'] = $suggestions;
}
}
return $this->corrections;
}
开发者ID:mauriciogsc,项目名称:ATbarPT,代码行数:16,代码来源:pspell.class.php
示例19: check
function check($word)
{
$pspell_config = pspell_config_create("ru", "", "", "UTF-8");
pspell_config_mode($pspell_config, PSPELL_FAST);
$pspell_link = pspell_new_config($pspell_config);
if (!pspell_check($pspell_link, $word)) {
$arr = array();
$suggestions = pspell_suggest($pspell_link, $word);
foreach ($suggestions as $suggestion) {
array_push($arr, $suggestion);
}
$json = json_encode($arr);
} else {
$json = true;
}
echo $json;
}
开发者ID:m304so,项目名称:spellchecker,代码行数:17,代码来源:spellchecker.php
示例20: check_data
function check_data($xml, $data)
{
global $element, $dict, $check_tags, $current_file, $word_count;
if (!in_array($element, $check_tags)) {
return;
}
if (trim($data) == '') {
return;
}
$words = preg_split('/\\W+/', trim($data));
if (is_array($words)) {
foreach ($words as $word) {
if (trim($word) == '' || is_numeric($word) || preg_match('/[^a-z]/', $word)) {
continue;
}
$word_count++;
$word = strtolower($word);
if (!pspell_check($dict, $word)) {
/* known bug: due to trim()ing and whitespace removal, the
* line number shown here might not match the actual line
* number in the file, but it's usually pretty close
*/
$note = "{$current_file}:" . xml_get_current_line_number($xml) . ": {$word} (in element {$element})\n";
echo $note;
echo "================\nContext:\n{$data}\n================\n";
do {
$response = read_line("Add this word to personal wordlist? (yes/no/save/later): ");
if ($response[0] == 's') {
pspell_save_wordlist($dict);
echo "Wordlist saved.\n";
}
} while ($response[0] != 'y' && $response[0] != 'n' && $response[0] != 'l');
if ($response[0] == 'y') {
pspell_add_to_personal($dict, $word);
echo "Added '{$word}' to personal wordlist.\n";
}
if ($response[0] == 'l') {
file_put_contents('/tmp/fix-me-later.txt', $note, FILE_APPEND);
echo "You will deal with '{$word}' later.\n";
}
}
}
}
return;
}
开发者ID:guoyu07,项目名称:NYAF,代码行数:45,代码来源:spell-checker.php
注:本文中的pspell_check函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论