Manybubbles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/86781


Change subject: Allow aggressive splitting.
......................................................................

Allow aggressive splitting.

Aggressive splitting splits camelCase, snake_case, terms with numb3rs in
them, hyphen-ated words, etc.  It might be good in all wikis but for now
it only works in English.

Bug: 54799

Change-Id: I6a84835ea5d6463f10e4fcd5bb228e1ffd252a28
---
M CirrusSearch.php
M includes/CirrusSearchAnalysisConfigBuilder.php
2 files changed, 22 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/81/86781/1

diff --git a/CirrusSearch.php b/CirrusSearch.php
index 9743802..f7bf99c 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -92,6 +92,10 @@
        'max_word_len' => 0,
 );
 
+// Should CirrusSearch aggressively split up compound words?  Good for 
splitting camelCase, snake_case, etc.
+// Changing it requires an in place reindex to take effect.  Currently only 
available in English.
+$wgCirrusSearchUseAggressiveSplitting = true;
+
 $dir = __DIR__ . '/';
 /**
  * Classes
diff --git a/includes/CirrusSearchAnalysisConfigBuilder.php 
b/includes/CirrusSearchAnalysisConfigBuilder.php
index 0da92a6..cd4ed84 100644
--- a/includes/CirrusSearchAnalysisConfigBuilder.php
+++ b/includes/CirrusSearchAnalysisConfigBuilder.php
@@ -84,6 +84,11 @@
                                ),
                                'lowercase' => array(
                                        'type' => 'lowercase',
+                               ),
+
+                               'aggressive_splitting' => array(
+                                       'type' => 'word_delimiter',
+                                       'stem_english_possessive' => 'false', 
// No need
                                )
                        ),
                        'tokenizer' => array(
@@ -102,6 +107,7 @@
         * Customize the default config for the language.
         */
        private function customize( $config ) {
+               global $wgCirrusSearchUseAggressiveSplitting;
                switch ( $this->language ) {
                // Please add languages in alphabetical order.
                case 'el':
@@ -116,8 +122,19 @@
                        $config[ 'analyzer' ][ 'text' ] = array(
                                'type' => 'custom',
                                'tokenizer' => 'standard',
-                               'filter' => array( 'standard', 
'possessive_english', 'lowercase', 'stop', 'porter_stem', 'asciifolding' )
                        );
+                       $filters = array();
+                       $filters[] = 'standard';
+                       if ( $wgCirrusSearchUseAggressiveSplitting ) {
+                               $filters[] = 'aggressive_splitting';
+                       }
+                       $filters[] = 'possessive_english';
+                       $filters[] = 'lowercase';
+                       $filters[] = 'stop';
+                       $filters[] = 'porter_stem';
+                       $filters[] = 'asciifolding';
+                       $config[ 'analyzer' ][ 'text' ][ 'filter' ] = $filters;
+
                        // Add asciifolding to the the text_plain analyzer as 
well
                        $config[ 'analyzer' ][ 'plain' ][ 'filter' ][] = 
'asciifolding';
                        // Add asciifolding to the prefix queries and 
incategory filters

-- 
To view, visit https://gerrit.wikimedia.org/r/86781
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a84835ea5d6463f10e4fcd5bb228e1ffd252a28
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to