package org.elasticsearch.index.analysis;

import org.apache.lucene.analysis.Tokenizer;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.apache.lucene.analysis.vi.VietnameseTokenizer;
import org.elasticsearch.index.settings.IndexSettings;

import java.io.Reader;

/**
 * @author duydo
 */
public class VietnameseTokenizerFactory extends AbstractTokenizerFactory {

    private boolean useSentenceDetector = true;
    private boolean useAmbiguitiesResolved = false;

    @Inject
    public VietnameseTokenizerFactory(Index index, @IndexSettings Settings indexSettings, String name, Settings settings) {
        super(index, indexSettings, name, settings);
        useSentenceDetector = settings.getAsBoolean("use_sentence_detector", Boolean.TRUE);
        useAmbiguitiesResolved = settings.getAsBoolean("use_ambiguities_resolved", Boolean.FALSE);
    }

    @Override
    public Tokenizer create(Reader reader) {
        return new VietnameseTokenizer(reader, useSentenceDetector, useAmbiguitiesResolved);
    }
}

@@ -128,16 +128,80 @@
 Inject;%0A
+import org.elasticsearch.common.inject.assistedinject.Assisted;%0A
 import o
@@ -532,24 +532,30 @@
 private 
+final 
 boolean 
 useSente
@@ -546,20 +546,17 @@
 boolean 
-useS
+s
 entenceD
@@ -566,15 +566,15 @@
 ctor
- = true
+Enabled
 ;%0A  
@@ -583,24 +583,30 @@
 private 
+final 
 boolean 
 useAmbig
@@ -597,20 +597,17 @@
 boolean 
-useA
+a
 mbiguiti
@@ -620,16 +620,8 @@
 lved
- = false
 ;%0A%0A 
@@ -720,16 +720,26 @@
 ettings,
+ @Assisted
  String 
@@ -743,16 +743,64 @@
 ng name,
+%0A                                      @Assisted
  Setting
@@ -874,20 +874,17 @@
         
-useS
+s
 entenceD
@@ -890,16 +890,23 @@
 Detector
+Enabled
  = setti
@@ -923,20 +923,16 @@
 oolean(%22
-use_
 sentence
@@ -966,20 +966,17 @@
         
-useA
+a
 mbiguiti
@@ -1015,12 +1015,8 @@
 an(%22
-use_
 ambi
@@ -1167,12 +1167,9 @@
 er, 
-useS
+s
 ente
@@ -1183,14 +1183,18 @@
 ctor
-, useA
+Enabled, a
 mbig

read settings