Skip to content

Commit

Permalink
Update HanLPAnalyzerProvider.java
Browse files Browse the repository at this point in the history
  • Loading branch information
kepmov authored Sep 6, 2018
1 parent 837de75 commit 8d552a3
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package org.elasticsearch.index.analysis;

import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.utility.Predefine;
import com.hankcs.lucene4.HanLPIndexAnalyzer;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.assistedinject.Assisted;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import java.io.File;
import java.nio.file.Path;

/**
*/
public class HanLPAnalyzerProvider extends AbstractIndexAnalyzerProvider<HanLPIndexAnalyzer> {

private final HanLPIndexAnalyzer analyzer;
private static String sysPath = String.valueOf(System.getProperties().get("user.dir"));

@Inject
public HanLPAnalyzerProvider(IndexSettings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) {
super(indexSettings, name, settings);
Predefine.HANLP_PROPERTIES_PATH = sysPath.substring(0, sysPath.length()-4) + File.separator + "plugins" + File.separator + "analysis-hanlp" + File.separator + "hanlp.properties";
Path pluginsDir = env.pluginsFile();
Predefine.HANLP_PROPERTIES_PATH = pluginsDir.toString() + File.separator + "analysis-hanlp" + File.separator + "hanlp.properties";
analyzer = new HanLPIndexAnalyzer(true);
}

Expand Down

0 comments on commit 8d552a3

Please sign in to comment.