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


PHP Zend_Search_Lucene_Analysis_Analyzer类代码示例

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


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

示例1: buildplaces

 public function buildplaces()
 {
     ini_set('memory_limit', '1000M');
     set_time_limit(0);
     $time = time();
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
     /**
      * Create index
      */
     $index = Zend_Search_Lucene::create($this->_indexPath);
     /**
      * Get all users
      */
     $sql = $this->_db->select()->from($this->_name, array('id', 'name', 'placepic'))->limit(7500);
     $result = $this->_db->fetchAssoc($sql);
     foreach ($result as $values) {
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::keyword('placeid', $values['id']));
         $doc->addField(Zend_Search_Lucene_Field::text('placename', $values['name']));
         $doc->addField(Zend_Search_Lucene_Field::unStored('placepic', $values['placepic']));
         $index->addDocument($doc);
     }
     $index->commit();
     $elapsed = time() - $time;
     print_r($elapsed);
 }
开发者ID:abdulnizam,项目名称:zend-freniz,代码行数:26,代码来源:places.php

示例2: __construct

 public function __construct()
 {
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
     //set default encoding
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_CJK());
     //set default Analyzer
 }
开发者ID:uniqid,项目名称:lucene,代码行数:7,代码来源:Indexes.php

示例3: addDocument

 /**
  * Adds a document to this segment.
  *
  * @param Zend_Search_Lucene_Document $document
  * @throws Zend_Search_Lucene_Exception
  */
 public function addDocument(Zend_Search_Lucene_Document $document)
 {
     $storedFields = array();
     $docNorms = array();
     $similarity = Zend_Search_Lucene_Search_Similarity::getDefault();
     foreach ($document->getFieldNames() as $fieldName) {
         $field = $document->getField($fieldName);
         $this->addField($field);
         if ($field->storeTermVector) {
             /**
              * @todo term vector storing support
              */
             throw new Zend_Search_Lucene_Exception('Store term vector functionality is not supported yet.');
         }
         if ($field->isIndexed) {
             if ($field->isTokenized) {
                 $tokenList = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($field->stringValue);
             } else {
                 $tokenList = array();
                 $tokenList[] = new Zend_Search_Lucene_Analysis_Token($field->stringValue, 0, strlen($field->stringValue));
             }
             $docNorms[$field->name] = chr($similarity->encodeNorm($similarity->lengthNorm($field->name, count($tokenList))));
             $position = 0;
             foreach ($tokenList as $token) {
                 $term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $field->name);
                 $termKey = $term->key();
                 if (!isset($this->_termDictionary[$termKey])) {
                     // New term
                     $this->_termDictionary[$termKey] = $term;
                     $this->_termDocs[$termKey] = array();
                     $this->_termDocs[$termKey][$this->_docCount] = array();
                 } else {
                     if (!isset($this->_termDocs[$termKey][$this->_docCount])) {
                         // Existing term, but new term entry
                         $this->_termDocs[$termKey][$this->_docCount] = array();
                     }
                 }
                 $position += $token->getPositionIncrement();
                 $this->_termDocs[$termKey][$this->_docCount][] = $position;
             }
         }
         if ($field->isStored) {
             $storedFields[] = $field;
         }
     }
     foreach ($this->_fields as $fieldName => $field) {
         if (!$field->isIndexed) {
             continue;
         }
         if (!isset($this->_norms[$fieldName])) {
             $this->_norms[$fieldName] = str_repeat(chr($similarity->encodeNorm($similarity->lengthNorm($fieldName, 0))), $this->_docCount);
         }
         if (isset($docNorms[$fieldName])) {
             $this->_norms[$fieldName] .= $docNorms[$fieldName];
         } else {
             $this->_norms[$fieldName] .= chr($similarity->encodeNorm($similarity->lengthNorm($fieldName, 0)));
         }
     }
     $this->addStoredFields($storedFields);
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:66,代码来源:DocumentWriter.php

