当前位置: 首页>>代码示例>>PHP>>正文


PHP pspell_new函数代码示例

本文整理汇总了PHP中pspell_new函数的典型用法代码示例。如果您正苦于以下问题:PHP pspell_new函数的具体用法?PHP pspell_new怎么用?PHP pspell_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pspell_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pspell_new

	/**
	 * Opens a link for pspell.
	 */
	function &_getPLink($lang) {
		// Check for native PSpell support
		if (!function_exists("pspell_new"))
			$this->throwError("PSpell support not found in PHP installation.");

		// Setup PSpell link
		$plink = pspell_new(
			$lang,
			$this->_config['PSpell.spelling'],
			$this->_config['PSpell.jargon'],
			empty($this->_config['PSpell.encoding']) ? 'utf-8' : $this->_config['PSpell.encoding'],
			$this->_config['PSpell.mode']
		);

		// Setup PSpell link
/*		if (!$plink) {
			$pspellConfig = pspell_config_create(
				$lang,
				$this->_config['PSpell.spelling'],
				$this->_config['PSpell.jargon'],
				$this->_config['PSpell.encoding']
			);

			$plink = pspell_new_config($pspell_config);
		}*/

		if (!$plink)
			$this->throwError("No PSpell link found opened.");

		return $plink;
	}
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:34,代码来源:PSpell.php

示例2: __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

示例3: get_pspell

 public static function get_pspell()
 {
     if (!isset(self::$_pspell_instance)) {
         self::$_pspell_instance = pspell_new('en');
     }
     return self::$_pspell_instance;
 }
开发者ID:rtoews,项目名称:meocracy,代码行数:7,代码来源:class.spellcheck.php

示例4: spellChecker

 /**
  * Constructor
  *
  * @param string $dict the dictionary (language) to use
  * @param string $account the current users account name
  */
 function spellChecker($dict, $account, $use_pspell = false)
 {
     global $atmail, $pref;
     $this->personal_words = $atmail->db->sqlarray("select Word from SpellCheck where SUnique='0' and Account=?", $account);
     $this->suggestions = array();
     // check for availability of pspell functions
     $this->use_pspell = $use_pspell && extension_loaded('pspell');
     //function_exists('pspell_new');
     // use pspell functions if they are available otherwise
     // use the aspell binary directly
     if ($this->use_pspell && function_exists('pspell_new')) {
         $this->dict = pspell_new($dict, null, null, 'utf-8', PSPELL_FAST);
     } else {
         $dict = escapeshellarg($dict);
         // Execute the aspell command and open file pointers for input/output
         $descriptorspec = array(array("pipe", "r"), array("pipe", "w"));
         $this->aspell_proc = proc_open("{$pref['aspell_path']} -a -l {$dict} --sug-mode=fast --encoding=utf-8", $descriptorspec, $pipes);
         $this->aspell_input = $pipes[0];
         $this->aspell_output = $pipes[1];
         // remove version info from stream
         $trash = fgets($this->aspell_output);
         unset($trash);
     }
     if (!$atmail->isset_chk($_SESSION['spellcheck_ignore'])) {
         $_SESSION['spellcheck_ignore'] = array();
     }
 }
开发者ID:BigBlueHat,项目名称:atmailopen,代码行数:33,代码来源:spellChecker.php

示例5: 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

示例6: getPspell

 /**
  * Returns pspell resource
  * @return int
  */
 protected function getPspell()
 {
     if ($this->pspell === null) {
         $this->pspell = pspell_new($this->language, "", "", "UTF-8");
     }
     return $this->pspell;
 }
开发者ID:unknown-opensource,项目名称:spelling-bundle,代码行数:11,代码来源:WordChecker.php

示例7: 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

示例8: spellingSuggestions

 /**
  * Suggestion of words coming from the pspell dictionnary in french and english
  *
  * @param string $q Query string
  * @param string $jsfunc The JS function to launch and pass the query string to
  */
 public function spellingSuggestions($q, $jsfunc = 'sugg')
 {
     $toret = '';
     if ($q == '') {
         return ' ... No suggestion possible, the query is empty ... ';
     }
     if (function_exists(pspell_new)) {
         $ss = 0;
         foreach (array('en' => 'English', "fr" => 'French') as $k => $v) {
             $pspellLink = pspell_new($k);
             $suggs = pspell_suggest($pspellLink, $q);
             if (count($suggs) > 0) {
                 $ss++;
                 $toret .= "<b>In " . $v . "</b> : ";
                 foreach ($suggs as $sug) {
                     $toret .= '<a href="javascript:' . $jsfunc . '(\'' . addslashes($sug) . '\')">' . htmlentities($sug) . '</a> &nbsp; ';
                 }
                 $toret .= "<br>";
             }
         }
         if ($ss == 0) {
             $toret .= '... we could not find anything in our dictionnaries ...';
         }
     } else {
         return ' !!! ERROR: the pspell module is not installed !!! ';
     }
     return $toret;
 }
开发者ID:Cryde,项目名称:sydney-core,代码行数:34,代码来源:SpellingSuggestions.php

示例9: configurePSpell

 /**
  * Set up custom PSpell dictionary.
  */
 private function configurePSpell()
 {
     $this->pspellLink = pspell_new('en');
     foreach ($this->config['spellcheck']['custom_words'] as $word) {
         pspell_add_to_session($this->pspellLink, $word);
     }
 }
