version 1.0.2
@@ -0,0 +1,220 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
4 | + <modelVersion>4.0.0</modelVersion> | |
5 | + <groupId>jp.sf.fess</groupId> | |
6 | + <artifactId>fess-suggest</artifactId> | |
7 | + <version>1.0.2</version> | |
8 | + <packaging>jar</packaging> | |
9 | + <name>fess-suggest</name> | |
10 | + <url>http://fess.codelibs.org/</url> | |
11 | + <inceptionYear>2009</inceptionYear> | |
12 | + <licenses> | |
13 | + <license> | |
14 | + <name>The Apache Software License, Version 2.0</name> | |
15 | + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | |
16 | + <distribution>repo</distribution> | |
17 | + </license> | |
18 | + </licenses> | |
19 | + <organization> | |
20 | + <name>CodeLibs</name> | |
21 | + <url>http://www.codelibs.org/</url> | |
22 | + </organization> | |
23 | + <developers> | |
24 | + <developer> | |
25 | + <id>shinsuke</id> | |
26 | + <name>Shinsuke Sugaya</name> | |
27 | + <email>shinsuke_at_yahoo.co.jp</email> | |
28 | + <url>http://www.chazine.com/</url> | |
29 | + </developer> | |
30 | + </developers> | |
31 | + <issueManagement> | |
32 | + <url><![CDATA[http://sourceforge.jp/projects/fess/ticket/]]></url> | |
33 | + </issueManagement> | |
34 | + <distributionManagement> | |
35 | + <repository> | |
36 | + <id>codelibs-repository</id> | |
37 | + <url>ftp://maven.codelibs.org/home/codelibs/maven/</url> | |
38 | + </repository> | |
39 | + <site> | |
40 | + <id>codelibs-site</id> | |
41 | + <url>ftp://maven.codelibs.org/home/codelibs/fess/projects/fess-suggest/</url> | |
42 | + </site> | |
43 | + </distributionManagement> | |
44 | + <scm> | |
45 | + <connection>scm:svn:http://svn.sourceforge.jp/svnroot/fess/fess-suggest/trunk</connection> | |
46 | + <developerConnection>scm:svn:https://svn.sourceforge.jp/svnroot/fess/fess-suggest/trunk</developerConnection> | |
47 | + <url>http://sourceforge.jp/projects/fess/svn/view/</url> | |
48 | + </scm> | |
49 | + <mailingLists> | |
50 | + <mailingList> | |
51 | + <name>User List</name> | |
52 | + <subscribe>http://lists.sourceforge.jp/mailman/listinfo/fess-user</subscribe> | |
53 | + <unsubscribe>http://lists.sourceforge.jp/mailman/listinfo/fess-user</unsubscribe> | |
54 | + <post>fess-user@lists.sourceforge.jp</post> | |
55 | + <archive>http://sourceforge.jp/projects/fess/lists/archive/user/</archive> | |
56 | + </mailingList> | |
57 | + </mailingLists> | |
58 | + <properties> | |
59 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
60 | + </properties> | |
61 | + <build> | |
62 | + <plugins> | |
63 | + <plugin> | |
64 | + <artifactId>maven-compiler-plugin</artifactId> | |
65 | + <configuration> | |
66 | + <source>1.6</source> | |
67 | + <target>1.6</target> | |
68 | + <encoding>UTF-8</encoding> | |
69 | + </configuration> | |
70 | + </plugin> | |
71 | + <plugin> | |
72 | + <artifactId>maven-source-plugin</artifactId> | |
73 | + <executions> | |
74 | + <execution> | |
75 | + <id>source-jar</id> | |
76 | + <phase>package</phase> | |
77 | + <goals> | |
78 | + <goal>jar</goal> | |
79 | + </goals> | |
80 | + </execution> | |
81 | + </executions> | |
82 | + </plugin> | |
83 | + <plugin> | |
84 | + <artifactId>maven-javadoc-plugin</artifactId> | |
85 | + <configuration> | |
86 | + <encoding>UTF-8</encoding> | |
87 | + <docencoding>UTF-8</docencoding> | |
88 | + <charset>UTF-8</charset> | |
89 | + <links> | |
90 | + <link>http://docs.oracle.com/javase/6/docs/api/</link> | |
91 | + <link>http://docs.oracle.com/javaee/6/api/</link> | |
92 | + <link>http://aopalliance.sourceforge.net/doc/</link> | |
93 | + <link>http://www.csg.is.titech.ac.jp/~chiba/javassist/html/</link> | |
94 | + <link>http://www.junit.org/junit/javadoc/4.3/</link> | |
95 | + <link>http://www.junit.org/junit/javadoc/3.8.1/</link> | |
96 | + <link>http://s2container.seasar.org/2.4/s2-framework/ja/apidocs/</link> | |
97 | + <link>http://s2container.seasar.org/2.4/s2-extension/ja/apidocs/</link> | |
98 | + <link>http://s2container.seasar.org/2.4/s2-tiger/ja/apidocs/</link> | |
99 | + <link>http://s2robot.sandbox.seasar.org/apidocs/</link> | |
100 | + </links> | |
101 | + </configuration> | |
102 | + <executions> | |
103 | + <execution> | |
104 | + <phase>site</phase> | |
105 | + <goals> | |
106 | + <goal>javadoc</goal> | |
107 | + </goals> | |
108 | + </execution> | |
109 | + </executions> | |
110 | + </plugin> | |
111 | + <plugin> | |
112 | + <groupId>com.mycila.maven-license-plugin</groupId> | |
113 | + <artifactId>maven-license-plugin</artifactId> | |
114 | + <version>1.5.0</version> | |
115 | + <configuration> | |
116 | + <header>${basedir}/src/etc/header.txt</header> | |
117 | + <includes> | |
118 | + <include>src/**/*.java</include> | |
119 | + </includes> | |
120 | + <encoding>UTF-8</encoding> | |
121 | + <headerDefinitions> | |
122 | + <headerDefinition>${basedir}/src/etc/header-definition.xml</headerDefinition> | |
123 | + </headerDefinitions> | |
124 | + </configuration> | |
125 | + </plugin> | |
126 | + <plugin> | |
127 | + <artifactId>maven-site-plugin</artifactId> | |
128 | + <configuration> | |
129 | + <locales>en,ja</locales> | |
130 | + <inputEncoding>UTF-8</inputEncoding> | |
131 | + <outputEncoding>UTF-8</outputEncoding> | |
132 | + </configuration> | |
133 | + </plugin> | |
134 | + </plugins> | |
135 | + <extensions> | |
136 | + <extension> | |
137 | + <groupId>org.apache.maven.wagon</groupId> | |
138 | + <artifactId>wagon-ftp</artifactId> | |
139 | + <version>1.0-beta-6</version> | |
140 | + </extension> | |
141 | + </extensions> | |
142 | + </build> | |
143 | + <pluginRepositories> | |
144 | + <pluginRepository> | |
145 | + <id>maven.seasar.org</id> | |
146 | + <name>The Seasar Foundation Maven2 Repository</name> | |
147 | + <url>http://maven.seasar.org/maven2/</url> | |
148 | + </pluginRepository> | |
149 | + <pluginRepository> | |
150 | + <id>maven-snapshot.seasar.org</id> | |
151 | + <name>The Seasar Foundation Maven2 Repository</name> | |
152 | + <url>http://maven.seasar.org/maven2-snapshot/</url> | |
153 | + </pluginRepository> | |
154 | + <pluginRepository> | |
155 | + <name>oss.sonatype.org</name> | |
156 | + <id>oss.sonatype.org</id> | |
157 | + <url>http://oss.sonatype.org/content/groups/public/</url> | |
158 | + </pluginRepository> | |
159 | + </pluginRepositories> | |
160 | + <repositories> | |
161 | + <repository> | |
162 | + <id>codelibs.org</id> | |
163 | + <name>CodeLibs Repository</name> | |
164 | + <url>http://maven.codelibs.org/</url> | |
165 | + </repository> | |
166 | + <repository> | |
167 | + <id>maven.seasar.org</id> | |
168 | + <name>The Seasar Foundation Maven2 Repository</name> | |
169 | + <url>http://maven.seasar.org/maven2/</url> | |
170 | + </repository> | |
171 | + <repository> | |
172 | + <id>maven-snapshot.seasar.org</id> | |
173 | + <name>The Seasar Foundation Maven2 Repository</name> | |
174 | + <url>http://maven.seasar.org/maven2-snapshot/</url> | |
175 | + </repository> | |
176 | + <repository> | |
177 | + <id>orangesignal.sourceforge.jp</id> | |
178 | + <name>OrangeSignal Repository</name> | |
179 | + <url>http://orangesignal.sourceforge.jp/maven2/</url> | |
180 | + </repository> | |
181 | + </repositories> | |
182 | + <dependencies> | |
183 | + <dependency> | |
184 | + <groupId>org.slf4j</groupId> | |
185 | + <artifactId>jcl-over-slf4j</artifactId> | |
186 | + <version>1.7.2</version> | |
187 | + </dependency> | |
188 | + <dependency> | |
189 | + <groupId>org.slf4j</groupId> | |
190 | + <artifactId>slf4j-api</artifactId> | |
191 | + <version>1.7.2</version> | |
192 | + </dependency> | |
193 | + <dependency> | |
194 | + <groupId>org.slf4j</groupId> | |
195 | + <artifactId>slf4j-log4j12</artifactId> | |
196 | + <version>1.7.2</version> | |
197 | + </dependency> | |
198 | + <dependency> | |
199 | + <groupId>org.apache.lucene</groupId> | |
200 | + <artifactId>lucene-analyzers-kuromoji</artifactId> | |
201 | + <version>4.4.0</version> | |
202 | + </dependency> | |
203 | + <dependency> | |
204 | + <groupId>commons-lang</groupId> | |
205 | + <artifactId>commons-lang</artifactId> | |
206 | + <version>2.6</version> | |
207 | + </dependency> | |
208 | + <dependency> | |
209 | + <groupId>com.ibm.icu</groupId> | |
210 | + <artifactId>icu4j</artifactId> | |
211 | + <version>50.1.1</version> | |
212 | + </dependency> | |
213 | + <dependency> | |
214 | + <groupId>junit</groupId> | |
215 | + <artifactId>junit</artifactId> | |
216 | + <version>4.11</version> | |
217 | + <scope>test</scope> | |
218 | + </dependency> | |
219 | + </dependencies> | |
220 | +</project> |
@@ -0,0 +1,160 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +import java.io.FileInputStream; | |
20 | +import java.io.IOException; | |
21 | +import java.io.InputStream; | |
22 | +import java.io.InputStreamReader; | |
23 | +import java.io.Reader; | |
24 | +import java.io.StringReader; | |
25 | +import java.nio.charset.Charset; | |
26 | +import java.nio.charset.CharsetDecoder; | |
27 | +import java.nio.charset.CodingErrorAction; | |
28 | +import java.util.LinkedHashMap; | |
29 | +import java.util.Map; | |
30 | + | |
31 | +import jp.sf.fess.suggest.FessSuggestException; | |
32 | + | |
33 | +import org.apache.commons.lang.StringUtils; | |
34 | +import org.apache.lucene.analysis.TokenStream; | |
35 | +import org.apache.lucene.analysis.ja.JapaneseTokenizer; | |
36 | +import org.apache.lucene.analysis.ja.dict.UserDictionary; | |
37 | +import org.apache.lucene.analysis.ja.tokenattributes.ReadingAttribute; | |
38 | +import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; | |
39 | +import org.apache.lucene.util.IOUtils; | |
40 | +import org.slf4j.Logger; | |
41 | +import org.slf4j.LoggerFactory; | |
42 | + | |
43 | +import com.ibm.icu.text.Transliterator; | |
44 | + | |
45 | +public class ReadingConverter implements SuggestConverter { | |
46 | + private static final Logger logger = LoggerFactory | |
47 | + .getLogger(ReadingConverter.class); | |
48 | + | |
49 | + private static final String USER_DICT_ENCODING = "fess.user.dict.encoding"; | |
50 | + | |
51 | + private static final String USER_DICT_PATH = "fess.user.dict.path"; | |
52 | + | |
53 | + protected volatile UserDictionary userDictionary; | |
54 | + | |
55 | + protected volatile boolean initialized = false; | |
56 | + | |
57 | + private final Transliterator transliterator = Transliterator | |
58 | + .getInstance("Hiragana-Katakana"); | |
59 | + | |
60 | + protected void init() { | |
61 | + if (initialized) { | |
62 | + return; | |
63 | + } | |
64 | + | |
65 | + synchronized (this) { | |
66 | + if (initialized) { | |
67 | + return; | |
68 | + } | |
69 | + | |
70 | + final String path = System.getProperty(USER_DICT_PATH); | |
71 | + if (path != null) { | |
72 | + InputStream stream = null; | |
73 | + try { | |
74 | + stream = new FileInputStream(path); | |
75 | + String encoding = System.getProperty(USER_DICT_ENCODING); | |
76 | + if (encoding == null) { | |
77 | + encoding = IOUtils.UTF_8; | |
78 | + } | |
79 | + final CharsetDecoder decoder = Charset.forName(encoding) | |
80 | + .newDecoder() | |
81 | + .onMalformedInput(CodingErrorAction.REPORT) | |
82 | + .onUnmappableCharacter(CodingErrorAction.REPORT); | |
83 | + final Reader reader = new InputStreamReader(stream, decoder); | |
84 | + userDictionary = new UserDictionary(reader); | |
85 | + } catch (final Exception e) { | |
86 | + throw new FessSuggestException(e); | |
87 | + } finally { | |
88 | + if (stream != null) { | |
89 | + try { | |
90 | + stream.close(); | |
91 | + } catch (final IOException e) { | |
92 | + } | |
93 | + } | |
94 | + } | |
95 | + } | |
96 | + | |
97 | + initialized = true; | |
98 | + } | |
99 | + } | |
100 | + | |
101 | + @Override | |
102 | + public String convert(final String query) { | |
103 | + init(); | |
104 | + | |
105 | + final Map<String, String> termMap = new LinkedHashMap<String, String>(); | |
106 | + | |
107 | + TokenStream stream = null; | |
108 | + try { | |
109 | + stream = new JapaneseTokenizer(new StringReader(query), | |
110 | + userDictionary, true, JapaneseTokenizer.Mode.NORMAL); | |
111 | + | |
112 | + stream.reset(); | |
113 | + while (stream.incrementToken()) { | |
114 | + final CharTermAttribute att = stream | |
115 | + .getAttribute(CharTermAttribute.class); | |
116 | + final String term = att.toString(); | |
117 | + | |
118 | + final ReadingAttribute rdAttr = stream | |
119 | + .getAttribute(ReadingAttribute.class); | |
120 | + final String reading = rdAttr.getReading(); | |
121 | + | |
122 | + if (StringUtils.isNotBlank(reading)) { | |
123 | + termMap.put(term, reading); | |
124 | + } else { | |
125 | + termMap.put(term, transliterator.transliterate(term)); | |
126 | + } | |
127 | + } | |
128 | + } catch (final Exception e) { | |
129 | + logger.warn("JapaneseTokenizer stream error", e); | |
130 | + } finally { | |
131 | + if (stream != null) { | |
132 | + try { | |
133 | + stream.close(); | |
134 | + } catch (final Exception e) { | |
135 | + } | |
136 | + } | |
137 | + } | |
138 | + | |
139 | + final StringBuilder buf = new StringBuilder(); | |
140 | + | |
141 | + int pos = 0; | |
142 | + for (final Map.Entry<String, String> entry : termMap.entrySet()) { | |
143 | + final String term = entry.getKey(); | |
144 | + final String reading = entry.getValue(); | |
145 | + final int index = query.indexOf(term, pos); | |
146 | + if (index - pos > 0) { | |
147 | + buf.append(transliterator.transliterate(query.substring(pos, | |
148 | + index))); | |
149 | + } | |
150 | + buf.append(reading); | |
151 | + pos = index + term.length(); | |
152 | + } | |
153 | + if (pos < query.length()) { | |
154 | + buf.append(query.substring(pos)); | |
155 | + } | |
156 | + | |
157 | + return buf.toString(); | |
158 | + } | |
159 | + | |
160 | +} |
@@ -0,0 +1,69 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +import java.util.ArrayList; | |
20 | +import java.util.List; | |
21 | + | |
22 | +public class SymbolConverter implements SuggestConverter { | |
23 | + | |
24 | + protected List<String> symbolList = new ArrayList<String>(); | |
25 | + | |
26 | + protected String symbolPrefix; | |
27 | + | |
28 | + protected String symbolSuffix; | |
29 | + | |
30 | + public SymbolConverter() { | |
31 | + this("__ID", "__"); | |
32 | + } | |
33 | + | |
34 | + public SymbolConverter(final String prefix, final String suffix) { | |
35 | + symbolPrefix = prefix; | |
36 | + symbolSuffix = suffix; | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public String convert(final String query) { | |
41 | + | |
42 | + String target = query; | |
43 | + for (int i = 0; i < symbolList.size(); i++) { | |
44 | + target = target.replace(symbolList.get(i), | |
45 | + symbolPrefix + Integer.valueOf(i) + symbolSuffix); | |
46 | + } | |
47 | + return target; | |
48 | + } | |
49 | + | |
50 | + public void addSymbol(final String[] symbols) { | |
51 | + if (symbols == null || symbols.length == 0) { | |
52 | + return; | |
53 | + } | |
54 | + | |
55 | + for (final String symbol : symbols) { | |
56 | + symbolList.add(symbol); | |
57 | + } | |
58 | + } | |
59 | + | |
60 | + public void addSymbol(final List<String> symbols) { | |
61 | + if (symbols == null || symbols.size() == 0) { | |
62 | + return; | |
63 | + } | |
64 | + | |
65 | + for (final String symbol : symbols) { | |
66 | + symbolList.add(symbol); | |
67 | + } | |
68 | + } | |
69 | +} |
@@ -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 | +} |
@@ -0,0 +1,37 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +import java.util.LinkedHashMap; | |
20 | +import java.util.Map; | |
21 | + | |
22 | +public class ReplaceConverter implements SuggestConverter { | |
23 | + protected Map<String, String> replaceMap = new LinkedHashMap<String, String>(); | |
24 | + | |
25 | + @Override | |
26 | + public String convert(final String query) { | |
27 | + String target = query; | |
28 | + for (final Map.Entry<String, String> entry : replaceMap.entrySet()) { | |
29 | + target = target.replaceAll(entry.getKey(), entry.getValue()); | |
30 | + } | |
31 | + return target; | |
32 | + } | |
33 | + | |
34 | + public void addReplaceString(final String before, final String after) { | |
35 | + replaceMap.put(before, after); | |
36 | + } | |
37 | +} |
@@ -0,0 +1,33 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +import com.ibm.icu.text.Transliterator; | |
20 | + | |
21 | +public class ICUConverter implements SuggestConverter { | |
22 | + protected Transliterator transliterator; | |
23 | + | |
24 | + public ICUConverter(final String transliteratorId) { | |
25 | + transliterator = Transliterator.getInstance(transliteratorId); | |
26 | + } | |
27 | + | |
28 | + @Override | |
29 | + public String convert(final String query) { | |
30 | + return transliterator.transliterate(query); | |
31 | + } | |
32 | + | |
33 | +} |
@@ -0,0 +1,21 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +public interface SuggestConverter { | |
20 | + String convert(final String query); | |
21 | +} |
@@ -0,0 +1,28 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest; | |
18 | + | |
19 | +public class SuggestConstants { | |
20 | + | |
21 | + public static final String EMPTY_STRING = ""; | |
22 | + | |
23 | + public static final String WORD_SEPARATOR = "_SP_"; | |
24 | + | |
25 | + protected SuggestConstants() { | |
26 | + // nothing | |
27 | + } | |
28 | +} |
@@ -0,0 +1,99 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest; | |
18 | + | |
19 | +import java.util.ArrayList; | |
20 | +import java.util.List; | |
21 | + | |
22 | +import jp.sf.fess.suggest.converter.SuggestConverter; | |
23 | + | |
24 | +public class Suggester { | |
25 | + | |
26 | + protected final List<SuggestConverter> preQueryConverterList = new ArrayList<SuggestConverter>(); | |
27 | + | |
28 | + protected final List<SuggestConverter> queryConverterList = new ArrayList<SuggestConverter>(); | |
29 | + | |
30 | + protected final List<SuggestConverter> resultConverterList = new ArrayList<SuggestConverter>(); | |
31 | + | |
32 | + public String wordSeprator = SuggestConstants.WORD_SEPARATOR; | |
33 | + | |
34 | + public void addQueryConverter(final SuggestConverter converter) { | |
35 | + queryConverterList.add(converter); | |
36 | + } | |
37 | + | |
38 | + public void addPreQueryConverter(final SuggestConverter converter) { | |
39 | + preQueryConverterList.add(converter); | |
40 | + } | |
41 | + | |
42 | + public void addResultConverter(final SuggestConverter converter) { | |
43 | + resultConverterList.add(converter); | |
44 | + } | |
45 | + | |
46 | + public String convertQuery(final String query) { | |
47 | + | |
48 | + String target = query; | |
49 | + for (final SuggestConverter conveter : preQueryConverterList) { | |
50 | + target = conveter.convert(target); | |
51 | + } | |
52 | + | |
53 | + final List<String> queryList = new ArrayList<String>(); | |
54 | + for (final SuggestConverter converter : queryConverterList) { | |
55 | + String convertedQuery = converter.convert(target); | |
56 | + if (convertedQuery != null) { | |
57 | + convertedQuery = convertedQuery.trim(); | |
58 | + if (convertedQuery.length() > 0) { | |
59 | + queryList.add(convertedQuery); | |
60 | + } | |
61 | + } | |
62 | + } | |
63 | + | |
64 | + if (queryList.size() == 0) { | |
65 | + queryList.add(target); | |
66 | + } | |
67 | + | |
68 | + final StringBuilder resultStrBuff = new StringBuilder(255); | |
69 | + | |
70 | + for (int i = 0; i < queryList.size(); i++) { | |
71 | + if (i > 0) { | |
72 | + resultStrBuff.append(' '); | |
73 | + } | |
74 | + | |
75 | + resultStrBuff.append(queryList.get(i)); | |
76 | + } | |
77 | + | |
78 | + return resultStrBuff.toString(); | |
79 | + } | |
80 | + | |
81 | + public String convertResultString(final String suggestTerm) { | |
82 | + final String[] strArray = suggestTerm.split(wordSeprator); | |
83 | + | |
84 | + String target; | |
85 | + | |
86 | + if (strArray.length == 1) { | |
87 | + target = strArray[0]; | |
88 | + } else if (strArray.length == 2) { | |
89 | + target = strArray[1]; | |
90 | + } else { | |
91 | + return SuggestConstants.EMPTY_STRING; | |
92 | + } | |
93 | + | |
94 | + for (final SuggestConverter converter : resultConverterList) { | |
95 | + target = converter.convert(target); | |
96 | + } | |
97 | + return target; | |
98 | + } | |
99 | +} |
@@ -0,0 +1,35 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest; | |
18 | + | |
19 | +public class FessSuggestException extends RuntimeException { | |
20 | + | |
21 | + private static final long serialVersionUID = 1L; | |
22 | + | |
23 | + public FessSuggestException(final String message, final Throwable cause) { | |
24 | + super(message, cause); | |
25 | + } | |
26 | + | |
27 | + public FessSuggestException(final String message) { | |
28 | + super(message); | |
29 | + } | |
30 | + | |
31 | + public FessSuggestException(final Throwable cause) { | |
32 | + super(cause); | |
33 | + } | |
34 | + | |
35 | +} |
@@ -0,0 +1,33 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest; | |
18 | + | |
19 | +import java.util.HashMap; | |
20 | +import java.util.Map; | |
21 | + | |
22 | +public class SuggesterManager { | |
23 | + | |
24 | + protected Map<String, Suggester> suggesterMap = new HashMap<String, Suggester>(); | |
25 | + | |
26 | + public void addSuggester(final String name, final Suggester suggester) { | |
27 | + suggesterMap.put(name, suggester); | |
28 | + } | |
29 | + | |
30 | + public Suggester getSuggester(final String name) { | |
31 | + return suggesterMap.get(name); | |
32 | + } | |
33 | +} |
@@ -0,0 +1,70 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +import static org.hamcrest.core.Is.is; | |
20 | +import static org.junit.Assert.assertThat; | |
21 | + | |
22 | +import org.junit.Test; | |
23 | + | |
24 | +public class ReadingConverterTest { | |
25 | + private final ReadingConverter readingConverter = new ReadingConverter(); | |
26 | + | |
27 | + @Test | |
28 | + public void convertHiragana() { | |
29 | + assertThat(readingConverter.convert("あいうえお"), is("アイウエオ")); | |
30 | + } | |
31 | + | |
32 | + @Test | |
33 | + public void convertKatakana() { | |
34 | + assertThat(readingConverter.convert("アイウエオ"), is("アイウエオ")); | |
35 | + assertThat(readingConverter.convert("アイウエオ"), is("アイウエオ")); | |
36 | + } | |
37 | + | |
38 | + @Test | |
39 | + public void convertKanji() { | |
40 | + assertThat(readingConverter.convert("検索"), is("ケンサク")); | |
41 | + assertThat(readingConverter.convert("琥珀"), is("コハク")); | |
42 | + } | |
43 | + | |
44 | + @Test | |
45 | + public void convertAlphabet() { | |
46 | + assertThat(readingConverter.convert("abc"), is("abc")); | |
47 | + assertThat(readingConverter.convert("ABC"), is("ABC")); | |
48 | + assertThat(readingConverter.convert("abc"), is("abc")); | |
49 | + assertThat(readingConverter.convert("ABC"), is("エイビーシー")); | |
50 | + } | |
51 | + | |
52 | + @Test | |
53 | + public void convertDigit() { | |
54 | + assertThat(readingConverter.convert("123"), is("123")); | |
55 | + assertThat(readingConverter.convert("123"), is("イチニサン")); | |
56 | + } | |
57 | + | |
58 | + @Test | |
59 | + public void convertSymbol() { | |
60 | + assertThat(readingConverter.convert("@"), is("@")); | |
61 | + assertThat(readingConverter.convert("@"), is("@")); | |
62 | + } | |
63 | + | |
64 | + @Test | |
65 | + public void convert() { | |
66 | + assertThat(readingConverter.convert("TEST用の文字列"), is("TESTヨウノモジレツ")); | |
67 | + assertThat(readingConverter.convert("メールアドレスtest@example.com"), | |
68 | + is("メールアドレスtest@example.com")); | |
69 | + } | |
70 | +} |
@@ -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 | +} |
@@ -0,0 +1,39 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +import static org.hamcrest.core.Is.is; | |
20 | +import static org.junit.Assert.assertThat; | |
21 | + | |
22 | +import org.junit.Test; | |
23 | + | |
24 | +public class SymbolConverterTest { | |
25 | + | |
26 | + @Test | |
27 | + public void convert() { | |
28 | + final SymbolConverter symbolConveter = new SymbolConverter(); | |
29 | + assertThat(symbolConveter.convert("123abcあいうえおアイウエオ"), | |
30 | + is("123abcあいうえおアイウエオ")); | |
31 | + symbolConveter.addSymbol(new String[] { "あ", "ア" }); | |
32 | + assertThat(symbolConveter.convert("123abcあいうえおアイウエオ"), | |
33 | + is("123abc__ID0__いうえお__ID1__イウエオ")); | |
34 | + symbolConveter.addSymbol(new String[] { "a" }); | |
35 | + assertThat(symbolConveter.convert("123abcあいうえおアイウエオ"), | |
36 | + is("123__ID2__bc__ID0__いうえお__ID1__イウエオ")); | |
37 | + } | |
38 | + | |
39 | +} |
@@ -0,0 +1,36 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +import static org.hamcrest.core.Is.is; | |
20 | +import static org.junit.Assert.assertThat; | |
21 | + | |
22 | +import org.junit.Test; | |
23 | + | |
24 | +public class ReplaceConverterTest { | |
25 | + | |
26 | + @Test | |
27 | + public void convert() { | |
28 | + final ReplaceConverter replaceConverter = new ReplaceConverter(); | |
29 | + assertThat(replaceConverter.convert("123abcあいうえおアイウエオ"), | |
30 | + is("123abcあいうえおアイウエオ")); | |
31 | + replaceConverter.addReplaceString("abc", "ABC"); | |
32 | + assertThat(replaceConverter.convert("123abcあいうえおアイウエオ"), | |
33 | + is("123ABCあいうえおアイウエオ")); | |
34 | + } | |
35 | + | |
36 | +} |
@@ -0,0 +1,140 @@ | ||
1 | +/* | |
2 | + * Copyright 2009-2013 the Fess Project and the Others. | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | + * either express or implied. See the License for the specific language | |
14 | + * governing permissions and limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package jp.sf.fess.suggest.converter; | |
18 | + | |
19 | +import static org.hamcrest.core.Is.is; | |
20 | +import static org.junit.Assert.assertThat; | |
21 | + | |
22 | +import java.util.Enumeration; | |
23 | + | |
24 | +import org.junit.Test; | |
25 | + | |
26 | +import com.ibm.icu.text.Transliterator; | |
27 | + | |
28 | +public class ICUConverterTest { | |
29 | + | |
30 | + @Test | |
31 | + public void convertFullwidthHalfwidth() { | |
32 | + final ICUConverter icuConverter = new ICUConverter( | |
33 | + "Fullwidth-Halfwidth"); | |
34 | + assertThat(icuConverter.convert("123"), is("123")); | |
35 | + assertThat(icuConverter.convert("123"), is("123")); | |
36 | + assertThat(icuConverter.convert("abc"), is("abc")); | |
37 | + assertThat(icuConverter.convert("abc"), is("abc")); | |
38 | + assertThat(icuConverter.convert("ABC"), is("ABC")); | |
39 | + assertThat(icuConverter.convert("ABC"), is("ABC")); | |
40 | + assertThat(icuConverter.convert("!\"#$%&'()~"), is("!\"#$%&'()~")); | |
41 | + assertThat(icuConverter.convert("!”#$%&’()〜"), is("!”#$%&’()〜")); | |
42 | + assertThat(icuConverter.convert("-^\\=~|"), is("-^\\=~|")); | |
43 | + assertThat(icuConverter.convert("ー^¥=〜|"), is("ー^¥=〜|")); | |
44 | + assertThat(icuConverter.convert("@[;:]`{+*}"), is("@[;:]`{+*}")); | |
45 | + assertThat(icuConverter.convert("@「;:」`{+*}"), is("@「;:」`{+*}")); | |
46 | + assertThat(icuConverter.convert(",./<>?_"), is(",./<>?_")); | |
47 | + assertThat(icuConverter.convert("、。・<>?_"), is("、。・<>?_")); | |
48 | + assertThat(icuConverter.convert("あいうえお"), is("あいうえお")); | |
49 | + assertThat(icuConverter.convert("アイウエオ"), is("アイウエオ")); | |
50 | + assertThat(icuConverter.convert("アイウエオ"), is("アイウエオ")); | |
51 | + assertThat(icuConverter.convert("漢字"), is("漢字")); | |
52 | + assertThat(icuConverter.convert(" "), is(" ")); | |
53 | + | |
54 | + } | |
55 | + | |
56 | + @Test | |
57 | + public void convertHalfwidthFullwidth() { | |
58 | + final ICUConverter icuConverter = new ICUConverter( | |
59 | + "Halfwidth-Fullwidth"); | |
60 | + assertThat(icuConverter.convert("123"), is("123")); | |
61 | + assertThat(icuConverter.convert("123"), is("123")); | |
62 | + assertThat(icuConverter.convert("abc"), is("abc")); | |
63 | + assertThat(icuConverter.convert("abc"), is("abc")); | |
64 | + assertThat(icuConverter.convert("ABC"), is("ABC")); | |
65 | + assertThat(icuConverter.convert("ABC"), is("ABC")); | |
66 | + assertThat(icuConverter.convert("!\"#$%&'()~"), is("!"#$%&'()~")); | |
67 | + assertThat(icuConverter.convert("!”#$%&’()〜"), is("!”#$%&’()〜")); | |
68 | + assertThat(icuConverter.convert("-^\\=~|"), is("-^\=~|")); | |
69 | + assertThat(icuConverter.convert("ー^¥=〜|"), is("ー^¥=〜|")); | |
70 | + assertThat(icuConverter.convert("@[;:]`{+*}"), is("@[;:]`{+*}")); | |
71 | + assertThat(icuConverter.convert("@「;:」`{+*}"), is("@「;:」`{+*}")); | |
72 | + assertThat(icuConverter.convert(",./<>?_"), is(",./<>?_")); | |
73 | + assertThat(icuConverter.convert("、。・<>?_"), is("、。・<>?_")); | |
74 | + assertThat(icuConverter.convert("あいうえお"), is("あいうえお")); | |
75 | + assertThat(icuConverter.convert("アイウエオ"), is("アイウエオ")); | |
76 | + assertThat(icuConverter.convert("アイウエオ"), is("アイウエオ")); | |
77 | + assertThat(icuConverter.convert("漢字"), is("漢字")); | |
78 | + assertThat(icuConverter.convert(" "), is(" ")); | |
79 | + | |
80 | + } | |
81 | + | |
82 | + @Test | |
83 | + public void convertKatakanaHiragana() { | |
84 | + final ICUConverter icuConverter = new ICUConverter("Katakana-Hiragana"); | |
85 | + assertThat(icuConverter.convert("123"), is("123")); | |
86 | + assertThat(icuConverter.convert("123"), is("123")); | |
87 | + assertThat(icuConverter.convert("abc"), is("abc")); | |
88 | + assertThat(icuConverter.convert("abc"), is("abc")); | |
89 | + assertThat(icuConverter.convert("ABC"), is("ABC")); | |
90 | + assertThat(icuConverter.convert("ABC"), is("ABC")); | |
91 | + assertThat(icuConverter.convert("!\"#$%&'()~"), is("!\"#$%&'()~")); | |
92 | + assertThat(icuConverter.convert("!”#$%&’()〜"), is("!”#$%&’()〜")); | |
93 | + assertThat(icuConverter.convert("-^\\=~|"), is("-^\\=~|")); | |
94 | + assertThat(icuConverter.convert("ー^¥=〜|"), is("ー^¥=〜|")); | |
95 | + assertThat(icuConverter.convert("@[;:]`{+*}"), is("@[;:]`{+*}")); | |
96 | + assertThat(icuConverter.convert("@「;:」`{+*}"), is("@「;:」`{+*}")); | |
97 | + assertThat(icuConverter.convert(",./<>?_"), is(",./<>?_")); | |
98 | + assertThat(icuConverter.convert("、。・<>?_"), is("、。・<>?_")); | |
99 | + assertThat(icuConverter.convert("あいうえお"), is("あいうえお")); | |
100 | + assertThat(icuConverter.convert("アイウエオ"), is("あいうえお")); | |
101 | + assertThat(icuConverter.convert("アイウエオ"), is("あいうえお")); | |
102 | + assertThat(icuConverter.convert("漢字"), is("漢字")); | |
103 | + assertThat(icuConverter.convert(" "), is(" ")); | |
104 | + | |
105 | + } | |
106 | + | |
107 | + @Test | |
108 | + public void convertHiraganaKatakana() { | |
109 | + final ICUConverter icuConverter = new ICUConverter("Hiragana-Katakana"); | |
110 | + assertThat(icuConverter.convert("123"), is("123")); | |
111 | + assertThat(icuConverter.convert("123"), is("123")); | |
112 | + assertThat(icuConverter.convert("abc"), is("abc")); | |
113 | + assertThat(icuConverter.convert("abc"), is("abc")); | |
114 | + assertThat(icuConverter.convert("ABC"), is("ABC")); | |
115 | + assertThat(icuConverter.convert("ABC"), is("ABC")); | |
116 | + assertThat(icuConverter.convert("!\"#$%&'()~"), is("!\"#$%&'()~")); | |
117 | + assertThat(icuConverter.convert("!”#$%&’()〜"), is("!”#$%&’()〜")); | |
118 | + assertThat(icuConverter.convert("-^\\=~|"), is("-^\\=~|")); | |
119 | + assertThat(icuConverter.convert("ー^¥=〜|"), is("ー^¥=〜|")); | |
120 | + assertThat(icuConverter.convert("@[;:]`{+*}"), is("@[;:]`{+*}")); | |
121 | + assertThat(icuConverter.convert("@「;:」`{+*}"), is("@「;:」`{+*}")); | |
122 | + assertThat(icuConverter.convert(",./<>?_"), is(",./<>?_")); | |
123 | + assertThat(icuConverter.convert("、。・<>?_"), is("、。・<>?_")); | |
124 | + assertThat(icuConverter.convert("あいうえお"), is("アイウエオ")); | |
125 | + assertThat(icuConverter.convert("アイウエオ"), is("アイウエオ")); | |
126 | + assertThat(icuConverter.convert("アイウエオ"), is("アイウエオ")); | |
127 | + assertThat(icuConverter.convert("漢字"), is("漢字")); | |
128 | + assertThat(icuConverter.convert(" "), is(" ")); | |
129 | + | |
130 | + } | |
131 | + | |
132 | + private void printTransliteratorIDs() { | |
133 | + final Enumeration<String> availableIDs = Transliterator | |
134 | + .getAvailableIDs(); | |
135 | + while (availableIDs.hasMoreElements()) { | |
136 | + System.out.println("ID: " + availableIDs.nextElement()); | |
137 | + } | |
138 | + } | |
139 | + | |
140 | +} |
@@ -0,0 +1,14 @@ | ||
1 | +Copyright 2009-${year} the Fess Project and the Others. | |
2 | + | |
3 | +Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | +you may not use this file except in compliance with the License. | |
5 | +You may obtain a copy of the License at | |
6 | + | |
7 | + http://www.apache.org/licenses/LICENSE-2.0 | |
8 | + | |
9 | +Unless required by applicable law or agreed to in writing, software | |
10 | +distributed under the License is distributed on an "AS IS" BASIS, | |
11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
12 | +either express or implied. See the License for the specific language | |
13 | +governing permissions and limitations under the License. | |
14 | + |
@@ -0,0 +1,13 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<additionalHeaders> | |
3 | + <javadoc_style> | |
4 | + <firstLine>/*</firstLine> | |
5 | + <beforeEachLine> * </beforeEachLine> | |
6 | + <endLine> */</endLine> | |
7 | + <!--skipLine></skipLine--> | |
8 | + <firstLineDetectionPattern>(\s|\t)*/\*.*$</firstLineDetectionPattern> | |
9 | + <lastLineDetectionPattern>.*\*/(\s|\t)*$</lastLineDetectionPattern> | |
10 | + <allowBlankLines>false</allowBlankLines> | |
11 | + <isMultiline>true</isMultiline> | |
12 | + </javadoc_style> | |
13 | +</additionalHeaders> |