diff --git a/README.md b/README.md index b27caf8..89874ad 100755 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ you can download this plugin from RTF project(https://github.com/medcl/elasticse -------------------------------------------------- | STConvert Analysis Plugin | Elasticsearch | -------------------------------------------------- + | 1.8.5 | 2.3.5 | + -------------------------------------------------- | 1.8.4 | 2.3.4 | -------------------------------------------------- | 1.8.3 | 2.3.3 | @@ -78,77 +80,3 @@ Analyze tests {"tokens":[{"token":"北京國際電視檯","start_offset":0,"end_offset":7,"type":"word","position":0},{"token":"北京國際電視臺","start_offset":8,"end_offset":15,"type":"word","position":1}]}% ``` - -Custom analyzer example: - -elasticsearch.yml - -``` - -index: - analysis: - - tokenizer: - s2t_convert: - type: stconvert - delimiter: "," - convert_type: s2t - t2s_convert: - type: stconvert - delimiter: "," - convert_type: t2s - s2t_keep_both_convert: - type: stconvert - delimiter: "," - keep_both: 'true' - convert_type: s2t - t2s_keep_both_convert: - type: stconvert - delimiter: "," - keep_both: 'true' - convert_type: t2s - - filter: - s2t_convert: - type: stconvert - delimiter: "," - convert_type: s2t - t2s_convert: - type: stconvert - delimiter: "," - convert_type: t2s - s2t_keep_both_convert: - type: stconvert - delimiter: "," - keep_both: 'true' - convert_type: s2t - t2s_keep_both_convert: - type: stconvert - delimiter: "," - keep_both: 'true' - convert_type: t2s - - analyzer: - stconvert: - alias: - - st_analyzer - type: stconvert - s2t_convert: - type: stconvert - delimiter: "," - convert_type: s2t - t2s_convert: - type: stconvert - delimiter: "," - convert_type: t2s - s2t_keep_both_convert: - type: stconvert - delimiter: "," - keep_both: 'true' - convert_type: s2t - t2s_keep_both_convert: - type: stconvert - delimiter: "," - keep_both: 'true' - convert_type: t2s -``` diff --git a/pom.xml b/pom.xml index c6b4c81..5789dbe 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.infinitbyte elasticsearch-analysis-stconvert - 1.8.4 + 1.8.5 jar http://log.medcl.net stconvert is a analysis plugin that convert Chinese characters between traditional and simplified. @@ -32,7 +32,7 @@ - 2.3.4 + 2.3.5 1.7 ${project.basedir}/src/main/assemblies/plugin.xml analysis-stconvert diff --git a/src/main/java/org/elasticsearch/index/analysis/STConverter.java b/src/main/java/org/elasticsearch/index/analysis/STConverter.java index 795de9b..2df7207 100755 --- a/src/main/java/org/elasticsearch/index/analysis/STConverter.java +++ b/src/main/java/org/elasticsearch/index/analysis/STConverter.java @@ -15,7 +15,7 @@ public class STConverter { private Properties charMap = new Properties(); private Properties revCharMap = new Properties(); - private Set conflictingSets = new HashSet(); + private Set conflictingSets = new HashSet(); private static STConverter instance=new STConverter(); public STConverter(){ @@ -65,10 +65,10 @@ private void initializeHelper() { String keySubstring = key.substring(0, i + 1); if (stringPossibilities.containsKey(keySubstring)) { Integer integer = (Integer)(stringPossibilities.get(keySubstring)); - stringPossibilities.put(keySubstring, new Integer(Integer.valueOf(integer) + 1)); + stringPossibilities.put(keySubstring, Integer.valueOf(integer) + 1); } else { - stringPossibilities.put(keySubstring, new Integer(1)); + stringPossibilities.put(keySubstring, 1); } } @@ -78,7 +78,7 @@ private void initializeHelper() { iter = stringPossibilities.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); - int value = Integer.valueOf( (Integer)stringPossibilities.get(key) ); + int value = (Integer)stringPossibilities.get(key); if (value > 1) { conflictingSets.add(key); } @@ -86,7 +86,7 @@ private void initializeHelper() { } public String convert(STConvertType type,String in) { - Map map=charMap; + Map map=charMap; if(type== STConvertType.SIMPLE_2_TRADITIONAL){ map=revCharMap; } @@ -125,7 +125,7 @@ public String convert(String text, STConvertType converterType) { return getInstance().convert(converterType,text); } - private static void mapping(Map map, StringBuilder outString, StringBuilder stackString) { + private static void mapping(Map map, StringBuilder outString, StringBuilder stackString) { while (stackString.length() > 0){ if (map.containsKey(stackString.toString())) { outString.append(map.get(stackString.toString()));