开发者ID:savaslabs,项目名称:sumac,代码行数:10,代码来源:SyncCommand.php

示例10: SpellCheck

function SpellCheck($text)
{
    //depends on fnSpell()
    // Extracts text from HTML code. In addition to normal word separators,  HTML tags
    // and HTML entities also function as word delimiters
    $pspell_link = pspell_new("en_GB");
    //0. Get the dictionary
    $strings = explode(">", $text);
    //1. Split $text on '>' to give us $strings with 0 or 1 HTML tags at the end
    $nStrings = count($strings);
    for ($cStrings = 0; $cStrings < $nStrings; $cStrings++) {
        $string = $strings[$cStrings];
        //2. For each string from 1
        if ($string == '') {
            continue;
        }
        $temp = explode('<', $string);
        //2.1   Split $string from $strings on '>' to give us a $tag and $cdata
        $tag = $temp[1];
        $cdata = $temp[0];
        $subCdatas = explode(";", $cdata);
        //2.2 Split &cdata on ';' to give $subcdatas with 0 or 1 HTML entities on the end
        $nSubCdatas = count($subCdatas);
        //2.3   For each $subCdata from $subcdatas in 2.2
        for ($cSubCdatas = 0; $cSubCdatas < $nSubCdatas; $cSubCdatas++) {
            $subCdata = $subCdatas[$cSubCdatas];
            if ($subCdata == '') {
                continue;
            }
            $temp = explode('&', $subCdata);
            //2.3.1     Split the $subCdata on '&' to give us a $subCdataEntity and a $subCdataWithNoEntities
            $subCdataEntity = $temp[1];
            $subCdataWithNoEntities = $temp[0];
            $subCdataWithNoEntities = fnSpell($pspell_link, $subCdataWithNoEntities);
            //2.3.2     Spellcheck the $cdataWithNoEntities
            if (!$subCdataEntity) {
                //2.3.3        Put the $subCdataEntity, a '&' and the $cdataWithNoEntities back into the $subCdata from 2.2
                $subCdata = $subCdataWithNoEntities;
            } else {
                $subCdata = $subCdataWithNoEntities . '&' . $subCdataEntity . ';';
            }
            $subCdatas[$cSubCdatas] = $subCdata;
            //2.3.4        Put the $subCdata back into the array of $subCdatas
        }
        $cdata = implode("", $subCdatas);
        //2.4    Implode the array of $subCdatas back into the $cdata
        if ($tag) {
            //2.5    Put the $tag , '>' and $cdata back into $string
            $string = $cdata . '<' . $tag . '>';
        } else {
            $string = $cdata;
        }
        $strings[$cStrings] = $string;
        //2.6    Put $string back in its place in $strings
    }
    $text = implode('', $strings);
    //3  Implode the $strings back into $text
    return $text;
}
开发者ID:ajaypendyala,项目名称:Hospital-managment-system,代码行数:59,代码来源:spell.php

示例11: __construct

 function __construct()
 {
     if (!function_exists('pspell_new')) {
         $this->pspell_link = NULL;
     } else {
         $this->pspell_link = pspell_new($this->dict, "", "", "", PSPELL_FAST);
     }
 }
开发者ID:bufvc,项目名称:bufvc-potnia-framework,代码行数:8,代码来源:SpellingCorrector.class.php

示例12: __construct

 /**
  * Constructor
  *
  * @see     php://pspell_new
  * @param   string language
  * @param   string spelling
  * @param   string jargon
  * @param   string encoding 
  * @param   int mode 
  * @throws  lang.IllegalArgumentException
  */
 public function __construct($language, $spelling = NULL, $jargon = NULL, $encoding = NULL, $mode = PSPELL_NORMAL)
 {
     if (FALSE === ($this->handle = pspell_new($language, $spelling, $jargon, $encoding, $mode))) {
         $e = new IllegalArgumentException('Could not create spell checker');
         xp::gc(__FILE__);
         throw $e;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:19,代码来源:SpellChecker.class.php

示例13: __construct

 public function __construct($language, $input)
 {
     $this->language = $language;
     $this->rawInput = $input;
     $this->pspell = pspell_new($this->language, "", "", "utf-8");
     // Set up config
     //$this->loadReplacements();
 }
开发者ID:mauriciogsc,项目名称:ATbarPT,代码行数:8,代码来源:pspell.class.php

示例14: testPspell

function testPspell($isocode)
{
    if (function_exists('pspell_new') && @pspell_new($isocode)) {
        return 1;
    } else {
        return 0;
    }
}
开发者ID:BackupTheBerlios,项目名称:hpt-obm-svn,代码行数:8,代码来源:spellcheck.php

示例15: misspellingsOnly

 private function misspellingsOnly(array $arr)
 {
     $pspell = pspell_new("en", "", "", "", PSPELL_FAST | PSPELL_RUN_TOGETHER);
     $miss = [];
     foreach ($arr as $w) {
         if (!pspell_check($pspell, $w)) {
             $miss[] = $w;
         }
     }
     return $miss;
 }
开发者ID:fliglio,项目名称:borg,代码行数:11,代码来源:ShakespeareResource.php


注:本文中的pspell_new函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。