INSTALL

install this module as usual.

To make its functionality availabe to existing stemmer
these stemmers need to be patched. Example patches 
accompanies this module.

No database tables are affected


For example the minimal patch needed to let stemer_api interact with 
a stemmer - here porterstemmer - is to set up an initial settings menu.
Put lines LIKE the following in <your_stemmer>.module

/********************************************************************/
/**
 * Implementation of hook_menu
 */
function porterstemmer_menu() {
  $items = array();
  $items['admin/settings/porterstemmer'] = array(
    'title' => 'Porter Stemmer',
    'description' => 'Search by word stems',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('porterstemmer_settings'),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

/**
 * dummy
 */
function porterstemmer_settings()
{ $form = array();
}

/********************************************************************/

To get full functionality of stemmer_api additional patches are required.
Use the read functions get the actual values of stopwords / exceptions.
For example for "de_stemmer":


In file de_stemmer.module:

// global variables to hold lists of words
$de_stemmer_stopwords = array();
$de_stemmer_exceptions = array();


function de_stemmer_init() {
  global $de_stemmer_stopwords;
  global $de_stemmer_exceptions;

  $de_stemmer_stopwords = stemmer_api_stopwords_read('de_stemmer');
  $de_stemmer_exceptions = stemmer_api_exceptions_read('de_stemmer');
}


In file de_stemmer.install:

/**
 * Implementation of hook_install().
 */
function de_stemmer_install() {
  $stopwords = stemmer_api_stopwords_read('de_stemmer');
  if ( empty($stopwords) ) {
	// get initial values for word lists
    require_once drupal_get_path('module', 'de_stemmer') . '/includes/de_stemmer.data.inc';
	// set valid stopwords from include file
    stemmer_api_stopwords_store($stopwords_default,'de_stemmer');
  }

  $exceptions = stemmer_api_exceptions_read('de_stemmer');
  if ( empty($exceptions) ) {
	// get initial values for word lists
    require_once drupal_get_path('module', 'de_stemmer') . '/includes/de_stemmer.data.inc';
	// set valid exceptions from include file
    stemmer_api_exceptions_store($exceptions_default,'de_stemmer');
  }
}


/**
 * Implementation of hook_uninstall().
 */
function de_stemmer_uninstall() {
  variable_del('de_stemmer_stopwords');
  variable_del('de_stemmer_exceptions');

  menu_rebuild();
}


In file de_stemmer.data.inc

  $stopwords_default = array(
	'ab', 'aber', 'aber', 'ach', 'acht', 'achte', 'achten', 'achter', 
        ...
  );

  $exceptions_default = array ( 
    'schön'	=> 'schön', 	// !schon
    ...
  );

