Skip to content

Commit

Permalink
Allow un -> vn for jqxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed May 31, 2024
1 parent a171fea commit 4380a8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libime/pinyin/pinyindata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@

#include "pinyindata.h"
#include "pinyinencoder.h"
#include <algorithm>
#include <boost/algorithm/string/predicate.hpp>
#include <cstdint>
#include <fcitx-utils/log.h>
#include <fcitx-utils/stringutils.h>
#include <iterator>
#include <optional>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

namespace libime {

Expand Down Expand Up @@ -989,7 +996,8 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
result.back() = 'v';
}

if (boost::algorithm::ends_with(result, "ue")) {
if (boost::algorithm::ends_with(result, "ue") ||
boost::algorithm::ends_with(result, "un")) {
result[result.size() - 2] = 'v';
}
if (boost::algorithm::ends_with(result, "uan")) {
Expand Down
8 changes: 8 additions & 0 deletions test/testpinyindata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
#include "libime/pinyin/pinyindata.h"
#include "libime/pinyin/pinyinencoder.h"
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <cstdint>
#include <fcitx-utils/log.h>
#include <iostream>
#include <iterator>
#include <ostream>
#include <string>
#include <unordered_set>

using namespace libime;
Expand Down Expand Up @@ -156,5 +162,7 @@ int main() {
}
}
FCITX_ASSERT(getPinyinMapV2().count("zhaung"));
FCITX_ASSERT(getPinyinMapV2().count("jvn"));
FCITX_ASSERT(getPinyinMapV2().count("yvn"));
return 0;
}

0 comments on commit 4380a8c

Please sign in to comment.