当前位置: 首页>>代码示例>>PHP>>正文


PHP FinderIndexerHelper::stemmer方法代码示例

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


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

示例1: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     parent::setUp();
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     // Set up our mock database
     JFactory::$database = $this->getMockDatabase('Mysqli');
     FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance('porter_en');
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:17,代码来源:FinderIndexerTokenTest.php

示例2: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     // Set up our mock database
     $db = JFactory::getDbo();
     $db->name = 'mysqli';
     JFactory::$database = $db;
     FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance('porter_en');
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:18,代码来源:FinderIndexerTokenTest.php

示例3: populateState

 /**
  * Method to auto-populate the model state.  Calling getState in this method will result in recursion.
  *
  * @param   string  $ordering   An optional ordering field. [optional]
  * @param   string  $direction  An optional direction. [optional]
  *
  * @return  void
  *
  * @since   2.5
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Get the configuration options.
     $app = JFactory::getApplication();
     $input = $app->input;
     $params = $app->getParams();
     $user = JFactory::getUser();
     $filter = JFilterInput::getInstance();
     $this->setState('filter.language', JLanguageMultilang::isEnabled());
     // Setup the stemmer.
     if ($params->get('stem', 1) && $params->get('stemmer', 'porter_en')) {
         FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance($params->get('stemmer', 'porter_en'));
     }
     $request = $input->request;
     $options = array();
     // Get the query string.
     $options['input'] = !is_null($request->get('q')) ? $request->get('q', '', 'string') : $params->get('q');
     $options['input'] = $filter->clean($options['input'], 'string');
     // Get the empty query setting.
     $options['empty'] = $params->get('allow_empty_query', 0);
     // Get the query language.
     $options['language'] = !is_null($request->get('l')) ? $request->get('l', '', 'cmd') : $params->get('l');
     $options['language'] = $filter->clean($options['language'], 'cmd');
     // Get the static taxonomy filters.
     $options['filter'] = !is_null($request->get('f')) ? $request->get('f', '', 'int') : $params->get('f');
     $options['filter'] = $filter->clean($options['filter'], 'int');
     // Get the dynamic taxonomy filters.
     $options['filters'] = !is_null($request->get('t', '', 'array')) ? $request->get('t', '', 'array') : $params->get('t');
     $options['filters'] = $filter->clean($options['filters'], 'array');
     JArrayHelper::toInteger($options['filters']);
     // Get the start date and start date modifier filters.
     $options['date1'] = !is_null($request->get('d1')) ? $request->get('d1', '', 'string') : $params->get('d1');
     $options['date1'] = $filter->clean($options['date1'], 'string');
     $options['when1'] = !is_null($request->get('w1')) ? $request->get('w1', '', 'string') : $params->get('w1');
     $options['when1'] = $filter->clean($options['when1'], 'string');
     // Get the end date and end date modifier filters.
     $options['date2'] = !is_null($request->get('d2')) ? $request->get('d2', '', 'string') : $params->get('d2');
     $options['date2'] = $filter->clean($options['date2'], 'string');
     $options['when2'] = !is_null($request->get('w2')) ? $request->get('w2', '', 'string') : $params->get('w2');
     $options['when2'] = $filter->clean($options['when2'], 'string');
     // Load the query object.
     $this->query = new FinderIndexerQuery($options);
     // Load the query token data.
     $this->excludedTerms = $this->query->getExcludedTermIds();
     $this->includedTerms = $this->query->getIncludedTermIds();
     $this->requiredTerms = $this->query->getRequiredTermIds();
     // Load the list state.
     $this->setState('list.start', $input->get('limitstart', 0, 'uint'));
     $this->setState('list.limit', $input->get('limit', $app->getCfg('list_limit', 20), 'uint'));
     // Load the sort ordering.
     $order = $params->get('sort_order', 'relevance');
     switch ($order) {
         case 'date':
             $this->setState('list.ordering', 'l.start_date');
             break;
         case 'price':
             $this->setState('list.ordering', 'l.list_price');
             break;
         case $order == 'relevance' && !empty($this->includedTerms):
             $this->setState('list.ordering', 'm.weight');
             break;
         default:
             $this->setState('list.ordering', 'l.link_id');
             break;
     }
     // Load the sort direction.
     $dirn = $params->get('sort_direction', 'desc');
     switch ($dirn) {
         case 'asc':
             $this->setState('list.direction', 'ASC');
             break;
         default:
         case 'desc':
             $this->setState('list.direction', 'DESC');
             break;
     }
     // Set the match limit.
     $this->setState('match.limit', 1000);
     // Load the parameters.
     $this->setState('params', $params);
     // Load the user state.
     $this->setState('user.id', (int) $user->get('id'));
     $this->setState('user.groups', $user->getAuthorisedViewLevels());
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:94,代码来源:search.php

示例4: populateState

 /**
  * Method to auto-populate the model state.  Calling getState in this method will result in recursion.
  *
  * @param   string  $ordering   An optional ordering field. [optional]
  * @param   string  $direction  An optional direction. [optional]
  *
  * @return  void
  *
  * @since   2.5
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Get the configuration options.
     $app = JFactory::getApplication();
     $input = $app->input;
     $params = $app->getParams();
     $user = JFactory::getUser();
     $filter = JFilterInput::getInstance();
     $this->setState('filter.language', JLanguageMultilang::isEnabled());
     // Setup the stemmer.
     if ($params->get('stem', 1) && $params->get('stemmer', 'porter_en')) {
         FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance($params->get('stemmer', 'porter_en'));
     }
     $request = $input->request;
     $options = array();
     // Get the empty query setting.
     $options['empty'] = $params->get('allow_empty_query', 0);
     // Get the static taxonomy filters.
     $options['filter'] = $request->getInt('f', $params->get('f', ''));
     // Get the dynamic taxonomy filters.
     $options['filters'] = $request->get('t', $params->get('t', array()), '', 'array');
     // Get the query string.
     $options['input'] = $request->getString('q', $params->get('q', ''));
     // Get the query language.
     $options['language'] = $request->getCmd('l', $params->get('l', ''));
     // Get the start date and start date modifier filters.
     $options['date1'] = $request->getString('d1', $params->get('d1', ''));
     $options['when1'] = $request->getString('w1', $params->get('w1', ''));
     // Get the end date and end date modifier filters.
     $options['date2'] = $request->getString('d2', $params->get('d2', ''));
     $options['when2'] = $request->getString('w2', $params->get('w2', ''));
     // Load the query object.
     $this->query = new FinderIndexerQuery($options);
     // Load the query token data.
     $this->excludedTerms = $this->query->getExcludedTermIds();
     $this->includedTerms = $this->query->getIncludedTermIds();
     $this->requiredTerms = $this->query->getRequiredTermIds();
     // Load the list state.
     $this->setState('list.start', $input->get('limitstart', 0, 'uint'));
     $this->setState('list.limit', $input->get('limit', $app->get('list_limit', 20), 'uint'));
     /* Load the sort ordering.
      * Currently this is 'hard' coded via menu item parameter but may not satisfy a users need.
      * More flexibility was way more user friendly. So we allow the user to pass a custom value
      * from the pool of fields that are indexed like the 'title' field.
      * Also, we allow this parameter to be passed in either case (lower/upper).
      */
     $order = $input->getWord('filter_order', $params->get('sort_order', 'relevance'));
     $order = JString::strtolower($order);
     switch ($order) {
         case 'date':
             $this->setState('list.ordering', 'l.start_date');
             break;
         case 'price':
             $this->setState('list.ordering', 'l.list_price');
             break;
         case $order == 'relevance' && !empty($this->includedTerms):
             $this->setState('list.ordering', 'm.weight');
             break;
             // custom field that is indexed and might be required for ordering
         // custom field that is indexed and might be required for ordering
         case 'title':
             $this->setState('list.ordering', 'l.title');
             break;
         default:
             $this->setState('list.ordering', 'l.link_id');
             break;
     }
     /* Load the sort direction.
      * Currently this is 'hard' coded via menu item parameter but may not satisfy a users need.
      * More flexibility was way more user friendly. So we allow to be inverted.
      * Also, we allow this parameter to be passed in either case (lower/upper).
      */
     $dirn = $input->getWord('filter_order_Dir', $params->get('sort_direction', 'desc'));
     $dirn = JString::strtolower($dirn);
     switch ($dirn) {
         case 'asc':
             $this->setState('list.direction', 'ASC');
             break;
         default:
         case 'desc':
             $this->setState('list.direction', 'DESC');
             break;
     }
     // Set the match limit.
     $this->setState('match.limit', 1000);
     // Load the parameters.
     $this->setState('params', $params);
     // Load the user state.
     $this->setState('user.id', (int) $user->get('id'));
     $this->setState('user.groups', $user->getAuthorisedViewLevels());
