Skip to content

Commit

Permalink
Add new property to store correction profile with pinyin ime
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Mar 23, 2024
1 parent 6ddb1ed commit 24dc861
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/libime/pinyin/pinyinime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
#include "pinyinime.h"
#include "libime/core/userlanguagemodel.h"
#include "libime/pinyin/pinyincorrectionprofile.h"
#include "libime/pinyin/pinyinencoder.h"
#include "pinyindecoder.h"

namespace libime {
Expand All @@ -25,6 +27,7 @@ class PinyinIMEPrivate : fcitx::QPtrHolder<PinyinIME> {
std::unique_ptr<UserLanguageModel> model_;
std::unique_ptr<PinyinDecoder> decoder_;
std::shared_ptr<const ShuangpinProfile> spProfile_;
std::shared_ptr<const PinyinCorrectionProfile> correctionProfile_;
size_t nbest_ = 1;
size_t beamSize_ = Decoder::beamSizeDefault;
size_t frameSize_ = Decoder::frameSizeDefault;
Expand Down Expand Up @@ -174,4 +177,20 @@ std::shared_ptr<const ShuangpinProfile> PinyinIME::shuangpinProfile() const {
FCITX_D();
return d->spProfile_;
}

void PinyinIME::setCorrectionProfile(
std::shared_ptr<const PinyinCorrectionProfile> profile) {
FCITX_D();
if (d->correctionProfile_ != profile) {
d->correctionProfile_ = std::move(profile);
emit<PinyinIME::optionChanged>();
}
}

std::shared_ptr<const PinyinCorrectionProfile>
PinyinIME::correctionProfile() const {
FCITX_D();
return d->correctionProfile_;
}

} // namespace libime
5 changes: 5 additions & 0 deletions src/libime/pinyin/pinyinime.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "libimepinyin_export.h"
#include <fcitx-utils/connectableobject.h>
#include <fcitx-utils/macros.h>
#include <libime/pinyin/pinyincorrectionprofile.h>
#include <libime/pinyin/pinyinencoder.h>
#include <limits>
#include <memory>
Expand Down Expand Up @@ -46,6 +47,10 @@ class LIBIMEPINYIN_EXPORT PinyinIME : public fcitx::ConnectableObject {
void setPreeditMode(PinyinPreeditMode mode);
PinyinPreeditMode preeditMode() const;

void setCorrectionProfile(
std::shared_ptr<const PinyinCorrectionProfile> profile);
std::shared_ptr<const PinyinCorrectionProfile> correctionProfile() const;

float maxDistance() const;
float minPath() const;

Expand Down

0 comments on commit 24dc861

Please sign in to comment.