Skip to content

Commit

Permalink
确保cncity字典返回的拼音均只包含英文字母,fix promeG#5
Browse files Browse the repository at this point in the history
  • Loading branch information
promeG committed Mar 11, 2017
1 parent 1622fb0 commit 5de8365
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tinypinyin-lexicons-android-cncity/src/main/assets/cncity.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DU'LAN 都兰

DU'LAN 都兰
ZHA'SHUI 柞水
LU'HE 六合
JUN'LIAN 筠连
Expand Down Expand Up @@ -64,7 +65,6 @@ CHANG'QING 长清
CHANG'FENG 长丰
CHANG'LE 长乐
FENG'DU 丰都
A'BA 阿坝
KA'SHI 喀什
TONG'BAI 桐柏
YUE'QING 乐清
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void words() throws Exception {
Set<String> words = mDict.mapping().keySet();

assertThat(words.contains(null), is(false));
assertThat(words.size(), is(98));
assertThat(words.size(), is(97));
}

@Test
Expand Down Expand Up @@ -75,6 +75,19 @@ public void toPinyin_test_not_same_with_PinyinOrigin() throws Exception {
}
}

// 字典返回的拼音应该只包含英文字母, fix issue 5
@Test
public void test_pinyin_only_contains_letters() throws Exception {
Set<String> words = mDict.mapping().keySet();
for (String word : words) {
String[] pinyins = mDict.mapping().get(word);

for (String pinyin : pinyins) {
assertThat(pinyin.matches("[a-zA-Z]+"), is(true));
}
}
}


}
//CHECKSTYLE:ON
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DU'LAN 都兰

DU'LAN 都兰
ZHA'SHUI 柞水
LU'HE 六合
JUN'LIAN 筠连
Expand Down Expand Up @@ -64,7 +65,6 @@ CHANG'QING 长清
CHANG'FENG 长丰
CHANG'LE 长乐
FENG'DU 丰都
A'BA 阿坝
KA'SHI 喀什
TONG'BAI 桐柏
YUE'QING 乐清
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void words() throws Exception {
Set<String> words = mDict.mapping().keySet();

assertThat(words.contains(null), is(false));
assertThat(words.size(), is(98));
assertThat(words.size(), is(97));
}

@Test
Expand Down Expand Up @@ -66,5 +66,18 @@ public void toPinyin_test_not_same_with_PinyinOrigin() throws Exception {
assertThat(hasDifferent, is(true));
}
}

// 字典返回的拼音应该只包含英文字母, fix issue 5
@Test
public void test_pinyin_only_contains_letters() throws Exception {
Set<String> words = mDict.mapping().keySet();
for (String word : words) {
String[] pinyins = mDict.mapping().get(word);

for (String pinyin : pinyins) {
assertThat(pinyin.matches("[a-zA-Z]+"), is(true));
}
}
}
}
//CHECKSTYLE:ON

0 comments on commit 5de8365

Please sign in to comment.