//.........这里部分代码省略.........
开发者ID:ziyou-liu,项目名称:1line,代码行数:101,代码来源:search.php

示例5: getState

 /**
  * Method to get the indexer state.
  *
  * @return  object  The indexer state object.
  *
  * @since   2.5
  */
 public static function getState()
 {
     // First, try to load from the internal state.
     if (!empty(self::$state)) {
         return self::$state;
     }
     // If we couldn't load from the internal state, try the session.
     $session = JFactory::getSession();
     $data = $session->get('_finder.state', null);
     // If the state is empty, load the values for the first time.
     if (empty($data)) {
         $data = new JObject();
         // Load the default configuration options.
         $data->options = JComponentHelper::getParams('com_finder');
         // Setup the weight lookup information.
         $data->weights = array(self::TITLE_CONTEXT => round($data->options->get('title_multiplier', 1.7), 2), self::TEXT_CONTEXT => round($data->options->get('text_multiplier', 0.7), 2), self::META_CONTEXT => round($data->options->get('meta_multiplier', 1.2), 2), self::PATH_CONTEXT => round($data->options->get('path_multiplier', 2.0), 2), self::MISC_CONTEXT => round($data->options->get('misc_multiplier', 0.3), 2));
         // Set the current time as the start time.
         $data->startTime = JFactory::getDate()->toSql();
         // Set the remaining default values.
         $data->batchSize = (int) $data->options->get('batch_size', 50);
         $data->batchOffset = 0;
         $data->totalItems = 0;
         $data->pluginState = array();
     }
     // Setup the profiler if debugging is enabled.
     if (JFactory::getApplication()->get('debug')) {
         self::$profiler = JProfiler::getInstance('FinderIndexer');
     }
     // Setup the stemmer.
     if ($data->options->get('stem', 1) && $data->options->get('stemmer', 'porter_en')) {
         FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance($data->options->get('stemmer', 'porter_en'));
     }
     // Set the state.
     self::$state = $data;
     return self::$state;
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:43,代码来源:indexer.php

示例6: __construct

 * @since 1.5
 */
class plgSearchStreams extends JPlugin
{
    /**
	 * Constructor
	 *
	 * For php4 compatability we must not use the __constructor as a constructor for plugins
	 * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
	 * This causes problems with cross-referencing necessary for the observer design pattern.
	 *
	 * @param 	object $subject The object to observe
	 * @param 	array  $config  An array that holds the plugin configuration
	 * @since 1.5
	 */
    public function __construct(&$subject, $config)
    {
        parent::__construct($subject, $config);
        //$this->loadLanguage();
    }
    /**
	 * Display the button
	 *
	 * @return array A two element array of ( imageName, textToInsert )
	 */
    function onContentSearch()
    {
        //global $mainframe;
        $mainframe = JFactory::getApplication();
        $args = func_get_args();
        if (empty($args[0])) {
            return array();
        }
        // array(4) { [0]=> string(10) "she is asd" [1]=> string(5) "exact/all/any" [2]=> string(6) "oldest/newest/alpha/category/popular" [3]=> NULL }
        // Group ID and Filter Range will be from "areas" parameter in com_search form
        if (is_null($args[3])) {
            $areas = 0;
        } else {
            $areas = is_array($args[3]) ? $args[3][0] : $args[3];
        }
        if (preg_match('/_\\d\\w$/', $areas)) {
            $splitVal = explode('_', $areas);
            $groupId = $splitVal[0];
            $filterRange = $splitVal[1];
            // _2w (2 weeks), _1m (1 month), _3m (3 months), _0a (all)
            $rangeCond = $this->_getDateRange($filterRange);
        } else {
            // no filter range info provided;
            $groupId = $areas;
            $filterRange = '0a';
            $rangeCond = $this->_getDateRange($filterRange);
        }
        // search for all/streams/comments/files/people is from "searchphrase" parameter in com_search form
        $searchFor = $args[1];
        // custom class loader
        JLoader::register('FinderIndexerStemmer', FINDER_PATH_INDEXER . '/stemmer.php');
        FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance('porter_en');
        // option porter_en/snowball
        //FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance('snowball'); // option porter_en/snowball
        $option = array("input" => $args[0], "empty" => "0", "language" => "", "filter" => 0, "filters" => array());
        $keyTerm = new FinderIndexerQuery($option);
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        // This part get all groups that the logined user is permitted to see.
        $my = JXFactory::getUser();
        if (!$my->isAdmin()) {
            $query->select('id');
            $query->from('#__groups');
            // group must not be archived and access is public
            $query->where(' ( ' . $db->quoteName('archived') . ' = 0 AND ' . $db->quoteName('access') . ' = 0 ) ', 'OR');
            // OR group is private and user is a member of the private group
            $query->where('( ' . $db->quoteName('access') . ' = 1 AND `members` REGEXP \'^' . $my->id . '[^0-9]|[^0-9]' . $my->id . '[^0-9]|[^0-9]' . $my->id . '$\'' . ' )');
            $db->setQuery($query);
            $allowGroups = $db->loadObjectList();
            for ($i = 0; $i < count($allowGroups); $i++) {
                $allowGroupId[] = $allowGroups[$i]->id;
            }
            $allowGroupId[] = 0;
            $allowGroupCond = ' ( group_id IN (' . implode(',', $allowGroupId) . ') ) ';
        } else {
            $allowGroupCond = '';
        }
        //$limit		= 20;
        $condStream = $condComment = $condFile = $condProfile = array();
        $stream = $comment = $files = $people = $user = $rec = array();
        $streamId = $userId = $keywords = array();
        $condition = '';
        $count = 0;
        foreach ($keyTerm->included as $searchKey) {
            $keywords[] = $searchKey->term;
            // prepare stream condition
            $condStream[$count] = " ( message LIKE " . $db->quote('%' . $searchKey->term . '%');
            // prepare comment condition
            //$condComment[$count]	= " ( comment LIKE ".$db->quote('%'.$searchKey->term.'%');
            // prepare files condition
            $condFile[$count] = " ( filename LIKE " . $db->quote('%' . $searchKey->term . '%');
            // prepare people condition
            $condProfile[$count] = " ( value LIKE " . $db->quote('%' . $searchKey->term . '%');
            $condUser[$count] = " ( name LIKE " . $db->quote('%' . $searchKey->term . '%') . " OR username LIKE " . $db->quote('%' . $searchKey->term . '%');
            if ($searchKey->term != $searchKey->stem) {
//.........这里部分代码省略.........
开发者ID:ErickLopez76,项目名称:offiria,代码行数:101,代码来源:streams.php


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