Support Japanese language

This commit is contained in:
jendib 2013-08-17 02:40:28 +02:00
parent 7bb1f48464
commit 5507d4ca57
4 changed files with 6 additions and 3 deletions

View File

@ -48,5 +48,5 @@ public class Constants {
/** /**
* Supported document languages. * Supported document languages.
*/ */
public static final List<String> SUPPORTED_LANGUAGES = Lists.newArrayList("eng", "fra"); public static final List<String> SUPPORTED_LANGUAGES = Lists.newArrayList("eng", "fra", "jpn");
} }

View File

@ -1,7 +1,9 @@
package com.sismics.docs.core.dao.lucene; package com.sismics.docs.core.dao.lucene;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField; import org.apache.lucene.document.StringField;
@ -100,7 +102,7 @@ public class LuceneDao {
* @return List of file IDs * @return List of file IDs
* @throws Exception * @throws Exception
*/ */
public List<String> search(String userId, String searchQuery, int limit) throws Exception { public Set<String> search(String userId, String searchQuery, int limit) throws Exception {
// Escape query and add quotes so QueryParser generate a PhraseQuery // Escape query and add quotes so QueryParser generate a PhraseQuery
searchQuery = "\"" + QueryParserUtil.escape(searchQuery) + "\""; searchQuery = "\"" + QueryParserUtil.escape(searchQuery) + "\"";
@ -125,7 +127,7 @@ public class LuceneDao {
ScoreDoc[] docs = topDocs.scoreDocs; ScoreDoc[] docs = topDocs.scoreDocs;
// Extract file IDs // Extract file IDs
List<String> fileIdList = new ArrayList<String>(); Set<String> fileIdList = new HashSet<String>();
for (int i = 0; i < docs.length; i++) { for (int i = 0; i < docs.length; i++) {
String id = searcher.doc(docs[i].doc).get("id"); String id = searcher.doc(docs[i].doc).get("id");
fileIdList.add(id); fileIdList.add(id);

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

View File

@ -26,6 +26,7 @@
<select id="inputLanguage" ng-model="document.language"> <select id="inputLanguage" ng-model="document.language">
<option value="fra">French</option> <option value="fra">French</option>
<option value="eng">English</option> <option value="eng">English</option>
<option value="jpn">Japanese</option>
</select> </select>
</div> </div>
</div> </div>