/[drupal]/contributions/modules/porterstemmer/porterstemmer.module
ViewVC logotype

Diff of /contributions/modules/porterstemmer/porterstemmer.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2.2.3, Thu Oct 8 16:22:10 2009 UTC revision 1.2.2.4, Wed Oct 21 23:39:54 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: porterstemmer.module,v 1.2.2.2 2009/09/10 14:50:28 jhodgdon Exp $  // $Id: porterstemmer.module,v 1.2.2.3 2009/10/08 16:22:10 jhodgdon Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 26  function porterstemmer_search_preprocess Line 26  function porterstemmer_search_preprocess
26      return $text;      return $text;
27    }    }
28    
29      // See if the PECL stemming package is installed and try to load it.
30    
31      $has_pecl_stem = FALSE;
32    
33      if (extension_loaded( 'stem')) {
34        $has_pecl_stem = TRUE;
35      }
36      else {
37        // dynamic loading of extensions is going away in PHP 6, so leave this
38        // check here!
39        if (function_exists( 'dl' )) {
40          $has_pecl_stem = dl('stem.so');
41        }
42      }
43    
44      $has_pecl_stem = $has_pecl_stem && function_exists('stem_english');
45    
46    // Process each word, skipping delimiters    // Process each word, skipping delimiters
47    $isword = !preg_match('/' . PORTERSTEMMER_BOUNDARY . '/', $words[0] );    $isword = !preg_match('/' . PORTERSTEMMER_BOUNDARY . '/', $words[0] );
48    foreach ($words as $k => $word) {    foreach ($words as $k => $word) {
49      if ($isword) {      if ($isword) {
50        $words[$k] = porterstemmer_stem($word);        if( $has_pecl_stem ) {
51            $words[$k] = stem_english($word);
52          } else {
53            $words[$k] = porterstemmer_stem($word);
54          }
55      }      }
56      $isword = !$isword;      $isword = !$isword;
57    }    }

Legend:
Removed from v.1.2.2.3  
changed lines
  Added in v.1.2.2.4

  ViewVC Help
Powered by ViewVC 1.1.2