public static SynonymMap buildAcronymsMergingMap() throws IOException { SynonymMap.Builder synonymMap = new SynonymMap.Builder(true); synonymMap.add(new CharsRef("אף על פי כן"), new CharsRef("אעפ\"כ"), false); synonymMap.add(new CharsRef("אף על פי"), new CharsRef("אע\"פ"), false); synonymMap.add(new CharsRef("כמו כן"), new CharsRef("כמו\"כ"), false); synonymMap.add(new CharsRef("על ידי"), new CharsRef("ע\"י"), false); synonymMap.add(new CharsRef("על פי"), new CharsRef("ע\"פ"), false); synonymMap.add(new CharsRef("כל כך"), new CharsRef("כ\"כ"), false); synonymMap.add(new CharsRef("בדרך כלל"), new CharsRef("בד\"כ"), false); return synonymMap.build(); }
private void setupSynonymMap() throws IOException, BadHanyuPinyinOutputFormatCombination { char[][] chineseChars = { // {from, to} {'\u4e00', '\u9fa5'} }; SynonymMap.Builder builder = new SynonymMap.Builder(true); for (int i = 0; i < chineseChars.length; i++) { char[] charRange = chineseChars[i]; for (char c = charRange[0]; c <= charRange[1]; c++) { String[] pinyinArr = pinyinSynonymArr(c); if (pinyinArr == null) { continue; } addTo(builder, new String[] {Character.toString(c)}, flattenPinyinArr(pinyinArr)); } } pinyinSynonymMap = builder.build(); }