[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/search/Zend/Search/Lucene/Analysis/Analyzer/ -> Common.php (source)

   1  <?php
   2  /**
   3   * Zend Framework
   4   *
   5   * LICENSE
   6   *
   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.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Search_Lucene
  17   * @subpackage Analysis
  18   * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  19   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  20   */
  21  
  22  
  23  /** Zend_Search_Lucene_Analysis_Analyzer */
  24  require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Analysis/Analyzer.php';
  25  
  26  
  27  /**
  28   * Common implementation of the Zend_Search_Lucene_Analysis_Analyzer interface.
  29   * There are several standard standard subclasses provided by Zend_Search_Lucene/Analysis
  30   * subpackage: Zend_Search_Lucene_Analysis_Analyzer_Common_Text, ZSearchHTMLAnalyzer, ZSearchXMLAnalyzer.
  31   *
  32   * @todo ZSearchHTMLAnalyzer and ZSearchXMLAnalyzer implementation
  33   *
  34   * @category   Zend
  35   * @package    Zend_Search_Lucene
  36   * @subpackage Analysis
  37   * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  38   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  39   */
  40  abstract class Zend_Search_Lucene_Analysis_Analyzer_Common extends Zend_Search_Lucene_Analysis_Analyzer
  41  {
  42      /**
  43       * The set of Token filters applied to the Token stream.
  44       * Array of Zend_Search_Lucene_Analysis_TokenFilter objects.
  45       *
  46       * @var array
  47       */
  48      private $_filters = array();
  49  
  50      /**
  51       * Add Token filter to the Analyzer
  52       *
  53       * @param Zend_Search_Lucene_Analysis_TokenFilter $filter
  54       */
  55      public function addFilter(Zend_Search_Lucene_Analysis_TokenFilter $filter)
  56      {
  57          $this->_filters[] = $filter;
  58      }
  59  
  60      /**
  61       * Apply filters to the token. Can return null when the token was removed.
  62       *
  63       * @param Zend_Search_Lucene_Analysis_Token $token
  64       * @return Zend_Search_Lucene_Analysis_Token
  65       */
  66      public function normalize(Zend_Search_Lucene_Analysis_Token $token)
  67      {
  68          foreach ($this->_filters as $filter) {
  69              $token = $filter->normalize($token);
  70  
  71              // resulting token can be null if the filter removed it
  72              if (is_null($token)) {
  73                  return null;
  74              }
  75          }
  76  
  77          return $token;
  78      }
  79  }
  80  


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7