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

Diff of /contributions/modules/xapian/xapian.module

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

revision 1.10.2.6, Thu Feb 5 23:10:50 2009 UTC revision 1.10.2.7, Thu Feb 5 23:37:27 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: xapian.module,v 1.10.2.5 2009/01/30 14:24:13 simon Exp $  // $Id: xapian.module,v 1.10.2.6 2009/02/05 23:10:50 jeremy Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 246  function xapian_admin() { Line 246  function xapian_admin() {
246    // Node Type Settings    // Node Type Settings
247    $form['node_types'] = array(    $form['node_types'] = array(
248      '#type' => 'fieldset',      '#type' => 'fieldset',
249      '#title' => t('Node Types')      '#title' => t('Node types')
250    );    );
251    $form['node_types']['markup'] = array(    $form['node_types']['markup'] = array(
252      '#value' => t("<p>Select the node types to <strong>EXCLUDE</strong> from Xapian's indexing</p>"),      '#value' => t("<p>Select the node types to <strong>EXCLUDE</strong> from Xapian's indexing</p>"),
# Line 262  function xapian_admin() { Line 262  function xapian_admin() {
262      '#default_value' => variable_get('xapian_excluded_nodes', array()),      '#default_value' => variable_get('xapian_excluded_nodes', array()),
263      '#multiple' => TRUE,      '#multiple' => TRUE,
264    );    );
265    
266      // Algorithms
267      $form['algorithms'] = array(
268        '#type' => 'fieldset',
269        '#title' => t('Algorithms')
270      );
271      $languages = _xapian_languages();
272      // See http://xapian.org/docs/stemming.html
273      $form['algorithms']['xapian_stem_language'] = array(
274        '#type' => 'select',
275        '#title' => t('Stemming language'),
276        '#options' => $languages,
277        '#default_value' => variable_get('xapian_stem_language', 'english'),
278        '#description' => t('Select the language that Xapian should use when deriving the stem of each word when building an index.'),
279      );
280    
281    $form['#submit'][] = 'xapian_admin_submit';    $form['#submit'][] = 'xapian_admin_submit';
282    
283    return system_settings_form($form);    return system_settings_form($form);
284  }  }
285    
# Line 410  function xapian_query($query_string, $st Line 427  function xapian_query($query_string, $st
427    
428      $enquire = new XapianEnquire($db);      $enquire = new XapianEnquire($db);
429      $query_parser = new XapianQueryParser();      $query_parser = new XapianQueryParser();
430      $stemmer = new XapianStem("english");      $stemmer = new XapianStem(variable_get('xapian_stem_language', 'english'));
431      $query_parser->set_stemmer($stemmer);      $query_parser->set_stemmer($stemmer);
432      $query_parser->set_database($db);      $query_parser->set_database($db);
433      $query_parser->set_stemming_strategy(XapianQueryParser::STEM_SOME);      $query_parser->set_stemming_strategy(XapianQueryParser::STEM_SOME);
# Line 572  function _xapian_index_node($node, $dele Line 589  function _xapian_index_node($node, $dele
589          }          }
590    
591          if (!is_object($stemmer)) {          if (!is_object($stemmer)) {
592            $stemmer = new XapianStem("english");            $stemmer = new XapianStem(variable_get('xapian_stem_language', 'english'));
593          }          }
594          $indexer->set_stemmer($stemmer);          $indexer->set_stemmer($stemmer);
595    
# Line 889  function node_xapian_index($node) { Line 906  function node_xapian_index($node) {
906    
907    return $terms;    return $terms;
908  }  }
909    
910    /**
911     * Build list of available languages.
912     */
913    function _xapian_languages() {
914      $list = explode(' ', XapianStem::get_available_languages());
915      foreach ($list as $language) {
916        $languages[$language] = ucfirst($language);
917      }
918      return $languages;
919    }

Legend:
Removed from v.1.10.2.6  
changed lines
  Added in v.1.10.2.7

  ViewVC Help
Powered by ViewVC 1.1.2