Skip to content

Commit

Permalink
es
Browse files Browse the repository at this point in the history
  • Loading branch information
ysc committed Oct 25, 2017
1 parent 69d9859 commit 91c43f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.apdplat.word.elasticsearch;

import org.apdplat.word.lucene.ChineseWordAnalyzer;
import org.apdplat.word.segmentation.Segmentation;
import org.apdplat.word.segmentation.SegmentationAlgorithm;
import org.apdplat.word.segmentation.SegmentationFactory;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -17,21 +16,10 @@
public class ChineseWordAnalyzerProvider extends AbstractIndexAnalyzerProvider<ChineseWordAnalyzer> {
private static final Logger LOGGER = LoggerFactory.getLogger(ChineseWordAnalyzerProvider.class);

private final ChineseWordAnalyzer analyzer;
private final Segmentation segmentation;
private final ChineseWordAnalyzer analyzer = new ChineseWordAnalyzer(SegmentationFactory.getSegmentation(SegmentationAlgorithm.MaxNgramScore));

public ChineseWordAnalyzerProvider(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
super(indexSettings, name, settings);
String segAlgorithm = settings.get("segAlgorithm");
if(segAlgorithm != null){
LOGGER.info("tokenizer使用指定分词算法:"+segAlgorithm);
segmentation = SegmentationFactory.getSegmentation(SegmentationAlgorithm.valueOf(segAlgorithm));
}else{
LOGGER.info("没有为word tokenizer指定segAlgorithm参数");
LOGGER.info("tokenizer使用默认分词算法:"+SegmentationAlgorithm.MaxNgramScore);
segmentation = SegmentationFactory.getSegmentation(SegmentationAlgorithm.MaxNgramScore);
}
analyzer = new ChineseWordAnalyzer(segmentation);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,10 @@
*/
public class ChineseWordTokenizerFactory extends AbstractTokenizerFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(ChineseWordTokenizerFactory.class);
private final Segmentation segmentation;
private final Segmentation segmentation = SegmentationFactory.getSegmentation(SegmentationAlgorithm.MaxNgramScore);

public ChineseWordTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
super(indexSettings, name, settings);
String segAlgorithm = settings.get("segAlgorithm");
if(segAlgorithm != null){
LOGGER.info("tokenizer使用指定分词算法:"+segAlgorithm);
segmentation = SegmentationFactory.getSegmentation(SegmentationAlgorithm.valueOf(segAlgorithm));
}else{
LOGGER.info("没有为word tokenizer指定segAlgorithm参数");
LOGGER.info("tokenizer使用默认分词算法:"+SegmentationAlgorithm.MaxNgramScore);
segmentation = SegmentationFactory.getSegmentation(SegmentationAlgorithm.MaxNgramScore);
}
}

@Override
Expand Down

0 comments on commit 91c43f0

Please sign in to comment.