5
5
*/
6
6
7
7
#include " pinyindata.h"
8
- #include " libime/pinyin/ pinyinencoder.h"
8
+ #include " pinyinencoder.h"
9
9
#include < boost/algorithm/string/predicate.hpp>
10
10
#include < fcitx-utils/stringutils.h>
11
- #include < unordered_map>
12
- #include < unordered_set>
13
- #include < utility>
14
11
15
12
namespace libime {
16
13
@@ -990,10 +987,8 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
990
987
} else if (boost::algorithm::ends_with (result, " ua" )) {
991
988
result[result.size () - 2 ] = ' a' ;
992
989
result[result.size () - 1 ] = ' u' ;
993
- } else if (boost::algorithm::ends_with (result, " uai" )) {
994
- result[result.size () - 3 ] = ' a' ;
995
- result[result.size () - 2 ] = ' u' ;
996
- } else if (boost::algorithm::ends_with (result, " uan" )) {
990
+ } else if (boost::algorithm::ends_with (result, " uai" ) ||
991
+ boost::algorithm::ends_with (result, " uan" )) {
997
992
result[result.size () - 3 ] = ' a' ;
998
993
result[result.size () - 2 ] = ' u' ;
999
994
} else if (boost::algorithm::ends_with (result, " van" )) {
@@ -1027,8 +1022,8 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
1027
1022
if (entry.flags ().test (PinyinFuzzyFlag::AdvancedTypo)) {
1028
1023
break ;
1029
1024
}
1030
- for (const auto two : {" ai" , " ia" , " ei" , " ie" , " ao" , " uo" , " ou " ,
1031
- " iu" , " an" , " en" , " in" }) {
1025
+ for (const auto * const two : {" ai" , " ia" , " ei" , " ie" , " ao" , " uo" ,
1026
+ " ou " , " iu" , " an" , " en" , " in" }) {
1032
1027
if (boost::algorithm::ends_with (result, two)) {
1033
1028
std::swap (result[result.size () - 2 ],
1034
1029
result[result.size () - 1 ]);
@@ -1038,7 +1033,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
1038
1033
if (entry.flags ().test (PinyinFuzzyFlag::AdvancedTypo)) {
1039
1034
break ;
1040
1035
}
1041
- for (const auto three :
1036
+ for (const auto * const three :
1042
1037
{" ang" , " eng" , " ing" , " ong" , " iao" , " ian" }) {
1043
1038
if (boost::algorithm::ends_with (result, three)) {
1044
1039
std::swap (result[result.size () - 3 ],
@@ -1049,7 +1044,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
1049
1044
if (entry.flags ().test (PinyinFuzzyFlag::AdvancedTypo)) {
1050
1045
break ;
1051
1046
}
1052
- for (const auto four : {" iang" , " iong" }) {
1047
+ for (const auto * const four : {" iang" , " iong" }) {
1053
1048
if (boost::algorithm::ends_with (result, four)) {
1054
1049
std::swap (result[result.size () - 4 ],
1055
1050
result[result.size () - 3 ]);
@@ -1208,7 +1203,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
1208
1203
1209
1204
void applyFuzzy (PinyinMap &map, PinyinFuzzyFlag fz, int pass = 0 ) {
1210
1205
std::vector<PinyinEntry> newEntries;
1211
- for (auto &entry : map) {
1206
+ for (const auto &entry : map) {
1212
1207
if (auto newEntry = applyFuzzy (entry, fz, pass)) {
1213
1208
newEntries.push_back (*newEntry);
1214
1209
}
0 commit comments