forked from infinilabs/analysis-pinyin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
拼音切词全文本offset使用原始位置+ 拼音串切分正向逆向取最大匹配 (infinilabs#183)
* 去除重复的拼音,添加rui等拼音。去除无用的韵母ue uan eng等 * pinyin offset + alphabettokenizer optimize * 拼音字母分词,非字母连接在一起 * pinyin no letter join
- Loading branch information
Showing
5 changed files
with
163 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/org/elasticsearch/index/analysis/PinyinAlphabetTokenizerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.elasticsearch.index.analysis; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* 拼音串切分,很难做到最好,认为取最少切分是最好的 | ||
* | ||
* @author shenyanchao | ||
* @since 2018-10-08 12:22 | ||
*/ | ||
public class PinyinAlphabetTokenizerTest { | ||
|
||
@Test | ||
public void walk() throws Exception { | ||
|
||
Assert.assertEquals(Arrays.asList("xian").toString(), PinyinAlphabetTokenizer.walk("xian").toString()); | ||
Assert.assertEquals(Arrays.asList("wo", "shi", "liang").toString(), | ||
PinyinAlphabetTokenizer.walk("woshiliang").toString()); | ||
|
||
Assert.assertEquals(Arrays.asList("zhong", "hua", "ren", "min", "gong", "he", "guo").toString(), | ||
PinyinAlphabetTokenizer.walk("zhonghuarenmingongheguo").toString()); | ||
Assert.assertEquals( | ||
Arrays.asList("5", "zhong", "hua", "ren", "89", "min", "gong", "he", "guo", "234").toString(), | ||
PinyinAlphabetTokenizer.walk("5zhonghuaren89mingongheguo234").toString()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,8 @@ | |
|
||
/** | ||
*/ | ||
public class PinyinAnalysisTests { | ||
|
||
public class PinyinAnalysisTest { | ||
|
||
|
||
@Test | ||
|