示例4: getQuery

 public function getQuery($encoding)
 {
     if (strpos($this->_phrase, '?') !== false || strpos($this->_phrase, '*') !== false) {
         require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
         throw new Zend_Search_Lucene_Search_QueryParserException('Wildcards are only allowed in a single terms.');
     }
     $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_phrase, $encoding);
     if (count($tokens) == 0) {
         return new Zend_Search_Lucene_Search_Query_Insignificant();
     }
     if (count($tokens) == 1) {
         $term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
         $query = new Zend_Search_Lucene_Search_Query_Term($term);
         $query->setBoost($this->_boost);
         return $query;
     }
     //It's not empty or one term query
     $position = -1;
     $query = new Zend_Search_Lucene_Search_Query_Phrase();
     foreach ($tokens as $token) {
         $position += $token->getPositionIncrement();
         $term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $this->_field);
         $query->addTerm($term, $position);
     }
     if ($this->_proximityQuery) {
         $query->setSlop($this->_wordsDistance);
     }
     $query->setBoost($this->_boost);
     return $query;
 }
开发者ID:hackingman,项目名称:TubeX,代码行数:30,代码来源:Phrase.php

示例5: __construct

 /**
  * Creates a new ZendLucene handler connection
  *
  * @param string $location
  */
 public function __construct($location)
 {
     /**
      * We're using realpath here because Zend_Search_Lucene does not do
      * that itself. It can cause issues because their destructor uses the
      * same filename but the cwd could have been changed.
      */
     $location = realpath($location);
     /* If the $location doesn't exist, ZSL throws a *generic* exception. We
      * don't care here though and just always assume it is because the
      * index does not exist. If it doesn't exist, we create it.
      */
     try {
         $this->connection = Zend_Search_Lucene::open($location);
     } catch (Zend_Search_Lucene_Exception $e) {
         $this->connection = Zend_Search_Lucene::create($location);
     }
     $this->inTransaction = 0;
     if (!$this->connection) {
         throw new ezcSearchCanNotConnectException('zendlucene', $location);
     }
     // Set proper default encoding for query parser
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:30,代码来源:zend_lucene.php

示例6: getInstance

 /**
  * Returns Zend_Search_Lucene instance for given subroot
  *
  * every subroot has it's own instance
  *
  * @param Kwf_Component_Data for this index
  * @return Zend_Search_Lucene_Interface
  */
 public static function getInstance(Kwf_Component_Data $subroot)
 {
     while ($subroot) {
         if (Kwc_Abstract::getFlag($subroot->componentClass, 'subroot')) {
             break;
         }
         $subroot = $subroot->parent;
     }
     if (!$subroot) {
         $subroot = Kwf_Component_Data_Root::getInstance();
     }
     static $instance = array();
     if (!isset($instance[$subroot->componentId])) {
         $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
         $analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords(2));
         //$stopWords = explode(' ', 'der dir das einer eine ein und oder doch ist sind an in vor nicht wir ihr sie es ich');
         //$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords));
         Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
         Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
         Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0666);
         $path = 'cache/fulltext';
         $path .= '/' . $subroot->componentId;
         try {
             $instance[$subroot->componentId] = Zend_Search_Lucene::open($path);
         } catch (Zend_Search_Lucene_Exception $e) {
             $instance[$subroot->componentId] = Zend_Search_Lucene::create($path);
         }
     }
     return $instance[$subroot->componentId];
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:38,代码来源:Lucene.php

示例7: getDefault

 /**
  * Return the default Analyzer implementation used by indexing code.
  *
  * @return Zend_Search_Lucene_Analysis_Analyzer
  */
 public static function getDefault()
 {
     if (!self::$_defaultImpl instanceof Zend_Search_Lucene_Analysis_Analyzer) {
         self::$_defaultImpl = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive();
     }
     return self::$_defaultImpl;
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:12,代码来源:Analyzer.php

示例8: update

 public static function update($data)
 {
     try {
         //Update an index.
         $index = Zend_Search_Lucene::open('../application/searchindex');
         Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
     } catch (Zend_Search_Exception $e) {
         throw $e;
     }
     // remove an existing entry
     $hits = $index->find('pk:' . $data['pk']);
     foreach ($hits as $hit) {
         $index->delete($hit->id);
     }
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $data['pk']));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('code', $data['code'], 'UTF-8'));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('u_code', strtolower($data['code']), 'UTF-8'));
     $doc->addField(Zend_Search_Lucene_Field::unIndexed('type', $data['type'], 'UTF-8'));
     $doc->addField(Zend_Search_Lucene_Field::unIndexed('id', $data['id'], 'UTF-8'));
     $doc->addField(Zend_Search_Lucene_Field::Text('title', $data['title'], 'UTF-8'));
     $doc->addField(Zend_Search_Lucene_Field::Text('en_title', Default_Model_Functions::convert_vi_to_en($data['title']), 'UTF-8'));
     $doc->addField(Zend_Search_Lucene_Field::Text('description', $data['description'], 'UTF-8'));
     $doc->addField(Zend_Search_Lucene_Field::Text('en_description', Default_Model_Functions::convert_vi_to_en($data['description']), 'UTF-8'));
     $index->addDocument($doc);
     $index->commit();
 }
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:27,代码来源:LuceneIndex.php

