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: TextNum.php 16541 2009-07-07 06:59:03Z bkarwin $
24 /** Zend_Search_Lucene_Analysis_Analyzer_Common */
25 require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php';
30 * @package Zend_Search_Lucene
31 * @subpackage Analysis
32 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
33 * @license http://framework.zend.com/license/new-bsd New BSD License
36 class Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum extends Zend_Search_Lucene_Analysis_Analyzer_Common
39 * Current position in a stream
48 public function reset()
52 if ($this->_input === null) {
56 // convert input into ascii
57 if (PHP_OS != 'AIX') {
58 $this->_input = iconv($this->_encoding, 'ASCII//TRANSLIT', $this->_input);
60 $this->_encoding = 'ASCII';
64 * Tokenization stream API
66 * Returns null at the end of stream
68 * @return Zend_Search_Lucene_Analysis_Token|null
70 public function nextToken()
72 if ($this->_input === null) {
77 if (! preg_match('/[a-zA-Z0-9]+/', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_position)) {
78 // It covers both cases a) there are no matches (preg_match(...) === 0)
79 // b) error occured (preg_match(...) === FALSE)
85 $endpos = $pos + strlen($str);
87 $this->_position = $endpos;
89 $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($str, $pos, $endpos));
90 } while ($token === null); // try again if token is skipped