7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Search_Lucene
17 * @subpackage Analysis
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Common.php 16541 2009-07-07 06:59:03Z bkarwin $
24 /** Zend_Search_Lucene_Analysis_Analyzer */
25 require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
29 * Common implementation of the Zend_Search_Lucene_Analysis_Analyzer interface.
30 * There are several standard standard subclasses provided by Zend_Search_Lucene/Analysis
31 * subpackage: Zend_Search_Lucene_Analysis_Analyzer_Common_Text, ZSearchHTMLAnalyzer, ZSearchXMLAnalyzer.
33 * @todo ZSearchHTMLAnalyzer and ZSearchXMLAnalyzer implementation
36 * @package Zend_Search_Lucene
37 * @subpackage Analysis
38 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
39 * @license http://framework.zend.com/license/new-bsd New BSD License
41 abstract class Zend_Search_Lucene_Analysis_Analyzer_Common extends Zend_Search_Lucene_Analysis_Analyzer
44 * The set of Token filters applied to the Token stream.
45 * Array of Zend_Search_Lucene_Analysis_TokenFilter objects.
49 private $_filters = array();
52 * Add Token filter to the Analyzer
54 * @param Zend_Search_Lucene_Analysis_TokenFilter $filter
56 public function addFilter(Zend_Search_Lucene_Analysis_TokenFilter $filter)
58 $this->_filters[] = $filter;
62 * Apply filters to the token. Can return null when the token was removed.
64 * @param Zend_Search_Lucene_Analysis_Token $token
65 * @return Zend_Search_Lucene_Analysis_Token
67 public function normalize(Zend_Search_Lucene_Analysis_Token $token)
69 foreach ($this->_filters as $filter) {
70 $token = $filter->normalize($token);
72 // resulting token can be null if the filter removes it
73 if ($token === null) {