File indexing completed on 2025-01-19 05:21:25
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Search_Lucene 0017 * @subpackage Analysis 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 0024 /** Define constant used to provide correct file processing order */ 0025 /** @todo Section should be removed with ZF 2.0 release as obsolete */ 0026 if (!defined('ZEND_SEARCH_LUCENE_COMMON_ANALYZER_PROCESSED')) { 0027 define('ZEND_SEARCH_LUCENE_COMMON_ANALYZER_PROCESSED', true); 0028 } 0029 0030 0031 /** Zend_Search_Lucene_Analysis_Analyzer */ 0032 // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; 0033 0034 /** Zend_Search_Lucene_Analysis_Token */ 0035 // require_once 'Zend/Search/Lucene/Analysis/Token.php'; 0036 0037 /** Zend_Search_Lucene_Analysis_TokenFilter */ 0038 // require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php'; 0039 0040 0041 /** 0042 * Common implementation of the Zend_Search_Lucene_Analysis_Analyzer interface. 0043 * There are several standard standard subclasses provided by Zend_Search_Lucene/Analysis 0044 * subpackage: Zend_Search_Lucene_Analysis_Analyzer_Common_Text, ZSearchHTMLAnalyzer, ZSearchXMLAnalyzer. 0045 * 0046 * @todo ZSearchHTMLAnalyzer and ZSearchXMLAnalyzer implementation 0047 * 0048 * @category Zend 0049 * @package Zend_Search_Lucene 0050 * @subpackage Analysis 0051 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0052 * @license http://framework.zend.com/license/new-bsd New BSD License 0053 */ 0054 abstract class Zend_Search_Lucene_Analysis_Analyzer_Common extends Zend_Search_Lucene_Analysis_Analyzer 0055 { 0056 /** 0057 * The set of Token filters applied to the Token stream. 0058 * Array of Zend_Search_Lucene_Analysis_TokenFilter objects. 0059 * 0060 * @var array 0061 */ 0062 private $_filters = array(); 0063 0064 /** 0065 * Add Token filter to the Analyzer 0066 * 0067 * @param Zend_Search_Lucene_Analysis_TokenFilter $filter 0068 */ 0069 public function addFilter(Zend_Search_Lucene_Analysis_TokenFilter $filter) 0070 { 0071 $this->_filters[] = $filter; 0072 } 0073 0074 /** 0075 * Apply filters to the token. Can return null when the token was removed. 0076 * 0077 * @param Zend_Search_Lucene_Analysis_Token $token 0078 * @return Zend_Search_Lucene_Analysis_Token 0079 */ 0080 public function normalize(Zend_Search_Lucene_Analysis_Token $token) 0081 { 0082 foreach ($this->_filters as $filter) { 0083 $token = $filter->normalize($token); 0084 0085 // resulting token can be null if the filter removes it 0086 if ($token === null) { 0087 return null; 0088 } 0089 } 0090 0091 return $token; 0092 } 0093 } 0094