follow-up r61856 — wordsegmentation should be done for all search engines, not just...
authorMark A. Hershberger <mah@users.mediawiki.org>
Tue, 9 Mar 2010 04:19:55 +0000 (04:19 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Tue, 9 Mar 2010 04:19:55 +0000 (04:19 +0000)
includes/search/SearchEngine.php
includes/search/SearchMySQL.php
includes/search/SearchUpdate.php
languages/classes/LanguageZh_hans.php

index 7f80447..67790dd 100644 (file)
@@ -56,7 +56,10 @@ class SearchEngine {
         * @return string
         */
        public function normalizeText( $string ) {
-               return $string;
+               global $wgContLang;
+
+               // Some languages such as Chinese require word segmentation
+               return $wgContLang->wordSegmentation( $string );
        }
 
        /**
index 0c238be..ff6ae7a 100644 (file)
@@ -325,8 +325,7 @@ class SearchMySQL extends SearchEngine {
 
                wfProfileIn( __METHOD__ );
                
-               // Some languages such as Chinese require word segmentation
-               $out = $wgContLang->wordSegmentation( $string );
+               $out = parent::normalizeText( $string );
 
                // MySQL fulltext index doesn't grok utf-8, so we
                // need to fold cases and convert to hex
index e30c70e..7840dd8 100644 (file)
@@ -37,7 +37,7 @@ class SearchUpdate {
 
                if( $this->mText === false ) {
                        $search->updateTitle($this->mId,
-                               Title::indexTitle( $this->mNamespace, $this->mTitle ));
+                               $search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ) );
                        wfProfileOut( $fname );
                        return;
                }
@@ -97,8 +97,8 @@ class SearchUpdate {
                wfRunHooks( 'SearchUpdate', array( $this->mId, $this->mNamespace, $this->mTitle, &$text ) );
 
                # Perform the actual update
-               $search->update($this->mId, Title::indexTitle( $this->mNamespace, $this->mTitle ),
-                               $text);
+               $search->update($this->mId, $search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ),
+                               $search->normalizeText( $text ) );
 
                wfProfileOut( $fname );
        }
index 5b03d73..20d3415 100644 (file)
@@ -25,6 +25,7 @@ class LanguageZh_hans extends Language {
                // Double-width roman characters
                $s = self::convertDoubleWidth( $string );
                $s = trim( $s );
+               $s = self::wordSegmentation( $s );
                $s = parent::normalizeForSearch( $s );
 
                wfProfileOut( __METHOD__ );