Файловый менеджер - Редактировать - /var/www/iplanru/data/www/intesco.ru/d59ed/common.php.tar
Назад
usr/share/xcache/htdocs/common/common.php 0000666 00000014325 15077704102 0014503 0 ustar 00 <?php class Cycle { var $values; var $i; var $count; function Cycle($v) { $this->values = func_get_args(); $this->i = -1; $this->count = count($this->values); } function next() { $this->i = ($this->i + 1) % $this->count; return $this->values[$this->i]; } function cur() { return $this->values[$this->i]; } function reset() { $this->i = -1; } } function switcher($name, $options) { $n = isset($_GET[$name]) ? $_GET[$name] : null; $html = array(); foreach ($options as $k => $v) { $html[] = sprintf('<a href="?%s=%s"%s>%s</a>', $name, $k, $k == $n ? ' class="active"' : '', $v); } return implode('', $html); } function mainnav() { foreach (array( "http://xcache.lighttpd.net/" => "XCache", "http://xcache.lighttpd.net/wiki/DocTOC" => _T("Document"), "http://xcache.lighttpd.net/wiki/PhpIni" => _T("INI Reference"), "http://xcache.lighttpd.net/wiki/GetSupport" => _T("Get Support"), "https://groups.google.com/group/xcache/" => _T("Discusson"), "http://www.php.net/" => "PHP", "http://www.lighttpd.net/" => "Lighttpd", ) as $url => $title) { $html[] = sprintf('<a href="%s" rel="external">%s</a>', $url, $title); } return implode('|', $html); } function subnav() { global $module, $modules; $html = array(); foreach ($modules as $k => $v) { $html[] = sprintf('<a href="../%s/"%s>%s</a>', $k, $k == $module ? ' class="active"' : '', $v); } return implode('', $html); } function th($name, $attrs = null) { $translated = __($name); if ($translated == $name) { $translated = "$name|$name"; } list($text, $title) = explode('|', $translated, 2); return sprintf('%s<th%s id="%s" class="h" title="%s"><a href="javascript:" onclick="resort(this); return false">%s</a></th>%s' , "\t" , $attrs ? " $attrs" : "" , $name, htmlspecialchars(trim($title)), trim($text) , "\n"); } function xcache_validateFileName($name) { return preg_match('!^[a-zA-Z0-9._-]+$!', $name); } function get_language_file_ex($dir, $lang) { static $langMap = array( 'zh' => 'zh-simplified', 'zh-hk' => 'zh-traditional', 'zh-tw' => 'zh-traditional', ); if (isset($langMap[$lang])) { $lang = $langMap[$lang]; } else if (!xcache_validateFileName($lang)) { return null; } $file = "$dir/$lang.php"; if (file_exists($file)) { return $file; } return null; } function get_language_file($dir) { global $config; if (!empty($config['lang'])) { $lang = strtolower($config['lang']); $file = get_language_file_ex($dir, $lang); if (!isset($file)) { $lang = strtok($lang, ':-'); $file = get_language_file_ex($dir, $lang); } } else { $config['lang'] = 'en'; if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $lang) { $lang = strtok($lang, ':;'); $file = get_language_file_ex($dir, $lang); if (isset($file)) { $config['lang'] = $lang; break; } if (strpos($lang, '-') !== false) { $file = get_language_file_ex($dir, strtok($lang, ':-')); if (isset($file)) { $config['lang'] = $lang; break; } } } } } return isset($file) ? $file : "$dir/en.php"; } function _T($str) { if (isset($GLOBALS['strings'][$str])) { return $GLOBALS['strings'][$str]; } if (!empty($GLOBALS['config']['show_todo_strings'])) { return '<span style="color:red">' . $str . '</span>|'; } return $str; } function __($str) { return _T($str); } function N_($str) { return $str; } function number_formats($a, $keys) { foreach ($keys as $k) { $a[$k] = number_format($a[$k]); } return $a; } function size($size) { $size = (int) $size; if ($size < 1024) return number_format($size, 2) . ' b'; if ($size < 1048576) return number_format($size / 1024, 2) . ' K'; return number_format($size / 1048576, 2) . ' M'; } function age($time) { if (!$time) return ''; $delta = REQUEST_TIME - $time; if ($delta < 0) { $delta = -$delta; } static $seconds = array(1, 60, 3600, 86400, 604800, 2678400, 31536000); static $name = array('s', 'm', 'h', 'd', 'w', 'M', 'Y'); for ($i = 6; $i >= 0; $i --) { if ($delta >= $seconds[$i]) { $ret = (int) ($delta / $seconds[$i]); return $ret . $name[$i]; } } return '0s'; } function stripaddslashes_array($value, $mqs = false) { if (is_array($value)) { foreach($value as $k => $v) { $value[$k] = stripaddslashes_array($v, $mqs); } } else if(is_string($value)) { $value = $mqs ? str_replace('\'\'', '\'', $value) : stripslashes($value); } return $value; } function ob_filter_path_nicer_default($list_html) { $sep = DIRECTORY_SEPARATOR; $docRoot = $_SERVER['DOCUMENT_ROOT']; if ($sep != '/') { $docRoot = str_replace('/', $sep, $docRoot); } $list_html = str_replace(">$docRoot", ">{DOCROOT}" . (substr($docRoot, -1) == $sep ? $sep : ""), $list_html); $xcachedir = realpath(dirname(__FILE__) . "$sep..$sep"); $list_html = str_replace(">$xcachedir$sep", ">{XCache}$sep", $list_html); if ($sep == '/') { $list_html = str_replace(">/home/", ">{H}/", $list_html); } return $list_html; } error_reporting(E_ALL); ini_set('display_errors', 'On'); define('REQUEST_TIME', time()); if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) { $mqs = (bool) ini_get('magic_quotes_sybase'); $_GET = stripaddslashes_array($_GET, $mqs); $_POST = stripaddslashes_array($_POST, $mqs); $_REQUEST = stripaddslashes_array($_REQUEST, $mqs); unset($mqs); } ini_set('magic_quotes_runtime', '0'); $config = array(); if (file_exists("./config.default.php")) { include "./config.default.php"; } include "../config.default.php"; if (file_exists("../config.php")) { include "../config.php"; } if (file_exists("./config.php")) { include "./config.php"; } $strings = array(); include get_language_file("../common/lang"); $modules = array(); if (file_exists("../cacher/index.php")) { $modules["cacher"] = _T("Cacher"); } if (file_exists("../coverager/index.php")) { $modules["coverager"] = _T("Coverager"); } if (file_exists("../diagnosis/index.php")) { $modules["diagnosis"] = _T("Diagnosis"); } header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); header("Content-Type: text/html; " . $GLOBALS['config']['charset']); header("Content-Language: " . $GLOBALS['config']['lang']); ?> var/www/iplanru/data/www/i-plan.ru/libraries/phpmorphy/src/common.php 0000666 00000065426 15100142467 0022007 0 ustar 00 <?php /** * This file is part of phpMorphy library * * Copyright c 2007-2008 Kamaev Vladimir <heromantor@users.sourceforge.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ if(!defined('PHPMORPHY_DIR')) { define('PHPMORPHY_DIR', dirname(__FILE__)); } require_once(PHPMORPHY_DIR . '/fsa/fsa.php'); require_once(PHPMORPHY_DIR . '/graminfo/graminfo.php'); require_once(PHPMORPHY_DIR . '/morphiers.php'); require_once(PHPMORPHY_DIR . '/gramtab.php'); require_once(PHPMORPHY_DIR . '/storage.php'); require_once(PHPMORPHY_DIR . '/source.php'); require_once(PHPMORPHY_DIR . '/langs_stuff/common.php'); class phpMorphy_Exception extends Exception { } // we need byte oriented string functions // with namespaces support we only need overload string functions in current namespace // but currently use this ugly hack. function phpmorphy_overload_mb_funcs($prefix) { $GLOBALS['__phpmorphy_strlen'] = "{$prefix}strlen"; $GLOBALS['__phpmorphy_strpos'] = "{$prefix}strpos"; $GLOBALS['__phpmorphy_strrpos'] = "{$prefix}strrpos"; $GLOBALS['__phpmorphy_substr'] = "{$prefix}substr"; $GLOBALS['__phpmorphy_strtolower'] = "{$prefix}strtolower"; $GLOBALS['__phpmorphy_strtoupper'] = "{$prefix}strtoupper"; $GLOBALS['__phpmorphy_substr_count'] = "{$prefix}substr_count"; } if(2 == (ini_get('mbstring.func_overload') & 2)) { phpmorphy_overload_mb_funcs('mb_orig_'); } else { phpmorphy_overload_mb_funcs(''); } class phpMorphy_FilesBundle { protected $dir, $lang; function phpMorphy_FilesBundle($dirName, $lang) { $this->dir = rtrim($dirName, "\\/" . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $this->setLang($lang); } function getLang() { return $this->lang; } function setLang($lang) { $this->lang = $GLOBALS['__phpmorphy_strtolower']($lang); } function getCommonAutomatFile() { return $this->genFileName('common_aut'); } function getPredictAutomatFile() { return $this->genFileName('predict_aut'); } function getGramInfoFile() { return $this->genFileName('morph_data'); } function getGramInfoAncodesCacheFile() { return $this->genFileName('morph_data_ancodes_cache'); } function getAncodesMapFile() { return $this->genFileName('morph_data_ancodes_map'); } function getGramTabFile() { return $this->genFileName('gramtab'); } function getGramTabFileWithTextIds() { return $this->genFileName('gramtab_txt'); } function getDbaFile($type) { if(!isset($type)) { $type = 'db3'; } return $this->genFileName("common_dict_$type"); } function getGramInfoHeaderCacheFile() { return $this->genFileName('morph_data_header_cache'); } protected function genFileName($token, $extraExt = null) { return $this->dir . $token . '.' . $this->lang . (isset($extraExt) ? '.' . $extraExt : '') . '.bin'; } }; class phpMorphy_WordDescriptor_Collection_Serializer { function serialize(phpMorphy_WordDescriptor_Collection $collection, $asText) { $result = array(); foreach($collection as $descriptor) { $result[] = $this->processWordDescriptor($descriptor, $asText); } return $result; } protected function processWordDescriptor(phpMorphy_WordDescriptor $descriptor, $asText) { $forms = array(); $all = array(); foreach($descriptor as $word_form) { $forms[] = $word_form->getWord(); $all[] = $this->serializeGramInfo($word_form, $asText); } return array( 'forms' => $forms, 'all' => $all, 'common' => '', ); } protected function serializeGramInfo(phpMorphy_WordForm $wordForm, $asText) { if($asText) { return $wordForm->getPartOfSpeech() . ' ' . implode(',', $wordForm->getGrammems()); } else { return array( 'pos' => $wordForm->getPartOfSpeech(), 'grammems' => $wordForm->getGrammems() ); } } } class phpMorphy { const RESOLVE_ANCODES_AS_TEXT = 0; const RESOLVE_ANCODES_AS_DIALING = 1; const RESOLVE_ANCODES_AS_INT = 2; const NORMAL = 0; const IGNORE_PREDICT = 2; const ONLY_PREDICT = 3; const PREDICT_BY_NONE = 'none'; const PREDICT_BY_SUFFIX = 'by_suffix'; const PREDICT_BY_DB = 'by_db'; protected $storage_factory, $common_fsa, $common_source, $predict_fsa, $options, // variables with two underscores uses lazy paradigm, i.e. initialized at first time access //$__common_morphier, //$__predict_by_suf_morphier, //$__predict_by_db_morphier, //$__bulk_morphier, //$__word_descriptor_serializer, $helper, $last_prediction_type ; function __construct($dir, $lang = null, $options = array()) { $this->options = $options = $this->repairOptions($options); // TODO: use two versions of phpMorphy class i.e. phpMorphy_v3 { } ... phpMorphy_v2 extends phpMorphy_v3 if($dir instanceof phpMorphy_FilesBundle && is_array($lang)) { $this->initOldStyle($dir, $lang); } else { $this->initNewStyle($this->createFilesBundle($dir, $lang), $options); } $this->last_prediction_type = self::PREDICT_BY_NONE; } /** * @return phpMorphy_Morphier_Interface */ function getCommonMorphier() { return $this->__common_morphier; } /** * @return phpMorphy_Morphier_Interface */ function getPredictBySuffixMorphier() { return $this->__predict_by_suf_morphier; } /** * @return phpMorphy_Morphier_Interface */ function getPredictByDatabaseMorphier() { return $this->__predict_by_db_morphier; } /** * @return phpMorphy_Morphier_Bulk */ function getBulkMorphier() { return $this->__bulk_morphier; } /** * @return string */ function getEncoding() { return $this->helper->getGramInfo()->getEncoding(); } /** * @return string */ function getLocale() { return $this->helper->getGramInfo()->getLocale(); } /** * @return phpMorphy_GrammemsProvider_Base */ function getGrammemsProvider() { return clone $this->__grammems_provider; } /** * @return phpMorphy_GrammemsProvider_Base */ function getDefaultGrammemsProvider() { return $this->__grammems_provider; } /** * @return phpMorphy_Shm_Cache */ function getShmCache() { return $this->storage_factory->getShmCache(); } /** * @return bool */ function isLastPredicted() { return self::PREDICT_BY_NONE !== $this->last_prediction_type; } function getLastPredictionType() { return $this->last_prediction_type; } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return phpMorphy_WordDescriptor_Collection */ function findWord($word, $type = self::NORMAL) { if(is_array($word)) { $result = array(); foreach($word as $w) { $result[$w] = $this->invoke('getWordDescriptor', $w, $type); } return $result; } else { return $this->invoke('getWordDescriptor', $word, $type); } } /** * Alias for getBaseForm * * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function lemmatize($word, $type = self::NORMAL) { return $this->getBaseForm($word, $type); } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function getBaseForm($word, $type = self::NORMAL) { return $this->invoke('getBaseForm', $word, $type); } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function getAllForms($word, $type = self::NORMAL) { return $this->invoke('getAllForms', $word, $type); } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function getPseudoRoot($word, $type = self::NORMAL) { return $this->invoke('getPseudoRoot', $word, $type); } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function getPartOfSpeech($word, $type = self::NORMAL) { return $this->invoke('getPartOfSpeech', $word, $type); } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function getAllFormsWithAncodes($word, $type = self::NORMAL) { return $this->invoke('getAllFormsWithAncodes', $word, $type); } /** * @param mixed $word - string or array of strings * @paradm bool $asText - represent graminfo as text or ancodes * @param mixed $type - prediction managment * @return array */ function getAllFormsWithGramInfo($word, $asText = true, $type = self::NORMAL) { if(false === ($result = $this->findWord($word, $type))) { return false; } $asText = (bool)$asText; if(is_array($word)) { $out = array(); foreach($result as $w => $r) { if(false !== $r) { $out[$w] = $this->processWordsCollection($r, $asText); } else { $out[$w] = false; } } return $out; } else { return $this->processWordsCollection($result, $asText); } } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function getAncode($word, $type = self::NORMAL) { return $this->invoke('getAncode', $word, $type); } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function getGramInfo($word, $type = self::NORMAL) { return $this->invoke('getGrammarInfo', $word, $type); } /** * @param mixed $word - string or array of strings * @param mixed $type - prediction managment * @return array */ function getGramInfoMergeForms($word, $type = self::NORMAL) { return $this->invoke('getGrammarInfoMergeForms', $word, $type); } protected function getAnnotForWord($word, $type) { return $this->invoke('getAnnot', $word, $type); } /** * @param string $word * @param mixed $ancode * @param mixed $commonAncode * @param bool $returnOnlyWord * @param mixed $callback * @param mixed $type * @return array */ function castFormByAncode($word, $ancode, $commonAncode = null, $returnOnlyWord = false, $callback = null, $type = self::NORMAL) { $resolver = $this->helper->getAncodesResolver(); $common_ancode_id = $resolver->unresolve($commonAncode); $ancode_id = $resolver->unresolve($ancode); $data = $this->helper->getGrammemsAndPartOfSpeech($ancode_id); if(isset($common_ancode_id)) { $data[1] = array_merge($data[1], $this->helper->getGrammems($common_ancode_id)); } return $this->castFormByGramInfo( $word, $data[0], $data[1], $returnOnlyWord, $callback, $type ); } /** * @param string $word * @param mixed $partOfSpeech * @param array $grammems * @param bool $returnOnlyWord * @param mixed $callback * @param mixed $type * @return array */ function castFormByGramInfo($word, $partOfSpeech, $grammems, $returnOnlyWord = false, $callback = null, $type = self::NORMAL) { if(false === ($annot = $this->getAnnotForWord($word, $type))) { return false; } return $this->helper->castFormByGramInfo($word, $annot, $partOfSpeech, $grammems, $returnOnlyWord, $callback); } /** * @param string $word * @param string $patternWord * @param mixed $essentialGrammems * @param bool $returnOnlyWord * @param mixed $callback * @param mixed $type * @return array */ function castFormByPattern($word, $patternWord, phpMorphy_GrammemsProvider_Interface $grammemsProvider = null, $returnOnlyWord = false, $callback = null, $type = self::NORMAL) { if(false === ($word_annot = $this->getAnnotForWord($word, $type))) { return false; } if(!isset($grammemsProvider)) { $grammemsProvider = $this->__grammems_provider; } $result = array(); foreach($this->getGramInfo($patternWord, $type) as $paradigm) { foreach($paradigm as $grammar) { $pos = $grammar['pos']; $essential_grammems = $grammemsProvider->getGrammems($pos); $grammems = false !== $essential_grammems ? array_intersect($grammar['grammems'], $essential_grammems): $grammar['grammems']; $res = $this->helper->castFormByGramInfo( $word, $word_annot, $pos, $grammems, $returnOnlyWord, $callback, $type ); if(count($res)) { $result = array_merge($result, $res); } } } return $returnOnlyWord ? array_unique($result) : $result; } // public interface end protected function processWordsCollection(phpMorphy_WordDescriptor_Collection $collection, $asText) { return $this->__word_descriptor_serializer->serialize($collection, $asText); } protected function invoke($method, $word, $type) { $this->last_prediction_type = self::PREDICT_BY_NONE; if($type === self::ONLY_PREDICT) { if(is_array($word)) { $result = array(); foreach($word as $w) { $result[$w] = $this->predictWord($method, $w); } return $result; } else { return $this->predictWord($method, $word); } } if(is_array($word)) { $result = $this->__bulk_morphier->$method($word); if($type !== self::IGNORE_PREDICT) { $not_found = $this->__bulk_morphier->getNotFoundWords(); for($i = 0, $c = count($not_found); $i < $c; $i++) { $word = $not_found[$i]; $result[$word] = $this->predictWord($method, $word); } } else { for($i = 0, $c = count($not_found); $i < $c; $i++) { $result[$not_found[$i]] = false; } } return $result; } else { if(false === ($result = $this->__common_morphier->$method($word))) { if($type !== self::IGNORE_PREDICT) { return $this->predictWord($method, $word); } } return $result; } } protected function predictWord($method, $word) { if(false !== ($result = $this->__predict_by_suf_morphier->$method($word))) { $this->last_prediction_type = self::PREDICT_BY_SUFFIX; return $result; } if(false !== ($result = $this->__predict_by_db_morphier->$method($word))) { $this->last_prediction_type = self::PREDICT_BY_DB; return $result; } return false; } //////////////// // init code //////////////// protected function initNewStyle(phpMorphy_FilesBundle $bundle, $options) { $this->options = $options = $this->repairOptions($options); $storage_type = $options['storage']; $storage_factory = $this->storage_factory = $this->createStorageFactory($options['shm']); $graminfo_as_text = $this->options['graminfo_as_text']; // fsa $this->common_fsa = $this->createFsa($storage_factory->open($storage_type, $bundle->getCommonAutomatFile(), false), false); // lazy $this->predict_fsa = $this->createFsa($storage_factory->open($storage_type, $bundle->getPredictAutomatFile(), true), true); // lazy // graminfo $graminfo = $this->createGramInfo($storage_factory->open($storage_type, $bundle->getGramInfoFile(), true), $bundle); // lazy // gramtab $gramtab = $this->createGramTab( $storage_factory->open( $storage_type, $graminfo_as_text ? $bundle->getGramTabFileWithTextIds() : $bundle->getGramTabFile(), true ) ); // always lazy // common source //$this->__common_source = $this->createCommonSource($bundle, $this->options['common_source']); $this->helper = $this->createMorphierHelper($graminfo, $gramtab, $graminfo_as_text, $bundle); } protected function createCommonSource(phpMorphy_FilesBundle $bundle, $opts) { $type = $opts['type']; switch($type) { case PHPMORPHY_SOURCE_FSA: return new phpMorphy_Source_Fsa($this->common_fsa); case PHPMORPHY_SOURCE_DBA: return new phpMorphy_Source_Dba( $bundle->getDbaFile($this->getDbaHandlerName(@$opts['opts']['handler'])), $opts['opts'] ); default: throw new phpMorphy_Exception("Unknown source type given '$type'"); } } protected function getDbaHandlerName($name) { return isset($name) ? $name : phpMorphy_Source_Dba::getDefaultHandler(); } protected function initOldStyle(phpMorphy_FilesBundle $bundle, $options) { $options = $this->repairOptions($options); switch($bundle->getLang()) { case 'rus': $bundle->setLang('ru_RU'); break; case 'eng': $bundle->setLang('en_EN'); break; case 'ger': $bundle->setLang('de_DE'); break; } $this->initNewStyle($bundle, $options); } protected function repairOldOptions($options) { $defaults = array( 'predict_by_suffix' => false, 'predict_by_db' => false, ); return (array)$options + $defaults; } protected function repairSourceOptions($options) { $defaults = array( 'type' => PHPMORPHY_SOURCE_FSA, 'opts' => null ); return (array)$options + $defaults; } protected function repairOptions($options) { $defaults = array( 'shm' => array(), 'graminfo_as_text' => true, 'storage' => PHPMORPHY_STORAGE_FILE, 'common_source' => $this->repairSourceOptions(@$options['common_source']), 'predict_by_suffix' => true, 'predict_by_db' => true, 'use_ancodes_cache' => false, 'resolve_ancodes' => self::RESOLVE_ANCODES_AS_TEXT ); return (array)$options + $defaults; } function __get($name) { switch($name) { case '__predict_by_db_morphier': $this->__predict_by_db_morphier = $this->createPredictByDbMorphier( $this->predict_fsa, $this->helper ); break; case '__predict_by_suf_morphier': $this->__predict_by_suf_morphier = $this->createPredictBySuffixMorphier( $this->common_fsa, $this->helper ); break; case '__bulk_morphier': $this->__bulk_morphier = $this->createBulkMorphier( $this->common_fsa, $this->helper ); break; case '__common_morphier': $this->__common_morphier = $this->createCommonMorphier( $this->common_fsa, $this->helper ); break; case '__word_descriptor_serializer': $this->__word_descriptor_serializer = $this->createWordDescriptorSerializer(); break; case '__grammems_provider': $this->__grammems_provider = $this->createGrammemsProvider(); break; default: throw new phpMorphy_Exception("Invalid prop name '$name'"); } return $this->$name; } //////////////////// // factory methods //////////////////// function createGrammemsProvider() { return phpMorphy_GrammemsProvider_Factory::create($this); } protected function createWordDescriptorSerializer() { return new phpMorphy_WordDescriptor_Collection_Serializer(); } protected function createFilesBundle($dir, $lang) { return new phpMorphy_FilesBundle($dir, $lang); } protected function createStorageFactory($options) { return new phpMorphy_Storage_Factory($options); } protected function createFsa(phpMorphy_Storage $storage, $lazy) { return phpMorphy_Fsa::create($storage, $lazy); } protected function createGramInfo(phpMorphy_Storage $graminfoFile, phpMorphy_FilesBundle $bundle) { //return new phpMorphy_GramInfo_RuntimeCaching(new phpMorphy_GramInfo_Proxy($storage)); //return new phpMorphy_GramInfo_RuntimeCaching(phpMorphy_GramInfo::create($storage, false)); $result = new phpMorphy_GramInfo_RuntimeCaching( new phpMorphy_GramInfo_Proxy_WithHeader( $graminfoFile, $bundle->getGramInfoHeaderCacheFile() ) ); if($this->options['use_ancodes_cache']) { return new phpMorphy_GramInfo_AncodeCache( $result, $this->storage_factory->open( $this->options['storage'], $bundle->getGramInfoAncodesCacheFile(), true ) // always lazy open ); } else { return $result; } } protected function createGramTab(phpMorphy_Storage $storage) { return new phpMorphy_GramTab_Proxy($storage); } protected function createAncodesResolverInternal(phpMorphy_GramTab_Interface $gramtab, phpMorphy_FilesBundle $bundle) { switch($this->options['resolve_ancodes']) { case self::RESOLVE_ANCODES_AS_TEXT: return array( 'phpMorphy_AncodesResolver_ToText', array($gramtab) ); case self::RESOLVE_ANCODES_AS_INT: return array( 'phpMorphy_AncodesResolver_AsIs', array() ); case self::RESOLVE_ANCODES_AS_DIALING: return array( 'phpMorphy_AncodesResolver_ToDialingAncodes', array( $this->storage_factory->open( $this->options['storage'], $bundle->getAncodesMapFile(), true ) // always lazy open ) ); default: throw new phpMorphy_Exception("Invalid resolve_ancodes option, valid values are RESOLVE_ANCODES_AS_DIALING, RESOLVE_ANCODES_AS_INT, RESOLVE_ANCODES_AS_TEXT"); } } protected function createAncodesResolver(phpMorphy_GramTab_Interface $gramtab, phpMorphy_FilesBundle $bundle, $lazy) { $result = $this->createAncodesResolverInternal($gramtab, $bundle); if($lazy) { return new phpMorphy_AncodesResolver_Proxy($result[0], $result[1]); } else { return phpMorphy_AncodesResolver_Proxy::instantinate($result[0], $result[1]); } } protected function createMorphierHelper( phpMorphy_GramInfo_Interace $graminfo, phpMorphy_GramTab_Interface $gramtab, $graminfoAsText, phpMorphy_FilesBundle $bundle ) { return new phpMorphy_Morphier_Helper( $graminfo, $gramtab, $this->createAncodesResolver($gramtab, $bundle, true), $graminfoAsText ); } protected function createCommonMorphier(phpMorphy_Fsa_Interface $fsa, phpMorphy_Morphier_Helper $helper) { return new phpMorphy_Morphier_Common($fsa, $helper); } protected function createBulkMorphier(phpMorphy_Fsa_Interface $fsa, phpMorphy_Morphier_Helper $helper) { return new phpMorphy_Morphier_Bulk($fsa, $helper); } protected function createPredictByDbMorphier(phpMorphy_Fsa_Interface $fsa, phpMorphy_Morphier_Helper $helper) { if($this->options['predict_by_db']) { return new phpMorphy_Morphier_Predict_Database($fsa, $helper); } else { return new phpMorphy_Morphier_Empty(); } } protected function createPredictBySuffixMorphier(phpMorphy_Fsa_Interface $fsa, phpMorphy_Morphier_Helper $helper) { if($this->options['predict_by_suffix']) { return new phpMorphy_Morphier_Predict_Suffix($fsa, $helper); } else { return new phpMorphy_Morphier_Empty(); } } };
| ver. 1.4 |
Github
|
.
| PHP 5.4.45-1~dotdeb+6.1 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка