r24628 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24627‎ | r24628 | r24629 >
Date:17:45, 6 August 2007
Author:rainman
Status:old
Tags:
Comment:
Convert underscores to spaces in category names, per bug 10822.
Modified paths:
  • /trunk/lucene-search-2/.project (modified) (history)
  • /trunk/lucene-search-2/src/org/wikimedia/lsearch/analyzers/FastWikiTokenizerEngine.java (modified) (history)
  • /trunk/lucene-search-2/src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java (modified) (history)
  • /trunk/lucene-search-2/src/org/wikimedia/lsearch/test/WikiQueryParserTest.java (modified) (history)

Diff [purge]

Index: trunk/lucene-search-2/.project
@@ -1,6 +1,6 @@
22 <?xml version="1.0" encoding="UTF-8"?>
33 <projectDescription>
4 - <name>search-2.0</name>
 4+ <name>search-trunk</name>
55 <comment>JavaCC Nature</comment>
66 <projects>
77 </projects>
Index: trunk/lucene-search-2/src/org/wikimedia/lsearch/test/WikiQueryParserTest.java
@@ -64,6 +64,12 @@
6565
6666 q = parser.parseRaw("+eggs incategory:breakfast");
6767 assertEquals("+contents:eggs +category:breakfast",q.toString());
 68+
 69+ q = parser.parseRaw("+eggs incategory:\"two_words\"");
 70+ assertEquals("+contents:eggs +category:\"two words\"",q.toString());
 71+
 72+ q = parser.parseRaw("+eggs incategory:\"two words\"");
 73+ assertEquals("+contents:eggs +category:\"two words\"",q.toString());
6874
6975 q = parser.parseRaw("help:making breakfast");
7076 assertEquals("+help:making +help:breakfast",q.toString());
Index: trunk/lucene-search-2/src/org/wikimedia/lsearch/analyzers/FastWikiTokenizerEngine.java
@@ -637,7 +637,7 @@
638638 // don't add token to get syntax like [[bean]]s
639639 continue;
640640 case CATEGORY:
641 - categories.add(new String(buffer,0,length));
 641+ categories.add(new String(buffer,0,length).replace("_"," "));
642642 length = 0;
643643 fetch = FetchState.WORD;
644644 // index category words
Index: trunk/lucene-search-2/src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java
@@ -402,9 +402,10 @@
403403 (namespacePolicy == NamespacePolicy.IGNORE ||
404404 namespacePolicy == NamespacePolicy.REWRITE))
405405 return new Term(defaultField,t);
406 - else if(field.equals("incategory"))
407 - return new Term("category",builder.isExactCase()? t : t.toLowerCase());
408 - else
 406+ else if(field.equals("incategory")){
 407+ String norm = t.replace("_"," "); // per bug 10822
 408+ return new Term("category",builder.isExactCase()? norm : norm.toLowerCase());
 409+ } else
409410 return new Term(field,t);
410411 }
411412

Status & tagging log