Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 29 additions & 21 deletions data/dictionary/DictionaryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,38 @@ TEST_F(DictionaryRunfilesTest, TWPhrasesReverseMapping) {
return map;
};

LexiconPtr twPhrases = loadLexicon(twPhrasesFile);
LexiconPtr twPhrasesRev = loadLexicon(twPhrasesRevFile);
ASSERT_NE(twPhrases, nullptr);
ASSERT_NE(twPhrasesRev, nullptr);

auto twMap = buildMap(twPhrases);
auto twRevMap = buildMap(twPhrasesRev);

for (const auto& entry : twMap) {
const std::string& key = entry.first;
for (const auto& value : entry.second) {
auto it = twRevMap.find(value);
EXPECT_TRUE(it != twRevMap.end() && it->second.count(key) > 0)
<< "Missing reverse mapping: " << key << " -> " << value;
try {
LexiconPtr twPhrases = loadLexicon(twPhrasesFile);
LexiconPtr twPhrasesRev = loadLexicon(twPhrasesRevFile);
ASSERT_NE(twPhrases, nullptr);
ASSERT_NE(twPhrasesRev, nullptr);

auto twMap = buildMap(twPhrases);
auto twRevMap = buildMap(twPhrasesRev);

for (const auto& entry : twMap) {
const std::string& key = entry.first;
for (const auto& value : entry.second) {
auto it = twRevMap.find(value);
EXPECT_TRUE(it != twRevMap.end() && it->second.count(key) > 0)
<< "Missing reverse mapping: " << key << " -> " << value;
}
}
}

for (const auto& entry : twRevMap) {
const std::string& key = entry.first;
for (const auto& value : entry.second) {
auto it = twMap.find(value);
EXPECT_TRUE(it != twMap.end() && it->second.count(key) > 0)
<< "Missing reverse mapping: " << key << " -> " << value;
for (const auto& entry : twRevMap) {
const std::string& key = entry.first;
for (const auto& value : entry.second) {
auto it = twMap.find(value);
EXPECT_TRUE(it != twMap.end() && it->second.count(key) > 0)
<< "Missing reverse mapping: " << key << " -> " << value;
}
}
} catch (const Exception& ex) {
FAIL() << "Exception: " << ex.what();
} catch (const std::exception& ex) {
FAIL() << "std::exception: " << ex.what();
} catch (...) {
FAIL() << "Unknown exception thrown during reverse mapping check.";
}
}

Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/HKVariants.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: HKVariants.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: s2hk.json, t2hk.json

僞 偽
兌 兑
叄 叁
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/HKVariantsRevPhrases.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: HKVariantsRevPhrases.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: hk2s.json, hk2t.json

一口吃個 一口喫個
一口吃成 一口喫成
一家三口 一家三口
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/JPShinjitaiCharacters.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: JPShinjitaiCharacters.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: jp2t.json

両 兩 輛
弁 辨 辯 瓣 辦 弁
御 御 禦
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/JPShinjitaiPhrases.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: JPShinjitaiPhrases.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: jp2t.json

一獲千金 一攫千金
丁寧 叮嚀
丁重 鄭重
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/JPVariants.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: JPVariants.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: t2jp.json

乘 乗
亂 乱
亙 亘
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/STCharacters.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: STCharacters.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: s2hk.json, s2t.json, s2tw.json, s2twp.json

㐷 傌
㐹 㑶 㐹
㐽 偑
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/STPhrases.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: STPhrases.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: s2hk.json, s2t.json, s2tw.json, s2twp.json

㓦划 㓦劃
一丝不挂 一絲不掛
一了心愿 一了心願
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/TSCharacters.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: TSCharacters.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: hk2s.json, t2s.json, tw2s.json, tw2sp.json

㑮 𫝈
㑯 㑔
㑳 㑇
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/TSPhrases.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: TSPhrases.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: hk2s.json, t2s.json, tw2s.json, tw2sp.json

一目瞭然 一目了然
上鍊 上链
不瞭解 不了解
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/TWPhrases.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: TWPhrases.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: s2twp.json (via TWPhrases.ocd2)

PN結 PN接面
SQL注入 SQL隱碼攻擊
SQL注入攻擊 SQL隱碼攻擊
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/TWPhrasesRev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: TWPhrasesRev.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: tw2sp.json (via TWPhrasesRev.ocd2)

PN接面 PN結
SQL隱碼攻擊 SQL注入 SQL注入攻擊
三極體 三極管
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/TWVariants.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: TWVariants.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: s2tw.json, s2twp.json, t2tw.json

僞 偽
啓 啟
喫 吃
Expand Down
7 changes: 7 additions & 0 deletions data/dictionary/TWVariantsRevPhrases.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: TWVariantsRevPhrases.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: tw2s.json, tw2sp.json, tw2t.json

一口吃個 一口喫個
一口吃成 一口喫成
一家三口 一家三口
Expand Down
Loading
Loading