- md5
- e21dd7963325f5670f4b8ce9bc790163
- sha1
- 192cc58127ccc1411a1f3a9638bb4173ddc16ed2
- sha256
- 8dc9938e19b3e8af2ab50fcb68d06c6b34e418b9cc7441fc77f4f63ba6028486
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('_JEXEC') or die;
/**
* Stemmer base class for the Finder indexer package.
*
* @since 2.5
*/
abstract class FinderIndexerStemmer
{
/**
* An internal cache of stemmed tokens.
*
* @var array
* @since 2.5
*/
public $cache = array();
/**
* Method to get a stemmer, creating it if necessary.
*
* @param string $adapter The type of stemmer to load.
*
* @return FinderIndexerStemmer A FinderIndexerStemmer instance.
*
* @since 2.5
* @throws Exception on invalid stemmer.
*/
public static function getInstance($adapter)
{
static $instances;
// Only create one stemmer for each adapter.
if (isset($instances[$adapter]))
{
return $instances[$adapter];
}
// Create an array of instances if necessary.
if (!is_array($instances))
{
$instances = array();
}
// Setup the adapter for the stemmer.
$adapter = JFilterInput::getInstance()->clean($adapter, 'cmd');
$path = __DIR__ . '/stemmer/' . $adapter . '.php';
$class = 'FinderIndexerStemmer' . ucfirst($adapter);
// Check if a stemmer exists for the adapter.
if (file_exists($path))
{
// Instantiate the stemmer.
include_once $path;
$instances[$adapter] = new $class;
}
else
{
// Throw invalid adapter exception.
throw new Exception(JText::sprintf('COM_FINDER_INDEXER_INVALID_STEMMER', $adapter));
}
return $instances[$adapter];
}
/**
* Method to stem a token and return the root.
*
* @param string $token The token to stem.
* @param string $lang The language of the token.
*
* @return string The root token.
*
* @since 2.5
*/
abstract public function stem($token, $lang);
}
The same content is in 20 releases, Joomla 3.4.0-beta1 to 3.5.0-beta. See them all, or every version of this file.