• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Search_Lucene_Analysis_Token类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: normalize

 /**
  * @see Zend_Search_Lucene_Analysis_TokenFilter
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
 {
     $text = $this->stemmer->doStem($srcToken->getTermText());
     $newToken = new Zend_Search_Lucene_Analysis_Token($text, $srcToken->getStartOffset(), $srcToken->getEndOffset());
     $newToken->setPositionIncrement($srcToken->getPositionIncrement());
     return $newToken;
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:10,代码来源:xfLuceneStemmerTokenFilter.class.php


示例2: normalize

 /**
  * Normalize Token or remove it (if null is returned)
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) {
     if (array_key_exists($srcToken->getTermText(), $this->_stopSet)) {
         return null;
     } else {
         return $srcToken;
     }
 }
开发者ID:nhp,项目名称:shopware-4,代码行数:13,代码来源:StopWords.php


示例3: normalize

 /**
  * Normalize Token or remove it (if null is returned)
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) {
     if (strlen($srcToken->getTermText()) < $this->length) {
         return null;
     } else {
         return $srcToken;
     }
 }
开发者ID:nhp,项目名称:shopware-4,代码行数:13,代码来源:ShortWords.php


示例4: normalize

 /**
  * If not numeric, calls the parent method.
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
 {
     if (!ctype_digit($srcToken->getTermText())) {
         return parent::normalize($srcToken);
     } else {
         return $srcToken;
     }
 }
开发者ID:sraj4,项目名称:EthicsPublicHtmlProd,代码行数:14,代码来源:ShortWords.php


示例5: normalize

 /**
  * Normalize Token or remove it (if null is returned).
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
 {
     // gets token text, invokes hook_search_preprocess().
     $processed_text = $srcToken->getTermText();
     search_invoke_preprocess($processed_text);
     // returns the new processed token
     $newToken = new Zend_Search_Lucene_Analysis_Token($processed_text, $srcToken->getStartOffset(), $srcToken->getEndOffset());
     $newToken->setPositionIncrement($srcToken->getPositionIncrement());
     return $newToken;
 }
开发者ID:sraj4,项目名称:EthicsPublicHtmlProd,代码行数:16,代码来源:Drupal.php


示例6: normalize

    /**
     * Normalize Token or remove it (if null is returned)
     *
     * @param Zend_Search_Lucene_Analysis_Token $srcToken
     * @return Zend_Search_Lucene_Analysis_Token
     */
    public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
    {
        $newToken = new Zend_Search_Lucene_Analysis_Token(
                                     strtolower( $srcToken->getTermText() ),
                                     $srcToken->getStartOffset(),
                                     $srcToken->getEndOffset());

        $newToken->setPositionIncrement($srcToken->getPositionIncrement());

        return $newToken;
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:17,代码来源:LowerCase.php


示例7: normalize

 /**
  * Normalize Token or remove it (if null is returned)
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
 {
     if ($this->mbString) {
         $value = mb_strtolower($srcToken->getTermText(), 'utf8');
     } else {
         $value = strtolower($srcToken->getTermText());
     }
     $newToken = new Zend_Search_Lucene_Analysis_Token($value, $srcToken->getStartOffset(), $srcToken->getEndOffset());
     $newToken->setPositionIncrement($srcToken->getPositionIncrement());
     return $newToken;
 }
开发者ID:palcoprincipal,项目名称:sfLucenePlugin,代码行数:17,代码来源:sfLuceneLowerCaseFilter.class.php


示例8: normalize

 /**
  * Normalize Token or remove it (if null is returned)
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $po_srctoken)
 {
     $vo_lang_analyzer = new LanguageDetection();
     $vs_original_string = $po_srctoken->getTermText();
     $vs_lang_code = $vo_lang_analyzer->analyze($vs_original_string);
     /* stem text with respect to language that has been detected */
     $vo_stemmer = new SnoballStemmer();
     if ($vs_lang_code) {
         $vs_stemmed_string = $vo_stemmer->stem($vs_original_string, $vs_lang_code);
     } else {
         /* if language could not be detected, don't do any stemming at all */
         $vs_stemmed_string = $vs_original_string;
     }
     /* build new token to return */
     $vo_new_token = new Zend_Search_Lucene_Analysis_Token($vs_stemmed_string, $po_srctoken->getStartOffset(), $po_srctoken->getEndOffset());
     $vo_new_token->setPositionIncrement($po_srctoken->getPositionIncrement());
     return $vo_new_token;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:24,代码来源:StemmingFilter.php


示例9: normalize

 /**
  * Normalize Token or remove it (if null is returned)
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
 {
     $srcToken->setTermText(mb_strtolower($srcToken->getTermText(), 'UTF-8'));
     return $srcToken;
 }
开发者ID:,项目名称:,代码行数:11,代码来源:


示例10: normalize

 /**
  * Normalize Token or remove it (if null is returned)
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
 {
     //iconv("utf-8", "us-ascii//TRANSLIT", $url); // TRANSLIT does the whole job
     // We could use also remove_accents() in uri.php
     // Problem: ñ -> n
     //$token = strtolower(iconv("utf-8", "us-ascii//TRANSLIT", $srcToken->getTermText()));
     $token = strtolower($srcToken->getTermText());
     if (strlen($token) < 2 || array_key_exists($token, $this->_stopSet)) {
         return null;
     }
     $newToken = new Zend_Search_Lucene_Analysis_Token($token, $srcToken->getStartOffset(), $srcToken->getEndOffset());
     $newToken->setPositionIncrement($srcToken->getPositionIncrement());
     return $newToken;
 }
开发者ID:brainsqueezer,项目名称:fffff,代码行数:20,代码来源:lucene.php


示例11: dirname

<?php

/**
 * This file is part of the sfLucene package.
 * (c) Carl Vondrick <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
require 'util/xfLuceneZendManager.class.php';
require 'stemmer/xfLuceneStemmerTokenFilter.class.php';
require 'stemmer/xfLuceneStemmer.interface.php';
require 'stemmer/xfLuceneStemmerPorter.class.php';
require 'vendor/PorterStemmer/PorterStemmer.class.php';
$t = new lime_test(2, new lime_output_color());
$s = new xfLuceneStemmerPorter();
$filter = new xfLuceneStemmerTokenFilter($s);
$token = new Zend_Search_Lucene_Analysis_Token('nationalize', 10, 21);
$token->setPositionIncrement(0);
$response = $filter->normalize($token);
$t->isa_ok($response, 'Zend_Search_Lucene_Analysis_Token', '->normalize() returns a Zend_Search_Lucene_Analysis_Token');
$t->is($response->getTermText(), 'nation', '->normalize() consults the stemmer');
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:23,代码来源:xfLuceneStemmerTokenFilterTest.php


示例12: nextToken

 /**
  * Tokenization stream API
  * Get next token
  * Returns null at the end of stream
  *
  * @return Zend_Search_Lucene_Analysis_Token|null
  */
 public function nextToken()
 {
     // есть ли нам откуда брать данные?
     if (!$this->num_chunks) {
         return null;
     }
     // сначала отдаём уже имеющиеся токены
     if (sizeof($this->token_stack)) {
         return array_pop($this->token_stack);
     }
     while ($this->num_chunks > $this->current_chunk) {
         $word = $this->input_chunks[$this->current_chunk + 1];
         // специальный случай: идентификаторы сайтов и разделов в виде sub123, site5
         if ($this->ignore_numbers && ($word == 'site' || $word == 'sub') && preg_match("/^(\\d+)/", $this->input_chunks[$this->current_chunk + 2], $matches)) {
             $word .= $matches[1];
         }
         $word_length = mb_strlen($word, 'UTF-8');
         $delimiter_length = mb_strlen($this->input_chunks[$this->current_chunk], 'UTF-8');
         $start_position = $this->current_chunk == 1 ? 0 : $this->char_position + $delimiter_length + 1;
         $end_position = $start_position + $word_length;
         // готовимся к следующему циклу
         $this->char_position = $end_position;
         $this->current_chunk += 2;
         if (!$word_length) {
             continue;
         }
         // на входе была строка без значащих символов?
         // применяем фильтры
         $processed = $this->apply_nc_filters($word);
         $count = sizeof($processed);
         if ($count > 0) {
             for ($i = 1; $i < $count; $i++) {
                 // i.e. if $count > 1
                 $token = new Zend_Search_Lucene_Analysis_Token($processed[$i], $start_position, $end_position);
                 // умная книга Lucene in Action советует установить $token->setPositionIncrement(0),
                 // но, по-моему, разницы нет (в исходниках ZSL отмечено "todo: Process
                 // $token->getPositionIncrement()" - может быть, в будущем заработает)
                 $token->setPositionIncrement(0);
                 $this->token_stack[] = $token;
             }
             return new Zend_Search_Lucene_Analysis_Token($processed[0], $start_position, $end_position);
         }
     }
     return null;
 }
开发者ID:Blu2z,项目名称:implsk,代码行数:52,代码来源:analyzer.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Search_Lucene_Document类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Search_Lucene_Analysis_Analyzer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap