From 9a37ef183ac3c4600c254d42b604843d90b040bb Mon Sep 17 00:00:00 2001 From: Xuesong Peng Date: Tue, 23 May 2023 13:32:11 +0800 Subject: [PATCH 1/5] fix #652: process whole conversion chain * continue to process whole conversion chain for whole candidate matching except for the candidate original form --- src/rime/gear/simplifier.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index 9e233396e..d010a2d34 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -250,7 +250,13 @@ bool Simplifier::Convert(const an& original, if (forms[i] == original->text()) { result->push_back(original); } else { - PushBack(original, result, forms[i]); + string simplified; + success = opencc_->ConvertText(forms[i], &simplified); + if (success && original->text().compare(simplified) != 0) { + PushBack(original, result, simplified); + } else { + PushBack(original, result, forms[i]); + } } } } else { From a625ff605fcf64d6550b6f35c3f59d3589e93d28 Mon Sep 17 00:00:00 2001 From: Xuesong Peng Date: Fri, 26 May 2023 11:50:14 +0800 Subject: [PATCH 2/5] fix Simplifier::Convert return value --- src/rime/gear/simplifier.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index d010a2d34..604038e0e 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -251,8 +251,8 @@ bool Simplifier::Convert(const an& original, result->push_back(original); } else { string simplified; - success = opencc_->ConvertText(forms[i], &simplified); - if (success && original->text().compare(simplified) != 0) { + const bool success_converted = opencc_->ConvertText(forms[i], &simplified); + if (success_converted && original->text().compare(simplified) != 0) { PushBack(original, result, simplified); } else { PushBack(original, result, forms[i]); From f9179a6613ae5a5e74f6ff66b3f4f169829bfd0f Mon Sep 17 00:00:00 2001 From: Xuesong Peng Date: Fri, 26 May 2023 13:39:24 +0800 Subject: [PATCH 3/5] convert from original text --- src/rime/gear/simplifier.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index 604038e0e..cebccdf45 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -251,7 +251,7 @@ bool Simplifier::Convert(const an& original, result->push_back(original); } else { string simplified; - const bool success_converted = opencc_->ConvertText(forms[i], &simplified); + const bool success_converted = opencc_->ConvertText(original->text(), &simplified); if (success_converted && original->text().compare(simplified) != 0) { PushBack(original, result, simplified); } else { From 214829a6d005e1b0fd62a90007e7c51971ed0ee8 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Tue, 8 Aug 2023 21:09:31 -0400 Subject: [PATCH 4/5] lint --- src/rime/gear/simplifier.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index 3d784594f..707a448ed 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -247,7 +247,8 @@ bool Simplifier::Convert(const an& original, result->push_back(original); } else { string simplified; - const bool success_converted = opencc_->ConvertText(original->text(), &simplified); + const bool success_converted = + opencc_->ConvertText(original->text(), &simplified); if (success_converted && original->text().compare(simplified) != 0) { PushBack(original, result, simplified); } else { From 91325f25ac45f60b8e88512bb436dd1923a53b69 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Tue, 8 Aug 2023 22:00:02 -0400 Subject: [PATCH 5/5] readability --- src/rime/gear/simplifier.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index 707a448ed..45d43e997 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -249,7 +249,7 @@ bool Simplifier::Convert(const an& original, string simplified; const bool success_converted = opencc_->ConvertText(original->text(), &simplified); - if (success_converted && original->text().compare(simplified) != 0) { + if (success_converted && original->text() != simplified) { PushBack(original, result, simplified); } else { PushBack(original, result, forms[i]);