• R/O
  • SSH
  • HTTPS

fess: Commit


Commit MetaInfo

Revision1603 (tree)
Time2013-03-02 23:38:32
Authoryfujita

Log Message

fixed #30873

Change Summary

Incremental Difference

--- fess-suggest/trunk/src/test/java/jp/sf/fess/suggest/converter/NormalizeConverterTest.java (nonexistent)
+++ fess-suggest/trunk/src/test/java/jp/sf/fess/suggest/converter/NormalizeConverterTest.java (revision 1603)
@@ -0,0 +1,16 @@
1+package jp.sf.fess.suggest.converter;
2+
3+import static org.hamcrest.core.Is.is;
4+import static org.junit.Assert.assertThat;
5+
6+import org.junit.Test;
7+
8+public class NormalizeConverterTest {
9+
10+ @Test
11+ public void convert() {
12+ final NormalizeConverter normalizeConveter = new NormalizeConverter();
13+ assertThat(normalizeConveter.convert("123ABC123ABCアイウエオアイウエオ"),
14+ is("123ABC123ABCアイウエオアイウエオ"));
15+ }
16+}
--- fess-suggest/trunk/src/test/java/jp/sf/fess/suggest/converter/SymbolConverterTest.java (revision 1602)
+++ fess-suggest/trunk/src/test/java/jp/sf/fess/suggest/converter/SymbolConverterTest.java (revision 1603)
@@ -25,16 +25,13 @@
2525
2626 @Test
2727 public void convert() {
28- final SymbolConveter symbolConveter = new SymbolConveter();
28+ final SymbolConverter symbolConveter = new SymbolConverter();
2929 assertThat(symbolConveter.convert("123abcあいうえおアイウエオ"),
3030 is("123abcあいうえおアイウエオ"));
31- symbolConveter.addSymbol("あ");
31+ symbolConveter.addSymbol(new String[] { "あ", "ア" });
3232 assertThat(symbolConveter.convert("123abcあいうえおアイウエオ"),
33- is("123abc__ID0__いうえおアイウエオ"));
34- symbolConveter.addSymbol("ア");
35- assertThat(symbolConveter.convert("123abcあいうえおアイウエオ"),
3633 is("123abc__ID0__いうえお__ID1__イウエオ"));
37- symbolConveter.addSymbol("a");
34+ symbolConveter.addSymbol(new String[] { "a" });
3835 assertThat(symbolConveter.convert("123abcあいうえおアイウエオ"),
3936 is("123__ID2__bc__ID0__いうえお__ID1__イウエオ"));
4037 }
--- fess-suggest/trunk/src/main/java/jp/sf/fess/suggest/converter/ReadingConverter.java (revision 1602)
+++ fess-suggest/trunk/src/main/java/jp/sf/fess/suggest/converter/ReadingConverter.java (revision 1603)
@@ -103,6 +103,7 @@
103103 stream = new JapaneseTokenizer(new StringReader(query),
104104 userDictionary, true, JapaneseTokenizer.Mode.NORMAL);
105105
106+ stream.reset();
106107 while (stream.incrementToken()) {
107108 final CharTermAttribute att = stream
108109 .getAttribute(CharTermAttribute.class);
--- fess-suggest/trunk/src/main/java/jp/sf/fess/suggest/converter/NormalizeConverter.java (nonexistent)
+++ fess-suggest/trunk/src/main/java/jp/sf/fess/suggest/converter/NormalizeConverter.java (revision 1603)
@@ -0,0 +1,14 @@
1+package jp.sf.fess.suggest.converter;
2+
3+import com.ibm.icu.text.Normalizer;
4+
5+public class NormalizeConverter implements SuggestConverter {
6+
7+ @Override
8+ public String convert(final String query) {
9+ final String target = Normalizer.normalize(query.replaceAll(" +", " "),
10+ Normalizer.NFKC);
11+
12+ return target;
13+ }
14+}
--- fess-suggest/trunk/src/main/java/jp/sf/fess/suggest/Suggester.java (revision 1602)
+++ fess-suggest/trunk/src/main/java/jp/sf/fess/suggest/Suggester.java (revision 1603)
@@ -61,6 +61,10 @@
6161 }
6262 }
6363
64+ if (queryList.size() == 0) {
65+ queryList.add(target);
66+ }
67+
6468 final StringBuilder resultStrBuff = new StringBuilder(255);
6569
6670 for (int i = 0; i < queryList.size(); i++) {
@@ -87,8 +91,8 @@
8791 return SuggestConstants.EMPTY_STRING;
8892 }
8993
90- for (final SuggestConverter conveter : preQueryConverterList) {
91- target = conveter.convert(target);
94+ for (final SuggestConverter converter : resultConverterList) {
95+ target = converter.convert(target);
9296 }
9397 return target;
9498 }
--- fess-suggest/trunk/pom.xml (revision 1602)
+++ fess-suggest/trunk/pom.xml (revision 1603)
@@ -204,6 +204,11 @@
204204 <version>4.1.0</version>
205205 </dependency>
206206 <dependency>
207+ <groupId>commons-lang</groupId>
208+ <artifactId>commons-lang</artifactId>
209+ <version>2.6</version>
210+ </dependency>
211+ <dependency>
207212 <groupId>com.ibm.icu</groupId>
208213 <artifactId>icu4j</artifactId>
209214 <version>50.1</version>
Show on old repository browser