示例9: luceneSearchAction

 public function luceneSearchAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $path = PUBLIC_PATH . '/tmp/lucene';
     $index = Zend_Search_Lucene::open($path);
     //        $term  = new Zend_Search_Lucene_Index_Term('ritesh','title');
     //        $subquery1 = new Zend_Search_Lucene_Search_Query_Term($term);
     //
     //        $from = new Zend_Search_Lucene_Index_Term('0', 'empcode');
     //        $to   = new Zend_Search_Lucene_Index_Term('53', 'empcode');
     //        $subquery2 = new Zend_Search_Lucene_Search_Query_Range($from, $to, true);
     //
     //        $query = new Zend_Search_Lucene_Search_Query_Boolean();
     //        $query->addSubquery($subquery1, true  );
     //        $query->addSubquery($subquery2, null );
     //        Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
     //        $hits  = $index->find($query);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
     Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(1);
     $hits = $index->find("empcode:[000 TO 200]");
     foreach ($hits as $h) {
         echo "Title:" . $h->title;
         echo "-------EmpCode:" . $h->empcode;
         echo "<br>";
     }
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:27,代码来源:ImageController.php

示例10: __construct

 /**
  * Searchengine::__construct()
  * 
  * @return
  */
 public function __construct()
 {
     parent::__construct();
     $this->search_index = APPPATH . 'cache/search_index/index';
     $this->load->library('zend');
     $this->zend->load('Zend/Search/Lucene');
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
 }
开发者ID:shartte,项目名称:fw_bs_webpage,代码行数:13,代码来源:searchengine.php

示例11: init

 public function init()
 {
     if (is_file(TEMP_PATH . '/Search/write.lock.file')) {
         $this->_indexHandle = Zend_Search_Lucene::open(TEMP_PATH . '/Search');
     } else {
         $this->_indexHandle = Zend_Search_Lucene::create(TEMP_PATH . '/Search');
     }
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:9,代码来源:IndexController.php

示例12: __construct

 public function __construct()
 {
     $this->_log()->info('Starting up');
     if (@preg_match('/\\pL/u', 'a') != 1) {
         $this->_log()->err("PCRE unicode support is turned off.\n");
     }
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding($this->_encoding);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:9,代码来源:Indexer.php

示例13: testAnalyzer

 public function testAnalyzer()
 {
     $currentAnalyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault();
     $this->assertTrue($currentAnalyzer instanceof Zend_Search_Lucene_Analysis_Analyzer);
     $newAnalyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num();
     Zend_Search_Lucene_Analysis_Analyzer::setDefault($newAnalyzer);
     $this->assertTrue(Zend_Search_Lucene_Analysis_Analyzer::getDefault() === $newAnalyzer);
     // Set analyzer to the default value (used in other tests)
     Zend_Search_Lucene_Analysis_Analyzer::setDefault($currentAnalyzer);
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:10,代码来源:AnalysisTest.php

示例14: getLuceneIndex

 public static function getLuceneIndex()
 {
     ProjectConfiguration::registerZend();
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
     if (file_exists($index = self::getLuceneIndexFile())) {
         return Zend_Search_Lucene::open($index);
     } else {
         return Zend_Search_Lucene::create($index);
     }
 }
开发者ID:hielh,项目名称:abjihproject,代码行数:10,代码来源:trackTable.class.php

示例15: registerZend

 public static function registerZend()
 {
     if (self::$zendLoaded) {
         return;
     }
     set_include_path(sfConfig::get('sf_lib_dir') . '/vendor' . PATH_SEPARATOR . get_include_path());
     require_once sfConfig::get('sf_lib_dir') . '/vendor/Zend/Loader/Autoloader.php';
     Zend_Loader_Autoloader::getInstance();
     self::$zendLoaded = true;
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
 }
开发者ID:vcgato29,项目名称:poff,代码行数:11,代码来源:ProjectConfiguration.class.php


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