/[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.5, Wed Oct 21 23:47:22 2009 UTC revision 1.2.2.6, Fri Oct 23 17:42:39 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: porterstemmer.module,v 1.2.2.4 2009/10/21 23:39:54 jhodgdon Exp $  // $Id: porterstemmer.module,v 1.2.2.5 2009/10/21 23:47:22 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.    $has_pecl_stem = _porterstemmer_pecl_loaded();
   
   $has_pecl_stem = FALSE;  
   
   if (extension_loaded( 'stem')) {  
     $has_pecl_stem = TRUE;  
   }  
   else {  
     // dynamic loading of extensions is going away in PHP 6, so leave this  
     // check here!  
     if (function_exists( 'dl' )) {  
       $has_pecl_stem = dl('stem.so');  
     }  
   }  
   
   $has_pecl_stem = $has_pecl_stem && function_exists('stem_english');  
30    
31    // Process each word, skipping delimiters    // Process each word, skipping delimiters
32    $isword = !preg_match('/' . PORTERSTEMMER_BOUNDARY . '/', $words[0] );    $isword = !preg_match('/' . PORTERSTEMMER_BOUNDARY . '/', $words[0] );
# Line 123  function porterstemmer_sbp_excerpt_match Line 108  function porterstemmer_sbp_excerpt_match
108  }  }
109    
110  /**  /**
111     * Checks to see if the PECL stem extension has been loaded.
112     *
113     * @return
114     *    TRUE if the stem_english() function from the PECL stem library can be
115     *    used, FALSE if not.
116     */
117    function _porterstemmer_pecl_loaded() {
118      static $has_pecl_stem = FALSE;
119      static $already_checked = FALSE;
120    
121      if ( $already_checked ) {
122        return $has_pecl_stem;
123      }
124    
125      $has_pecl_stem = extension_loaded('stem') && function_exists('stem_english');
126      $already_checked = TRUE;
127      return $has_pecl_stem;
128    }
129    
130    /**
131   * Regular expression defining a vowel for Porter Stemmer purposes.   * Regular expression defining a vowel for Porter Stemmer purposes.
132   */   */
133  define('PORTERSTEMMER_VOWEL', '[aeiouy]');  define('PORTERSTEMMER_VOWEL', '[aeiouy]');

Legend:
Removed from v.1.2.2.5  
changed lines
  Added in v.1.2.2.6

  ViewVC Help
Powered by ViewVC 1.1.2